mirror of
https://github.com/sern-handler/website
synced 2026-06-26 09:42:24 +00:00
feat: migrate to starlight
This commit is contained in:
49
node_modules/direction/cli.js
generated
vendored
Executable file
49
node_modules/direction/cli.js
generated
vendored
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env node
|
||||
import fs from 'node:fs'
|
||||
import process from 'node:process'
|
||||
|
||||
import {direction} from './index.js'
|
||||
|
||||
/** @type {{[key: string]: unknown, version: string}} */
|
||||
const pack = JSON.parse(String(fs.readFileSync('package.json')))
|
||||
|
||||
const argv = process.argv.slice(2)
|
||||
|
||||
if (argv.includes('--help') || argv.includes('-h')) {
|
||||
console.log(help())
|
||||
} else if (argv.includes('--version') || argv.includes('-v')) {
|
||||
console.log(pack.version)
|
||||
} else if (argv.length === 0) {
|
||||
process.stdin.resume()
|
||||
process.stdin.setEncoding('utf8')
|
||||
process.stdin.on('data', function (data) {
|
||||
console.log(direction(String(data)))
|
||||
})
|
||||
} else {
|
||||
console.log(direction(argv.join(' ')))
|
||||
}
|
||||
|
||||
function help() {
|
||||
return [
|
||||
'',
|
||||
' Usage: ' + pack.name + ' [options] <words...>',
|
||||
'',
|
||||
' ' + pack.description,
|
||||
'',
|
||||
' Options:',
|
||||
'',
|
||||
' -h, --help output usage information',
|
||||
' -v, --version output version number',
|
||||
'',
|
||||
' Usage:',
|
||||
'',
|
||||
' # output directionality',
|
||||
' $ ' + pack.name + ' @',
|
||||
' # ' + direction('@'),
|
||||
'',
|
||||
' # output directionality from stdin',
|
||||
" $ echo 'الانجليزية' | " + pack.name,
|
||||
' # ' + direction('الانجليزية'),
|
||||
''
|
||||
].join('\n')
|
||||
}
|
||||
7
node_modules/direction/index.d.ts
generated
vendored
Normal file
7
node_modules/direction/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Detect the direction of text: left-to-right, right-to-left, or neutral
|
||||
*
|
||||
* @param {string} value
|
||||
* @returns {'rtl'|'ltr'|'neutral'}
|
||||
*/
|
||||
export function direction(value: string): 'rtl' | 'ltr' | 'neutral'
|
||||
21
node_modules/direction/index.js
generated
vendored
Normal file
21
node_modules/direction/index.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
const rtlRange = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC'
|
||||
const ltrRange =
|
||||
'A-Za-z\u00C0-\u00D6\u00D8-\u00F6' +
|
||||
'\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C' +
|
||||
'\uFE00-\uFE6F\uFEFD-\uFFFF'
|
||||
|
||||
/* eslint-disable no-misleading-character-class */
|
||||
const rtl = new RegExp('^[^' + ltrRange + ']*[' + rtlRange + ']')
|
||||
const ltr = new RegExp('^[^' + rtlRange + ']*[' + ltrRange + ']')
|
||||
/* eslint-enable no-misleading-character-class */
|
||||
|
||||
/**
|
||||
* Detect the direction of text: left-to-right, right-to-left, or neutral
|
||||
*
|
||||
* @param {string} value
|
||||
* @returns {'rtl'|'ltr'|'neutral'}
|
||||
*/
|
||||
export function direction(value) {
|
||||
const source = String(value || '')
|
||||
return rtl.test(source) ? 'rtl' : ltr.test(source) ? 'ltr' : 'neutral'
|
||||
}
|
||||
22
node_modules/direction/license
generated
vendored
Normal file
22
node_modules/direction/license
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
78
node_modules/direction/package.json
generated
vendored
Normal file
78
node_modules/direction/package.json
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"name": "direction",
|
||||
"version": "2.0.1",
|
||||
"description": "Detect the direction of text: left-to-right, right-to-left, or neutral",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"writing",
|
||||
"system",
|
||||
"direction",
|
||||
"directionality",
|
||||
"rtl",
|
||||
"ltr",
|
||||
"cli",
|
||||
"bin"
|
||||
],
|
||||
"repository": "wooorm/direction",
|
||||
"bugs": "https://github.com/wooorm/direction/issues",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"bin": "cli.js",
|
||||
"types": "index.d.ts",
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"index.js",
|
||||
"cli.js"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/tape": "^4.0.0",
|
||||
"c8": "^7.0.0",
|
||||
"prettier": "^2.0.0",
|
||||
"remark-cli": "^10.0.0",
|
||||
"remark-preset-wooorm": "^9.0.0",
|
||||
"rimraf": "^3.0.0",
|
||||
"tape": "^5.0.0",
|
||||
"type-coverage": "^2.0.0",
|
||||
"typescript": "^4.0.0",
|
||||
"xo": "^0.46.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublishOnly": "npm run build && npm run format",
|
||||
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
|
||||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
|
||||
"test-api": "node --conditions development test.js",
|
||||
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
|
||||
"test": "npm run build && npm run format && npm run test-coverage"
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
},
|
||||
"typeCoverage": {
|
||||
"atLeast": 100,
|
||||
"detail": true,
|
||||
"strict": true,
|
||||
"ignoreCatch": true
|
||||
}
|
||||
}
|
||||
158
node_modules/direction/readme.md
generated
vendored
Normal file
158
node_modules/direction/readme.md
generated
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
# direction
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
|
||||
Detect the direction of text: left-to-right, right-to-left, or neutral.
|
||||
|
||||
## Contents
|
||||
|
||||
* [What is this?](#what-is-this)
|
||||
* [When should I use this?](#when-should-i-use-this)
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`direction(value)`](#directionvalue)
|
||||
* [CLI](#cli)
|
||||
* [Types](#types)
|
||||
* [Compatibility](#compatibility)
|
||||
* [Security](#security)
|
||||
* [Contribute](#contribute)
|
||||
* [License](#license)
|
||||
|
||||
## What is this?
|
||||
|
||||
This package detects whether text is written left-to-right or right-to-left.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
This is a simple and fast algorithm.
|
||||
It looks at the first strong left-to-right or right-to-left character (for
|
||||
example, the letter `a` is LTR, the letter `ى` is RTL).
|
||||
That’s often enough but might be too naïve as it doesn’t take percentages or so
|
||||
into account.
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
|
||||
```sh
|
||||
npm install direction
|
||||
```
|
||||
|
||||
In Deno with [Skypack][]:
|
||||
|
||||
```js
|
||||
import {direction} from 'https://cdn.skypack.dev/direction@2?dts'
|
||||
```
|
||||
|
||||
In browsers with [Skypack][]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import {direction} from 'https://cdn.skypack.dev/direction@2?min'
|
||||
</script>
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
```js
|
||||
import {direction} from 'direction'
|
||||
|
||||
direction('A') // => 'ltr'
|
||||
direction('anglais') // => 'ltr'
|
||||
direction('بسيطة') // => 'rtl'
|
||||
direction('@') // => 'neutral'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
This package exports the following identifier: `direction`.
|
||||
There is no default export.
|
||||
|
||||
### `direction(value)`
|
||||
|
||||
Detect the direction of `value` (`string?`).
|
||||
Returns `'ltr'`, `'rtl'`, or `'neutral'`.
|
||||
|
||||
## CLI
|
||||
|
||||
```txt
|
||||
Usage: direction [options] <words...>
|
||||
|
||||
Detect the direction of text: left-to-right, right-to-left, or neutral
|
||||
|
||||
Options:
|
||||
|
||||
-h, --help output usage information
|
||||
-v, --version output version number
|
||||
|
||||
Usage:
|
||||
|
||||
# output directionality
|
||||
$ direction @
|
||||
# neutral
|
||||
|
||||
# output directionality from stdin
|
||||
$ echo 'الانجليزية' | direction
|
||||
# rtl
|
||||
```
|
||||
|
||||
## Types
|
||||
|
||||
This package is fully typed with [TypeScript][].
|
||||
There are no extra exported types.
|
||||
|
||||
## Compatibility
|
||||
|
||||
This package is at least compatible with all maintained versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
It also works in Deno and modern browsers.
|
||||
|
||||
## Security
|
||||
|
||||
This package is safe.
|
||||
|
||||
## Contribute
|
||||
|
||||
Yes please!
|
||||
See [How to Contribute to Open Source][contribute].
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[build-badge]: https://github.com/wooorm/direction/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/wooorm/direction/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/direction.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/wooorm/direction
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/direction.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/direction
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/direction.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=direction
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[skypack]: https://www.skypack.dev
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
||||
[contribute]: https://opensource.guide/how-to-contribute/
|
||||
Reference in New Issue
Block a user