Showing
12 changed files
with
786 additions
and
4 deletions
Chess/node_modules/math/AUTHORS
0 → 100644
1 | +Kaleb Hornsby <kaleb@hornsby.ws> (kaleb.hornsby.ws) |
Chess/node_modules/math/Cakefile
0 → 100644
1 | +{exec, spawn} = require 'child_process' | ||
2 | +path = require 'path' | ||
3 | + | ||
4 | +repo = 'git' # or 'hg | ||
5 | + | ||
6 | +getVersion = -> spawn 'npm', ['--version'], (err, stdout, stderr) -> | ||
7 | + [err, stdout, stderr] | ||
8 | + | ||
9 | +task 'edit', 'Edit the Cakefile', (options) -> | ||
10 | + console.log 'Not implemented', options | ||
11 | + | ||
12 | +task 'version', 'Display the package version.', (options) -> | ||
13 | + exec 'npm --version', (error, stdout, stderr) -> | ||
14 | + version = stdout.split('.') | ||
15 | + console.log version[2] | ||
16 | + | ||
17 | +task 'ci', 'commit', (options) -> | ||
18 | + console.dir(options) | ||
19 | + exec "#{repo} commit", (error, stdout, stderr) -> | ||
20 | + console.log stdout | ||
21 | + | ||
22 | +task 'co', | ||
23 | + | ||
24 | +task 'push' | ||
25 | + | ||
26 | +task 'pull' | ||
27 | + | ||
28 | +option '-m', '--message', 'Message' |
Chess/node_modules/math/math.coffee
0 → 100644
1 | +module?.exports &&= Math | ||
2 | + | ||
3 | +###* | ||
4 | + * @return wheter a Number x, has the same sign as another Number, y. | ||
5 | + * @example | ||
6 | + * Math.samesign(1,2) | ||
7 | + * //-> true | ||
8 | + * Math.samesign(-3, 4) | ||
9 | + * //-> false | ||
10 | + * @test | ||
11 | + * Math.samesign(5, 6) | ||
12 | + * //-> false | ||
13 | + * Math.samesign(-7, -8) | ||
14 | + * //-> true | ||
15 | + ### | ||
16 | +Math.samesign = (x, y) -> (x >= 0) != (y < 0) | ||
17 | + | ||
18 | +###* | ||
19 | + * @return {Number} a copy of Number x with the same sign of Number y. | ||
20 | + * @example | ||
21 | + * Math.copysign(1, -2) | ||
22 | + * //-> -1 | ||
23 | + * @test | ||
24 | + * Math.copysign(-3, 4) | ||
25 | + * //-> 3 | ||
26 | + * Math.copysign(5, 6) | ||
27 | + * //-> 5 | ||
28 | + * Math.copysign(-7, -8) | ||
29 | + * //-> -7 | ||
30 | + ### | ||
31 | +Math.copysign = (x, y) -> if Math.samesign x, y then x else -x | ||
32 | + | ||
33 | +###* | ||
34 | + * @return {Number} sum of two Numbers. | ||
35 | + * @example | ||
36 | + * Math.add(1, 2) | ||
37 | + * //-> 3 | ||
38 | + * @test | ||
39 | + * Math.add('three', 4) | ||
40 | + * //-> NaN | ||
41 | + ### | ||
42 | +Math.add = (a, b) -> (+a) + (+b) | ||
43 | + | ||
44 | +###* | ||
45 | + * @return {Number} sum of an Array of Numbers. | ||
46 | + * @example | ||
47 | + * Math.sum([1, 2, 3]) | ||
48 | + * //-> 6 | ||
49 | + ### | ||
50 | +Math.sum = (nums) -> nums.reduce Math.add | ||
51 | + | ||
52 | +###* | ||
53 | + * @return {Number} product of two Numbers. | ||
54 | + * @example | ||
55 | + * Math.(2, 3) | ||
56 | + * //-> 6 | ||
57 | + ### | ||
58 | +Math.mul = (a, b) -> a * b | ||
59 | + | ||
60 | +###* | ||
61 | + * @return {Number} product of an Array of Numbers. | ||
62 | + * @example | ||
63 | + * Math.prod(2, 3, 4) | ||
64 | + * //-> 24 | ||
65 | + ### | ||
66 | +Math.prod = (nums) -> nums.reduce Math.mul | ||
67 | + | ||
68 | +###* | ||
69 | + * @return {Number} factorial of a Number. | ||
70 | + * @example | ||
71 | + * Math.factorial(4) | ||
72 | + * //-> 24 | ||
73 | + * @test | ||
74 | + * Math.factorial(3) | ||
75 | + * //-> 6 | ||
76 | + * Math.factorial(2) | ||
77 | + * //-> 2 | ||
78 | + * Math.factorial(1) | ||
79 | + * //-> 1 | ||
80 | + * Math.factorial(0) | ||
81 | + * //-> 1 | ||
82 | + * Math.factorial(-1) | ||
83 | + * //-> Infinity | ||
84 | + ### | ||
85 | +Math.factorial = (n) -> | ||
86 | + if n < 0 then Infinity | ||
87 | + else if n == 0 then 1 | ||
88 | + else Math.prod.apply null, [1..n] | ||
89 | + | ||
90 | +###* | ||
91 | + * Greatest Common Multipler | ||
92 | + * @return {Number} greatest common multipler of two Numbers. | ||
93 | + * @example | ||
94 | + * Math.gcd(493, 289) | ||
95 | + * //-> 17 | ||
96 | + * @test | ||
97 | + * Math.gcd(493, -289) | ||
98 | + * //-> 17 | ||
99 | + ### | ||
100 | +Math.gcd = (a, b) -> [a, b] = [b, a % b] while b; a | ||
101 | + | ||
102 | +###* | ||
103 | + * Least Common Multiplier | ||
104 | + * @return {Number} least common multiplier of two numbers. | ||
105 | + * @example | ||
106 | + * Math.lcm(4, 12) | ||
107 | + * //-> 12 | ||
108 | + * @test | ||
109 | + * Math.lcm(6, 7) | ||
110 | + * //-> 42 | ||
111 | + ### | ||
112 | +Math.lcm = (a, b) -> a / Math.gcd(a, b) * b |
Chess/node_modules/math/math.js
0 → 100644
1 | +(function() { | ||
2 | + if (typeof module !== "undefined" && module !== null) { | ||
3 | + module.exports && (module.exports = Math); | ||
4 | + } | ||
5 | + /** | ||
6 | + * @return wheter a Number x, has the same sign as another Number, y. | ||
7 | + * @example | ||
8 | + * Math.samesign(1,2) | ||
9 | + * //-> true | ||
10 | + * Math.samesign(-3, 4) | ||
11 | + * //-> false | ||
12 | + * @test | ||
13 | + * Math.samesign(5, 6) | ||
14 | + * //-> false | ||
15 | + * Math.samesign(-7, -8) | ||
16 | + * //-> true | ||
17 | + */ | ||
18 | + Math.samesign = function(x, y) { | ||
19 | + return (x >= 0) !== (y < 0); | ||
20 | + }; | ||
21 | + /** | ||
22 | + * @return {Number} a copy of Number x with the same sign of Number y. | ||
23 | + * @example | ||
24 | + * Math.copysign(1, -2) | ||
25 | + * //-> -1 | ||
26 | + * @test | ||
27 | + * Math.copysign(-3, 4) | ||
28 | + * //-> 3 | ||
29 | + * Math.copysign(5, 6) | ||
30 | + * //-> 5 | ||
31 | + * Math.copysign(-7, -8) | ||
32 | + * //-> -7 | ||
33 | + */ | ||
34 | + Math.copysign = function(x, y) { | ||
35 | + if (Math.samesign(x, y)) { | ||
36 | + return x; | ||
37 | + } else { | ||
38 | + return -x; | ||
39 | + } | ||
40 | + }; | ||
41 | + /** | ||
42 | + * @return {Number} sum of two Numbers. | ||
43 | + * @example | ||
44 | + * Math.add(1, 2) | ||
45 | + * //-> 3 | ||
46 | + * @test | ||
47 | + * Math.add('three', 4) | ||
48 | + * //-> NaN | ||
49 | + */ | ||
50 | + Math.add = function(a, b) { | ||
51 | + return (+a) + (+b); | ||
52 | + }; | ||
53 | + /** | ||
54 | + * @return {Number} sum of an Array of Numbers. | ||
55 | + * @example | ||
56 | + * Math.sum([1, 2, 3]) | ||
57 | + * //-> 6 | ||
58 | + */ | ||
59 | + Math.sum = function(nums) { | ||
60 | + return nums.reduce(Math.add); | ||
61 | + }; | ||
62 | + /** | ||
63 | + * @return {Number} product of two Numbers. | ||
64 | + * @example | ||
65 | + * Math.(2, 3) | ||
66 | + * //-> 6 | ||
67 | + */ | ||
68 | + Math.mul = function(a, b) { | ||
69 | + return a * b; | ||
70 | + }; | ||
71 | + /** | ||
72 | + * @return {Number} product of an Array of Numbers. | ||
73 | + * @example | ||
74 | + * Math.prod(2, 3, 4) | ||
75 | + * //-> 24 | ||
76 | + */ | ||
77 | + Math.prod = function(nums) { | ||
78 | + return nums.reduce(Math.mul); | ||
79 | + }; | ||
80 | + /** | ||
81 | + * @return {Number} factorial of a Number. | ||
82 | + * @example | ||
83 | + * Math.factorial(4) | ||
84 | + * //-> 24 | ||
85 | + * @test | ||
86 | + * Math.factorial(3) | ||
87 | + * //-> 6 | ||
88 | + * Math.factorial(2) | ||
89 | + * //-> 2 | ||
90 | + * Math.factorial(1) | ||
91 | + * //-> 1 | ||
92 | + * Math.factorial(0) | ||
93 | + * //-> 1 | ||
94 | + * Math.factorial(-1) | ||
95 | + * //-> Infinity | ||
96 | + */ | ||
97 | + Math.factorial = function(n) { | ||
98 | + var _i, _results; | ||
99 | + if (n < 0) { | ||
100 | + return Infinity; | ||
101 | + } else if (n === 0) { | ||
102 | + return 1; | ||
103 | + } else { | ||
104 | + return Math.prod.apply(null, (function() { | ||
105 | + _results = []; | ||
106 | + for (var _i = 1; 1 <= n ? _i <= n : _i >= n; 1 <= n ? _i++ : _i--){ _results.push(_i); } | ||
107 | + return _results; | ||
108 | + }).apply(this, arguments)); | ||
109 | + } | ||
110 | + }; | ||
111 | + /** | ||
112 | + * Greatest Common Multipler | ||
113 | + * @return {Number} greatest common multipler of two Numbers. | ||
114 | + * @example | ||
115 | + * Math.gcd(493, 289) | ||
116 | + * //-> 17 | ||
117 | + * @test | ||
118 | + * Math.gcd(493, -289) | ||
119 | + * //-> 17 | ||
120 | + */ | ||
121 | + Math.gcd = function(a, b) { | ||
122 | + var _ref; | ||
123 | + while (b) { | ||
124 | + _ref = [b, a % b], a = _ref[0], b = _ref[1]; | ||
125 | + } | ||
126 | + return a; | ||
127 | + }; | ||
128 | + /** | ||
129 | + * Least Common Multiplier | ||
130 | + * @return {Number} least common multiplier of two numbers. | ||
131 | + * @example | ||
132 | + * Math.lcm(4, 12) | ||
133 | + * //-> 12 | ||
134 | + * @test | ||
135 | + * Math.lcm(6, 7) | ||
136 | + * //-> 42 | ||
137 | + */ | ||
138 | + Math.lcm = function(a, b) { | ||
139 | + return a / Math.gcd(a, b) * b; | ||
140 | + }; | ||
141 | +}).call(this); |
Chess/node_modules/math/package.json
0 → 100644
1 | +{ | ||
2 | + "_from": "math", | ||
3 | + "_id": "math@0.0.3", | ||
4 | + "_inBundle": false, | ||
5 | + "_integrity": "sha1-hbAg/VTOELJqvqv81+H0vbxGRw8=", | ||
6 | + "_location": "/math", | ||
7 | + "_phantomChildren": {}, | ||
8 | + "_requested": { | ||
9 | + "type": "tag", | ||
10 | + "registry": true, | ||
11 | + "raw": "math", | ||
12 | + "name": "math", | ||
13 | + "escapedName": "math", | ||
14 | + "rawSpec": "", | ||
15 | + "saveSpec": null, | ||
16 | + "fetchSpec": "latest" | ||
17 | + }, | ||
18 | + "_requiredBy": [ | ||
19 | + "#USER", | ||
20 | + "/" | ||
21 | + ], | ||
22 | + "_resolved": "https://registry.npmjs.org/math/-/math-0.0.3.tgz", | ||
23 | + "_shasum": "85b020fd54ce10b26abeabfcd7e1f4bdbc46470f", | ||
24 | + "_spec": "math", | ||
25 | + "_where": "C:\\Users\\tlsgml8847\\Documents\\oss\\Project\\OSS_project\\Chess", | ||
26 | + "author": { | ||
27 | + "name": "Kaleb Hornsby", | ||
28 | + "email": "kaleb@hornsby.ws", | ||
29 | + "url": "kaleb.hornsby.ws" | ||
30 | + }, | ||
31 | + "bugs": { | ||
32 | + "url": "https://github.com/kaleb/js-math/issues" | ||
33 | + }, | ||
34 | + "bundleDependencies": false, | ||
35 | + "contributors": [ | ||
36 | + { | ||
37 | + "name": "Kaleb Hornsby", | ||
38 | + "email": "kaleb@hornsby.ws", | ||
39 | + "url": "kaleb.hornsby.ws" | ||
40 | + } | ||
41 | + ], | ||
42 | + "dependencies": {}, | ||
43 | + "deprecated": false, | ||
44 | + "description": "Mathematical Functions", | ||
45 | + "devDependencies": {}, | ||
46 | + "engines": { | ||
47 | + "node": "> 0.0.0" | ||
48 | + }, | ||
49 | + "homepage": "http://kaleb.hornsby.ws/js-math", | ||
50 | + "main": "math.js", | ||
51 | + "name": "math", | ||
52 | + "repository": { | ||
53 | + "type": "git", | ||
54 | + "url": "git://github.com/kaleb/js-math.git" | ||
55 | + }, | ||
56 | + "version": "0.0.3" | ||
57 | +} |
Chess/node_modules/urlencode/History.md
0 → 100644
1 | + | ||
2 | +1.1.0 / 2015-08-14 | ||
3 | +================== | ||
4 | + | ||
5 | + * fix typo | ||
6 | + * feat: Support IE8 | ||
7 | + | ||
8 | +1.0.1 / 2015-07-06 | ||
9 | +================== | ||
10 | + | ||
11 | + * refactor: add \n to benchmark | ||
12 | + * fix '\n' encoding | ||
13 | + | ||
14 | +1.0.0 / 2015-04-04 | ||
15 | +================== | ||
16 | + | ||
17 | + * deps: upgrade iconv-lite to 0.4.7 | ||
18 | + | ||
19 | +0.2.0 / 2014-04-25 | ||
20 | +================== | ||
21 | + | ||
22 | + * urlencode.stringify done (@alsotang) | ||
23 | + | ||
24 | +0.1.2 / 2014-04-09 | ||
25 | +================== | ||
26 | + | ||
27 | + * remove unused variable QueryString (@azbykov) | ||
28 | + | ||
29 | +0.1.1 / 2014-02-25 | ||
30 | +================== | ||
31 | + | ||
32 | + * improve parse() performance 10x | ||
33 | + | ||
34 | +0.1.0 / 2014-02-24 | ||
35 | +================== | ||
36 | + | ||
37 | + * decode with charset | ||
38 | + * add npm image | ||
39 | + * remove 0.6 for travis | ||
40 | + * update to support coveralls | ||
41 | + * use jscover instead of jscoverage | ||
42 | + * update gitignore | ||
43 | + * Merge pull request #1 from aleafs/master | ||
44 | + * Add http entries test case | ||
45 | + | ||
46 | +0.0.1 / 2012-10-31 | ||
47 | +================== | ||
48 | + | ||
49 | + * encode() done. add benchmark and tests | ||
50 | + * Initial commit |
Chess/node_modules/urlencode/LICENSE.txt
0 → 100644
1 | +This software is licensed under the MIT License. | ||
2 | + | ||
3 | +Copyright (C) 2012 - 2014 fengmk2 <fengmk2@gmail.com> | ||
4 | +Copyright (C) 2015 node-modules | ||
5 | + | ||
6 | +Permission is hereby granted, free of charge, to any person obtaining a copy | ||
7 | +of this software and associated documentation files (the "Software"), to deal | ||
8 | +in the Software without restriction, including without limitation the rights | ||
9 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
10 | +copies of the Software, and to permit persons to whom the Software is | ||
11 | +furnished to do so, subject to the following conditions: | ||
12 | + | ||
13 | +The above copyright notice and this permission notice shall be included in | ||
14 | +all copies or substantial portions of the Software. | ||
15 | + | ||
16 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
17 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
18 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
19 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
20 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
21 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
22 | +THE SOFTWARE. |
Chess/node_modules/urlencode/README.md
0 → 100644
1 | +urlencode [](http://travis-ci.org/node-modules/urlencode) [](https://coveralls.io/r/node-modules/urlencode) | ||
2 | +======= | ||
3 | + | ||
4 | +[](https://nodei.co/npm/urlencode/) | ||
5 | + | ||
6 | +encodeURIComponent with charset, e.g.: `gbk` | ||
7 | + | ||
8 | +## Install | ||
9 | + | ||
10 | +```bash | ||
11 | +$ npm install urlencode | ||
12 | +``` | ||
13 | + | ||
14 | +## Usage | ||
15 | + | ||
16 | +```js | ||
17 | +var urlencode = require('urlencode'); | ||
18 | + | ||
19 | +console.log(urlencode('苏千')); // default is utf8 | ||
20 | +console.log(urlencode('苏千', 'gbk')); // '%CB%D5%C7%A7' | ||
21 | + | ||
22 | +// decode gbk | ||
23 | +urlencode.decode('%CB%D5%C7%A7', 'gbk'); // '苏千' | ||
24 | + | ||
25 | +// parse gbk querystring | ||
26 | +urlencode.parse('nick=%CB%D5%C7%A7', {charset: 'gbk'}); // {nick: '苏千'} | ||
27 | + | ||
28 | +// stringify obj with gbk encoding | ||
29 | +var str = 'x[y][0][v][w]=' + urlencode('雾空', 'gbk'); // x[y][0][v][w]=%CE%ED%BF%D5 | ||
30 | +var obj = {'x' : {'y' : [{'v' : {'w' : '雾空'}}]}}; | ||
31 | +urlencode.stringify(obj, {charset: 'gbk'}).should.equal(str); | ||
32 | + | ||
33 | +``` | ||
34 | + | ||
35 | +## Benchmark | ||
36 | + | ||
37 | +### urlencode(str, encoding) | ||
38 | + | ||
39 | +```bash | ||
40 | +$ node benchmark/urlencode.js | ||
41 | + | ||
42 | +node version: v0.10.26 | ||
43 | +urlencode(str) x 11,980 ops/sec ±1.13% (100 runs sampled) | ||
44 | +urlencode(str, "gbk") x 8,575 ops/sec ±1.58% (94 runs sampled) | ||
45 | +encodeURIComponent(str) x 11,677 ops/sec ±2.32% (93 runs sampled) | ||
46 | +Fastest is urlencode(str) | ||
47 | +``` | ||
48 | + | ||
49 | +### urlencode.decode(str, encoding) | ||
50 | + | ||
51 | +```bash | ||
52 | +$ node benchmark/urlencode.decode.js | ||
53 | + | ||
54 | +node version: v0.10.26 | ||
55 | +urlencode.decode(str) x 26,027 ops/sec ±7.51% (73 runs sampled) | ||
56 | +urlencode.decode(str, "gbk") x 14,409 ops/sec ±1.72% (98 runs sampled) | ||
57 | +decodeURIComponent(str) x 36,052 ops/sec ±0.90% (96 runs sampled) | ||
58 | +urlencode.parse(qs, {charset: "gbk"}) x 16,401 ops/sec ±1.09% (98 runs sampled) | ||
59 | +urlencode.parse(qs, {charset: "utf8"}) x 23,381 ops/sec ±2.22% (93 runs sampled) | ||
60 | +Fastest is decodeURIComponent(str) | ||
61 | +``` | ||
62 | + | ||
63 | +## TODO | ||
64 | + | ||
65 | +* [x] stringify() | ||
66 | + | ||
67 | +## License | ||
68 | + | ||
69 | +[MIT](LICENSE.txt) |
1 | +/**! | ||
2 | + * urlencode - lib/urlencode.js | ||
3 | + * | ||
4 | + * MIT Licensed | ||
5 | + * | ||
6 | + * Authors: | ||
7 | + * fengmk2 <fengmk2@gmail.com> (http://fengmk2.com) | ||
8 | + */ | ||
9 | + | ||
10 | +"use strict"; | ||
11 | + | ||
12 | +/** | ||
13 | + * Module dependencies. | ||
14 | + */ | ||
15 | + | ||
16 | +var iconv = require('iconv-lite'); | ||
17 | + | ||
18 | +function isUTF8(charset) { | ||
19 | + if (!charset) { | ||
20 | + return true; | ||
21 | + } | ||
22 | + charset = charset.toLowerCase(); | ||
23 | + return charset === 'utf8' || charset === 'utf-8'; | ||
24 | +} | ||
25 | + | ||
26 | +function encode(str, charset) { | ||
27 | + if (isUTF8(charset)) { | ||
28 | + return encodeURIComponent(str); | ||
29 | + } | ||
30 | + | ||
31 | + var buf = iconv.encode(str, charset); | ||
32 | + var encodeStr = ''; | ||
33 | + var ch = ''; | ||
34 | + for (var i = 0; i < buf.length; i++) { | ||
35 | + ch = buf[i].toString('16'); | ||
36 | + if (ch.length === 1) { | ||
37 | + ch = '0' + ch; | ||
38 | + } | ||
39 | + encodeStr += '%' + ch; | ||
40 | + } | ||
41 | + encodeStr = encodeStr.toUpperCase(); | ||
42 | + return encodeStr; | ||
43 | +} | ||
44 | + | ||
45 | +function decode(str, charset) { | ||
46 | + if (isUTF8(charset)) { | ||
47 | + return decodeURIComponent(str); | ||
48 | + } | ||
49 | + | ||
50 | + var bytes = []; | ||
51 | + for (var i = 0; i < str.length; ) { | ||
52 | + if (str[i] === '%') { | ||
53 | + i++; | ||
54 | + bytes.push(parseInt(str.substring(i, i + 2), 16)); | ||
55 | + i += 2; | ||
56 | + } else { | ||
57 | + bytes.push(str.charCodeAt(i)); | ||
58 | + i++; | ||
59 | + } | ||
60 | + } | ||
61 | + var buf = new Buffer(bytes); | ||
62 | + return iconv.decode(buf, charset); | ||
63 | +} | ||
64 | + | ||
65 | +function parse(qs, sep, eq, options) { | ||
66 | + if (typeof sep === 'object') { | ||
67 | + // parse(qs, options) | ||
68 | + options = sep; | ||
69 | + sep = null; | ||
70 | + } | ||
71 | + | ||
72 | + sep = sep || '&'; | ||
73 | + eq = eq || '='; | ||
74 | + var obj = {}; | ||
75 | + | ||
76 | + if (typeof qs !== 'string' || qs.length === 0) { | ||
77 | + return obj; | ||
78 | + } | ||
79 | + | ||
80 | + var regexp = /\+/g; | ||
81 | + qs = qs.split(sep); | ||
82 | + | ||
83 | + var maxKeys = 1000; | ||
84 | + var charset = null; | ||
85 | + if (options) { | ||
86 | + if (typeof options.maxKeys === 'number') { | ||
87 | + maxKeys = options.maxKeys; | ||
88 | + } | ||
89 | + if (typeof options.charset === 'string') { | ||
90 | + charset = options.charset; | ||
91 | + } | ||
92 | + } | ||
93 | + | ||
94 | + var len = qs.length; | ||
95 | + // maxKeys <= 0 means that we should not limit keys count | ||
96 | + if (maxKeys > 0 && len > maxKeys) { | ||
97 | + len = maxKeys; | ||
98 | + } | ||
99 | + | ||
100 | + for (var i = 0; i < len; ++i) { | ||
101 | + var x = qs[i].replace(regexp, '%20'); | ||
102 | + var idx = x.indexOf(eq); | ||
103 | + var kstr, vstr, k, v; | ||
104 | + | ||
105 | + if (idx >= 0) { | ||
106 | + kstr = x.substr(0, idx); | ||
107 | + vstr = x.substr(idx + 1); | ||
108 | + } else { | ||
109 | + kstr = x; | ||
110 | + vstr = ''; | ||
111 | + } | ||
112 | + | ||
113 | + if (kstr && kstr.indexOf('%') >= 0) { | ||
114 | + try { | ||
115 | + k = decode(kstr, charset); | ||
116 | + } catch (e) { | ||
117 | + k = kstr; | ||
118 | + } | ||
119 | + } else { | ||
120 | + k = kstr; | ||
121 | + } | ||
122 | + | ||
123 | + if (vstr && vstr.indexOf('%') >= 0) { | ||
124 | + try { | ||
125 | + v = decode(vstr, charset); | ||
126 | + } catch (e) { | ||
127 | + v = vstr; | ||
128 | + } | ||
129 | + } else { | ||
130 | + v = vstr; | ||
131 | + } | ||
132 | + | ||
133 | + if (!has(obj, k)) { | ||
134 | + obj[k] = v; | ||
135 | + } else if (Array.isArray(obj[k])) { | ||
136 | + obj[k].push(v); | ||
137 | + } else { | ||
138 | + obj[k] = [obj[k], v]; | ||
139 | + } | ||
140 | + } | ||
141 | + | ||
142 | + return obj; | ||
143 | +} | ||
144 | + | ||
145 | +function has(obj, prop) { | ||
146 | + return Object.prototype.hasOwnProperty.call(obj, prop); | ||
147 | +} | ||
148 | + | ||
149 | +function isASCII(str) { | ||
150 | + return (/^[\x00-\x7F]*$/).test(str); | ||
151 | +} | ||
152 | + | ||
153 | +function encodeComponent(item, charset) { | ||
154 | + item = String(item); | ||
155 | + if (isASCII(item)) { | ||
156 | + item = encodeURIComponent(item); | ||
157 | + } else { | ||
158 | + item = encode(item, charset); | ||
159 | + } | ||
160 | + return item; | ||
161 | +} | ||
162 | + | ||
163 | +var stringify = function(obj, prefix, options) { | ||
164 | + if (typeof prefix !== 'string') { | ||
165 | + options = prefix || {}; | ||
166 | + prefix = null; | ||
167 | + } | ||
168 | + var charset = options.charset || 'utf-8'; | ||
169 | + if (Array.isArray(obj)) { | ||
170 | + return stringifyArray(obj, prefix, options); | ||
171 | + } else if ('[object Object]' === {}.toString.call(obj)) { | ||
172 | + return stringifyObject(obj, prefix, options); | ||
173 | + } else if ('string' === typeof obj) { | ||
174 | + return stringifyString(obj, prefix, options); | ||
175 | + } else { | ||
176 | + return prefix + '=' + encodeComponent(String(obj), charset); | ||
177 | + } | ||
178 | +}; | ||
179 | + | ||
180 | +function stringifyString(str, prefix, options) { | ||
181 | + if (!prefix) { | ||
182 | + throw new TypeError('stringify expects an object'); | ||
183 | + } | ||
184 | + var charset = options.charset; | ||
185 | + return prefix + '=' + encodeComponent(str, charset); | ||
186 | +} | ||
187 | + | ||
188 | +function stringifyArray(arr, prefix, options) { | ||
189 | + var ret = []; | ||
190 | + if (!prefix) { | ||
191 | + throw new TypeError('stringify expects an object'); | ||
192 | + } | ||
193 | + for (var i = 0; i < arr.length; i++) { | ||
194 | + ret.push(stringify(arr[i], prefix + '[' + i + ']', options)); | ||
195 | + } | ||
196 | + return ret.join('&'); | ||
197 | +} | ||
198 | + | ||
199 | +function stringifyObject(obj, prefix, options) { | ||
200 | + var ret = []; | ||
201 | + var keys = Object.keys(obj); | ||
202 | + var key; | ||
203 | + | ||
204 | + var charset = options.charset; | ||
205 | + for (var i = 0, len = keys.length; i < len; ++i) { | ||
206 | + key = keys[i]; | ||
207 | + if ('' === key) { | ||
208 | + continue; | ||
209 | + } | ||
210 | + if (null === obj[key]) { | ||
211 | + ret.push(encode(key, charset) + '='); | ||
212 | + } else { | ||
213 | + ret.push(stringify( | ||
214 | + obj[key], | ||
215 | + prefix ? prefix + '[' + encodeComponent(key, charset) + ']': encodeComponent(key, charset), | ||
216 | + options)); | ||
217 | + } | ||
218 | + } | ||
219 | + | ||
220 | + return ret.join('&'); | ||
221 | +} | ||
222 | + | ||
223 | +module.exports = encode; | ||
224 | +module.exports.encode = encode; | ||
225 | +module.exports.decode = decode; | ||
226 | +module.exports.parse = parse; | ||
227 | +module.exports.stringify = stringify; |
Chess/node_modules/urlencode/package.json
0 → 100644
1 | +{ | ||
2 | + "_from": "urlencode", | ||
3 | + "_id": "urlencode@1.1.0", | ||
4 | + "_inBundle": false, | ||
5 | + "_integrity": "sha1-HyuibwE8hfATP3o61v8nMK33y7c=", | ||
6 | + "_location": "/urlencode", | ||
7 | + "_phantomChildren": {}, | ||
8 | + "_requested": { | ||
9 | + "type": "tag", | ||
10 | + "registry": true, | ||
11 | + "raw": "urlencode", | ||
12 | + "name": "urlencode", | ||
13 | + "escapedName": "urlencode", | ||
14 | + "rawSpec": "", | ||
15 | + "saveSpec": null, | ||
16 | + "fetchSpec": "latest" | ||
17 | + }, | ||
18 | + "_requiredBy": [ | ||
19 | + "#USER", | ||
20 | + "/" | ||
21 | + ], | ||
22 | + "_resolved": "https://registry.npmjs.org/urlencode/-/urlencode-1.1.0.tgz", | ||
23 | + "_shasum": "1f2ba26f013c85f0133f7a3ad6ff2730adf7cbb7", | ||
24 | + "_spec": "urlencode", | ||
25 | + "_where": "C:\\Users\\tlsgml8847\\Documents\\oss\\Project\\OSS_project\\Chess", | ||
26 | + "author": { | ||
27 | + "name": "fengmk2", | ||
28 | + "email": "fengmk2@gmail.com" | ||
29 | + }, | ||
30 | + "bugs": { | ||
31 | + "url": "https://github.com/node-modules/urlencode/issues" | ||
32 | + }, | ||
33 | + "bundleDependencies": false, | ||
34 | + "dependencies": { | ||
35 | + "iconv-lite": "~0.4.11" | ||
36 | + }, | ||
37 | + "deprecated": false, | ||
38 | + "description": "encodeURIComponent with charset", | ||
39 | + "devDependencies": { | ||
40 | + "autod": "*", | ||
41 | + "beautify-benchmark": "*", | ||
42 | + "benchmark": "*", | ||
43 | + "blanket": "*", | ||
44 | + "contributors": "*", | ||
45 | + "istanbul": "~0.3.17", | ||
46 | + "jshint": "*", | ||
47 | + "mocha": "*", | ||
48 | + "should": "7" | ||
49 | + }, | ||
50 | + "files": [ | ||
51 | + "lib" | ||
52 | + ], | ||
53 | + "homepage": "https://github.com/node-modules/urlencode", | ||
54 | + "keywords": [ | ||
55 | + "urlencode", | ||
56 | + "urldecode", | ||
57 | + "encodeURIComponent", | ||
58 | + "decodeURIComponent", | ||
59 | + "querystring", | ||
60 | + "parse" | ||
61 | + ], | ||
62 | + "license": "MIT", | ||
63 | + "main": "lib/urlencode.js", | ||
64 | + "name": "urlencode", | ||
65 | + "repository": { | ||
66 | + "type": "git", | ||
67 | + "url": "git://github.com/node-modules/urlencode.git" | ||
68 | + }, | ||
69 | + "scripts": { | ||
70 | + "autod": "autod -w --prefix '~' -t test -e examples", | ||
71 | + "benchmark": "node benchmark/urlencode.js && node benchmark/urlencode.decode.js", | ||
72 | + "cnpm": "npm install --registry=https://registry.npm.taobao.org", | ||
73 | + "jshint": "jshint .", | ||
74 | + "test": "mocha -R spec -t 20000 -r should test/*.test.js", | ||
75 | + "test-cov": "istanbul cover node_modules/.bin/_mocha -- -t 20000 -r should test/*.test.js", | ||
76 | + "test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- -t 20000 -r should test/*.test.js" | ||
77 | + }, | ||
78 | + "version": "1.1.0" | ||
79 | +} |
Chess/public/giphy.gif
0 → 100644

33.6 KB
Chess/router/main.js
deleted
100644 → 0
-
Please register or login to post a comment