This commit is contained in:
46
node_modules/direction/cli.js
generated
vendored
Executable file
46
node_modules/direction/cli.js
generated
vendored
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict'
|
||||
|
||||
var pack = require('./package.json')
|
||||
var direction = require('.')
|
||||
|
||||
var argv = process.argv.slice(2)
|
||||
|
||||
if (argv.indexOf('--help') !== -1 || argv.indexOf('-h') !== -1) {
|
||||
console.log(help())
|
||||
} else if (argv.indexOf('--version') !== -1 || argv.indexOf('-v') !== -1) {
|
||||
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(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')
|
||||
}
|
||||
26
node_modules/direction/index.js
generated
vendored
Normal file
26
node_modules/direction/index.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = direction
|
||||
|
||||
var RTL = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC'
|
||||
var LTR =
|
||||
'A-Za-z\u00C0-\u00D6\u00D8-\u00F6' +
|
||||
'\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C' +
|
||||
'\uFE00-\uFE6F\uFEFD-\uFFFF'
|
||||
|
||||
var rtl = new RegExp('^[^' + LTR + ']*[' + RTL + ']')
|
||||
var ltr = new RegExp('^[^' + RTL + ']*[' + LTR + ']')
|
||||
|
||||
function direction(value) {
|
||||
value = String(value || '')
|
||||
|
||||
if (rtl.test(value)) {
|
||||
return 'rtl'
|
||||
}
|
||||
|
||||
if (ltr.test(value)) {
|
||||
return 'ltr'
|
||||
}
|
||||
|
||||
return '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.
|
||||
80
node_modules/direction/package.json
generated
vendored
Normal file
80
node_modules/direction/package.json
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"name": "direction",
|
||||
"version": "1.0.4",
|
||||
"description": "Detect directionality: 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)"
|
||||
],
|
||||
"bin": "cli.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"cli.js"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.0.0",
|
||||
"nyc": "^15.0.0",
|
||||
"prettier": "^1.0.0",
|
||||
"remark-cli": "^7.0.0",
|
||||
"remark-preset-wooorm": "^6.0.0",
|
||||
"tape": "^4.0.0",
|
||||
"tinyify": "^2.0.0",
|
||||
"xo": "^0.25.0"
|
||||
},
|
||||
"scripts": {
|
||||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
|
||||
"build-bundle": "browserify . -s direction -o direction.js",
|
||||
"build-mangle": "browserify . -s direction -p tinyify -o direction.min.js",
|
||||
"build": "npm run build-bundle && npm run build-mangle",
|
||||
"test-api": "node test",
|
||||
"test-coverage": "nyc --reporter lcov tape test.js",
|
||||
"test": "npm run format && npm run build && npm run test-coverage"
|
||||
},
|
||||
"nyc": {
|
||||
"check-coverage": true,
|
||||
"lines": 100,
|
||||
"functions": 100,
|
||||
"branches": 100
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"esnext": false,
|
||||
"rules": {
|
||||
"unicorn/prefer-includes": "off"
|
||||
},
|
||||
"ignores": [
|
||||
"direction.js"
|
||||
]
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
}
|
||||
}
|
||||
84
node_modules/direction/readme.md
generated
vendored
Normal file
84
node_modules/direction/readme.md
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
# direction
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
|
||||
Detect direction: left-to-right, right-to-left, or neutral.
|
||||
|
||||
## API
|
||||
|
||||
Install:
|
||||
|
||||
```sh
|
||||
npm install direction
|
||||
```
|
||||
|
||||
Use:
|
||||
|
||||
```js
|
||||
var direction = require('direction')
|
||||
|
||||
direction('A') // => 'ltr'
|
||||
direction('anglais') // => 'ltr'
|
||||
direction('بسيطة') // => 'rtl'
|
||||
direction('@') // => 'neutral'
|
||||
```
|
||||
|
||||
## CLI
|
||||
|
||||
Install:
|
||||
|
||||
```sh
|
||||
npm install -g direction
|
||||
```
|
||||
|
||||
Use:
|
||||
|
||||
```txt
|
||||
Usage: direction [options] <words...>
|
||||
|
||||
Detect directionality: 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
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[build-badge]: https://img.shields.io/travis/wooorm/direction.svg
|
||||
|
||||
[build]: https://travis-ci.org/wooorm/direction
|
||||
|
||||
[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
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
Reference in New Issue
Block a user