This commit is contained in:
2025-05-12 05:38:44 +09:00
parent dced21c3f8
commit 6d78bfa46e
8120 changed files with 1161564 additions and 0 deletions

22
book/node_modules/direction/LICENSE generated vendored Normal file
View 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.

64
book/node_modules/direction/Readme.md generated vendored Normal file
View File

@ -0,0 +1,64 @@
# direction [![Build Status](https://img.shields.io/travis/wooorm/direction.svg?style=flat)](https://travis-ci.org/wooorm/direction) [![Coverage Status](https://img.shields.io/coveralls/wooorm/direction.svg?style=flat)](https://coveralls.io/r/wooorm/direction?branch=master)
Detect direction: left-to-right, right-to-left, or neutral.
## Installation
npm:
```bash
$ npm install direction
```
Component:
```bash
$ component install wooorm/direction
```
Bower:
```bash
$ bower install direction
```
## Usage
```js
var direction = require('direction');
direction("A"); // "ltr"
direction("anglais"); // "ltr"
direction("بسيطة"); // "rtl"
direction("@"); // "neutral"
```
## CLI
Install:
```bash
$ npm install direction --global
```
Usage:
```
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 direction of given values
$ direction @
# neutral
# output direction from stdin
$ echo "الانجليزية" | direction
# rtl
```
## License
MIT © [Titus Wormer](http://wooorm.com)

81
book/node_modules/direction/cli.js generated vendored Executable file
View File

@ -0,0 +1,81 @@
#!/usr/bin/env node
'use strict';
/*
* Dependencies.
*/
var direction,
pack;
direction = require('./');
pack = require('./package.json');
/*
* Arguments.
*/
var argv;
argv = process.argv.slice(2);
/*
* Command.
*/
var command;
command = Object.keys(pack.bin)[0];
/**
* Help.
*
* @return {string}
*/
function help() {
return [
'',
'Usage: ' + command + ' [options] words...',
'',
pack.description,
'',
'Options:',
'',
' -h, --help output usage information',
' -v, --version output version number',
'',
'Usage:',
'',
'# output direction of given values',
'$ ' + command + ' @',
'# neutral',
'',
'# output direction from stdin',
'$ echo "الانجليزية" | ' + command,
'# rtl'
].join('\n ') + '\n';
}
/*
* Program.
*/
if (
argv.indexOf('--help') === 0 ||
argv.indexOf('-h') === 0
) {
console.log(help());
} else if (
argv.indexOf('--version') === 0 ||
argv.indexOf('-v') === 0
) {
console.log(pack.version);
} else if (argv[0]) {
console.log(direction(argv.join(' ')));
} else {
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (data) {
console.log(direction(data.trim()));
});
}

71
book/node_modules/direction/index.js generated vendored Normal file
View File

@ -0,0 +1,71 @@
'use strict';
var GROUP_LEFT_TO_RIGHT,
GROUP_RIGHT_TO_LEFT,
EXPRESSION_LEFT_TO_RIGHT,
EXPRESSION_RIGHT_TO_LEFT;
/*
* Character ranges of left-to-right characters.
*/
GROUP_LEFT_TO_RIGHT = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6' +
'\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C' +
'\uFE00-\uFE6F\uFEFD-\uFFFF';
/*
* Character ranges of right-to-left characters.
*/
GROUP_RIGHT_TO_LEFT = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC';
/*
* Expression to match a left-to-right string.
*
* Matches the start of a string, followed by zero or
* more non-right-to-left characters, followed by a
* left-to-right character.
*/
EXPRESSION_LEFT_TO_RIGHT = new RegExp(
'^[^' + GROUP_RIGHT_TO_LEFT + ']*[' + GROUP_LEFT_TO_RIGHT + ']'
);
/*
* Expression to match a right-to-left string.
*
* Matches the start of a string, followed by zero or
* more non-left-to-right characters, followed by a
* right-to-left character.
*/
EXPRESSION_RIGHT_TO_LEFT = new RegExp(
'^[^' + GROUP_LEFT_TO_RIGHT + ']*[' + GROUP_RIGHT_TO_LEFT + ']'
);
/**
* Detect the direction of text.
*
* @param {string} value - value to stringify and check.
* @return {string} - One of `"rtl"`, `"ltr"`, or
* `"neutral"`.
*/
function direction(value) {
value = value.toString();
if (EXPRESSION_RIGHT_TO_LEFT.test(value)) {
return 'rtl';
}
if (EXPRESSION_LEFT_TO_RIGHT.test(value)) {
return 'ltr';
}
return 'neutral';
}
/*
* Expose `direction`.
*/
module.exports = direction;

45
book/node_modules/direction/package.json generated vendored Normal file
View File

@ -0,0 +1,45 @@
{
"name": "direction",
"version": "0.1.5",
"description": "Detect directionality: left-to-right, right-to-left, or neutral",
"license": "MIT",
"keywords": [
"writing",
"system",
"direction",
"directionality",
"rtl",
"ltr",
"cli",
"bin"
],
"repository": {
"type": "git",
"url": "https://github.com/wooorm/direction.git"
},
"author": "Titus Wormer <tituswormer@gmail.com>",
"bin": {
"direction": "cli.js"
},
"devDependencies": {
"eslint": "^0.10.0",
"istanbul": "^0.3.0",
"jscs": "^1.0.0",
"jscs-jsdoc": "^0.3.2",
"mocha": "^2.0.0"
},
"scripts": {
"test-lib": "_mocha --check-leaks test.js",
"test-cli": "bash ./test.sh",
"test-coveralls": "istanbul cover _mocha --report lcovonly -- --check-leaks test.js",
"test-travis": "npm run test-cli && npm run test-coveralls",
"test": "npm run test-lib && npm run test-cli",
"coverage": "istanbul cover _mocha -- -- test.js",
"lint-api": "eslint index.js",
"lint-cli": "eslint cli.js",
"lint-test": "eslint --env mocha test.js",
"lint-style": "jscs --reporter inline index.js cli.js test.js",
"lint": "npm run lint-api && npm run lint-cli && npm run lint-test && npm run lint-style",
"make": "npm run lint && npm run coverage"
}
}

70
book/node_modules/direction/test.sh generated vendored Executable file
View File

@ -0,0 +1,70 @@
#!/bin/sh
#!/bin/bash
typeset -i tests=0
function it {
let tests+=1;
description="$1";
}
function assert {
if [[ "$1" == "$2" ]]; then
printf "\033[32m.\033[0m";
else
printf "\033[31m\nFAIL: $description\033[0m: '$1' != '$2'\n";
exit 1
fi
}
it "Should accept a value"
result=`./cli.js "direction"` 2> /dev/null
assert $result "ltr"
it "Should accept a right-to-left value"
result=`./cli.js "لانجليزية"` 2> /dev/null
assert $result "rtl"
it "Should accept a neutral value"
result=`./cli.js "@!"` 2> /dev/null
assert $result "neutral"
it "Should accept multiple values"
result=`./cli.js "direction another"` 2> /dev/null
assert $result "ltr"
it "Should accept multiple arguments"
result=`./cli.js "direction" "another"` 2> /dev/null
assert $result "ltr"
it "Should accept a value over stdin"
result=`echo "direction" | ./cli.js` 2> /dev/null
assert $result "ltr"
it "Should accept multiple values over stdin"
result=`echo "direction another" | ./cli.js` 2> /dev/null
assert $result "ltr"
it "Should accept \`--help\`"
code=0
./cli.js --help > /dev/null 2>&1 || code=$?
assert $code 0
it "Should accept \`-h\`"
code=0
./cli.js -h > /dev/null 2>&1 || code=$?
assert $code 0
it "Should accept \`--version\`"
code=0
./cli.js --version > /dev/null 2>&1 || code=$?
assert $code 0
it "Should accept \`-v\`"
code=0
./cli.js -v > /dev/null 2>&1 || code=$?
assert $code 0
printf "\033[32m\n(✓) Passed $tests assertions without errors\033[0m\n";
exit 0