양신희

메인 image 추가

Kaleb Hornsby <kaleb@hornsby.ws> (kaleb.hornsby.ws)
{exec, spawn} = require 'child_process'
path = require 'path'
repo = 'git' # or 'hg
getVersion = -> spawn 'npm', ['--version'], (err, stdout, stderr) ->
[err, stdout, stderr]
task 'edit', 'Edit the Cakefile', (options) ->
console.log 'Not implemented', options
task 'version', 'Display the package version.', (options) ->
exec 'npm --version', (error, stdout, stderr) ->
version = stdout.split('.')
console.log version[2]
task 'ci', 'commit', (options) ->
console.dir(options)
exec "#{repo} commit", (error, stdout, stderr) ->
console.log stdout
task 'co',
task 'push'
task 'pull'
option '-m', '--message', 'Message'
module?.exports &&= Math
###*
* @return wheter a Number x, has the same sign as another Number, y.
* @example
* Math.samesign(1,2)
* //-> true
* Math.samesign(-3, 4)
* //-> false
* @test
* Math.samesign(5, 6)
* //-> false
* Math.samesign(-7, -8)
* //-> true
###
Math.samesign = (x, y) -> (x >= 0) != (y < 0)
###*
* @return {Number} a copy of Number x with the same sign of Number y.
* @example
* Math.copysign(1, -2)
* //-> -1
* @test
* Math.copysign(-3, 4)
* //-> 3
* Math.copysign(5, 6)
* //-> 5
* Math.copysign(-7, -8)
* //-> -7
###
Math.copysign = (x, y) -> if Math.samesign x, y then x else -x
###*
* @return {Number} sum of two Numbers.
* @example
* Math.add(1, 2)
* //-> 3
* @test
* Math.add('three', 4)
* //-> NaN
###
Math.add = (a, b) -> (+a) + (+b)
###*
* @return {Number} sum of an Array of Numbers.
* @example
* Math.sum([1, 2, 3])
* //-> 6
###
Math.sum = (nums) -> nums.reduce Math.add
###*
* @return {Number} product of two Numbers.
* @example
* Math.(2, 3)
* //-> 6
###
Math.mul = (a, b) -> a * b
###*
* @return {Number} product of an Array of Numbers.
* @example
* Math.prod(2, 3, 4)
* //-> 24
###
Math.prod = (nums) -> nums.reduce Math.mul
###*
* @return {Number} factorial of a Number.
* @example
* Math.factorial(4)
* //-> 24
* @test
* Math.factorial(3)
* //-> 6
* Math.factorial(2)
* //-> 2
* Math.factorial(1)
* //-> 1
* Math.factorial(0)
* //-> 1
* Math.factorial(-1)
* //-> Infinity
###
Math.factorial = (n) ->
if n < 0 then Infinity
else if n == 0 then 1
else Math.prod.apply null, [1..n]
###*
* Greatest Common Multipler
* @return {Number} greatest common multipler of two Numbers.
* @example
* Math.gcd(493, 289)
* //-> 17
* @test
* Math.gcd(493, -289)
* //-> 17
###
Math.gcd = (a, b) -> [a, b] = [b, a % b] while b; a
###*
* Least Common Multiplier
* @return {Number} least common multiplier of two numbers.
* @example
* Math.lcm(4, 12)
* //-> 12
* @test
* Math.lcm(6, 7)
* //-> 42
###
Math.lcm = (a, b) -> a / Math.gcd(a, b) * b
(function() {
if (typeof module !== "undefined" && module !== null) {
module.exports && (module.exports = Math);
}
/**
* @return wheter a Number x, has the same sign as another Number, y.
* @example
* Math.samesign(1,2)
* //-> true
* Math.samesign(-3, 4)
* //-> false
* @test
* Math.samesign(5, 6)
* //-> false
* Math.samesign(-7, -8)
* //-> true
*/
Math.samesign = function(x, y) {
return (x >= 0) !== (y < 0);
};
/**
* @return {Number} a copy of Number x with the same sign of Number y.
* @example
* Math.copysign(1, -2)
* //-> -1
* @test
* Math.copysign(-3, 4)
* //-> 3
* Math.copysign(5, 6)
* //-> 5
* Math.copysign(-7, -8)
* //-> -7
*/
Math.copysign = function(x, y) {
if (Math.samesign(x, y)) {
return x;
} else {
return -x;
}
};
/**
* @return {Number} sum of two Numbers.
* @example
* Math.add(1, 2)
* //-> 3
* @test
* Math.add('three', 4)
* //-> NaN
*/
Math.add = function(a, b) {
return (+a) + (+b);
};
/**
* @return {Number} sum of an Array of Numbers.
* @example
* Math.sum([1, 2, 3])
* //-> 6
*/
Math.sum = function(nums) {
return nums.reduce(Math.add);
};
/**
* @return {Number} product of two Numbers.
* @example
* Math.(2, 3)
* //-> 6
*/
Math.mul = function(a, b) {
return a * b;
};
/**
* @return {Number} product of an Array of Numbers.
* @example
* Math.prod(2, 3, 4)
* //-> 24
*/
Math.prod = function(nums) {
return nums.reduce(Math.mul);
};
/**
* @return {Number} factorial of a Number.
* @example
* Math.factorial(4)
* //-> 24
* @test
* Math.factorial(3)
* //-> 6
* Math.factorial(2)
* //-> 2
* Math.factorial(1)
* //-> 1
* Math.factorial(0)
* //-> 1
* Math.factorial(-1)
* //-> Infinity
*/
Math.factorial = function(n) {
var _i, _results;
if (n < 0) {
return Infinity;
} else if (n === 0) {
return 1;
} else {
return Math.prod.apply(null, (function() {
_results = [];
for (var _i = 1; 1 <= n ? _i <= n : _i >= n; 1 <= n ? _i++ : _i--){ _results.push(_i); }
return _results;
}).apply(this, arguments));
}
};
/**
* Greatest Common Multipler
* @return {Number} greatest common multipler of two Numbers.
* @example
* Math.gcd(493, 289)
* //-> 17
* @test
* Math.gcd(493, -289)
* //-> 17
*/
Math.gcd = function(a, b) {
var _ref;
while (b) {
_ref = [b, a % b], a = _ref[0], b = _ref[1];
}
return a;
};
/**
* Least Common Multiplier
* @return {Number} least common multiplier of two numbers.
* @example
* Math.lcm(4, 12)
* //-> 12
* @test
* Math.lcm(6, 7)
* //-> 42
*/
Math.lcm = function(a, b) {
return a / Math.gcd(a, b) * b;
};
}).call(this);
{
"_from": "math",
"_id": "math@0.0.3",
"_inBundle": false,
"_integrity": "sha1-hbAg/VTOELJqvqv81+H0vbxGRw8=",
"_location": "/math",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "math",
"name": "math",
"escapedName": "math",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/math/-/math-0.0.3.tgz",
"_shasum": "85b020fd54ce10b26abeabfcd7e1f4bdbc46470f",
"_spec": "math",
"_where": "C:\\Users\\tlsgml8847\\Documents\\oss\\Project\\OSS_project\\Chess",
"author": {
"name": "Kaleb Hornsby",
"email": "kaleb@hornsby.ws",
"url": "kaleb.hornsby.ws"
},
"bugs": {
"url": "https://github.com/kaleb/js-math/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Kaleb Hornsby",
"email": "kaleb@hornsby.ws",
"url": "kaleb.hornsby.ws"
}
],
"dependencies": {},
"deprecated": false,
"description": "Mathematical Functions",
"devDependencies": {},
"engines": {
"node": "> 0.0.0"
},
"homepage": "http://kaleb.hornsby.ws/js-math",
"main": "math.js",
"name": "math",
"repository": {
"type": "git",
"url": "git://github.com/kaleb/js-math.git"
},
"version": "0.0.3"
}
1.1.0 / 2015-08-14
==================
* fix typo
* feat: Support IE8
1.0.1 / 2015-07-06
==================
* refactor: add \n to benchmark
* fix '\n' encoding
1.0.0 / 2015-04-04
==================
* deps: upgrade iconv-lite to 0.4.7
0.2.0 / 2014-04-25
==================
* urlencode.stringify done (@alsotang)
0.1.2 / 2014-04-09
==================
* remove unused variable QueryString (@azbykov)
0.1.1 / 2014-02-25
==================
* improve parse() performance 10x
0.1.0 / 2014-02-24
==================
* decode with charset
* add npm image
* remove 0.6 for travis
* update to support coveralls
* use jscover instead of jscoverage
* update gitignore
* Merge pull request #1 from aleafs/master
* Add http entries test case
0.0.1 / 2012-10-31
==================
* encode() done. add benchmark and tests
* Initial commit
This software is licensed under the MIT License.
Copyright (C) 2012 - 2014 fengmk2 <fengmk2@gmail.com>
Copyright (C) 2015 node-modules
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.
urlencode [![Build Status](https://secure.travis-ci.org/node-modules/urlencode.png)](http://travis-ci.org/node-modules/urlencode) [![Coverage Status](https://coveralls.io/repos/node-modules/urlencode/badge.png)](https://coveralls.io/r/node-modules/urlencode)
=======
[![NPM](https://nodei.co/npm/urlencode.png?downloads=true&stars=true)](https://nodei.co/npm/urlencode/)
encodeURIComponent with charset, e.g.: `gbk`
## Install
```bash
$ npm install urlencode
```
## Usage
```js
var urlencode = require('urlencode');
console.log(urlencode('苏千')); // default is utf8
console.log(urlencode('苏千', 'gbk')); // '%CB%D5%C7%A7'
// decode gbk
urlencode.decode('%CB%D5%C7%A7', 'gbk'); // '苏千'
// parse gbk querystring
urlencode.parse('nick=%CB%D5%C7%A7', {charset: 'gbk'}); // {nick: '苏千'}
// stringify obj with gbk encoding
var str = 'x[y][0][v][w]=' + urlencode('雾空', 'gbk'); // x[y][0][v][w]=%CE%ED%BF%D5
var obj = {'x' : {'y' : [{'v' : {'w' : '雾空'}}]}};
urlencode.stringify(obj, {charset: 'gbk'}).should.equal(str);
```
## Benchmark
### urlencode(str, encoding)
```bash
$ node benchmark/urlencode.js
node version: v0.10.26
urlencode(str) x 11,980 ops/sec ±1.13% (100 runs sampled)
urlencode(str, "gbk") x 8,575 ops/sec ±1.58% (94 runs sampled)
encodeURIComponent(str) x 11,677 ops/sec ±2.32% (93 runs sampled)
Fastest is urlencode(str)
```
### urlencode.decode(str, encoding)
```bash
$ node benchmark/urlencode.decode.js
node version: v0.10.26
urlencode.decode(str) x 26,027 ops/sec ±7.51% (73 runs sampled)
urlencode.decode(str, "gbk") x 14,409 ops/sec ±1.72% (98 runs sampled)
decodeURIComponent(str) x 36,052 ops/sec ±0.90% (96 runs sampled)
urlencode.parse(qs, {charset: "gbk"}) x 16,401 ops/sec ±1.09% (98 runs sampled)
urlencode.parse(qs, {charset: "utf8"}) x 23,381 ops/sec ±2.22% (93 runs sampled)
Fastest is decodeURIComponent(str)
```
## TODO
* [x] stringify()
## License
[MIT](LICENSE.txt)
/**!
* urlencode - lib/urlencode.js
*
* MIT Licensed
*
* Authors:
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
*/
"use strict";
/**
* Module dependencies.
*/
var iconv = require('iconv-lite');
function isUTF8(charset) {
if (!charset) {
return true;
}
charset = charset.toLowerCase();
return charset === 'utf8' || charset === 'utf-8';
}
function encode(str, charset) {
if (isUTF8(charset)) {
return encodeURIComponent(str);
}
var buf = iconv.encode(str, charset);
var encodeStr = '';
var ch = '';
for (var i = 0; i < buf.length; i++) {
ch = buf[i].toString('16');
if (ch.length === 1) {
ch = '0' + ch;
}
encodeStr += '%' + ch;
}
encodeStr = encodeStr.toUpperCase();
return encodeStr;
}
function decode(str, charset) {
if (isUTF8(charset)) {
return decodeURIComponent(str);
}
var bytes = [];
for (var i = 0; i < str.length; ) {
if (str[i] === '%') {
i++;
bytes.push(parseInt(str.substring(i, i + 2), 16));
i += 2;
} else {
bytes.push(str.charCodeAt(i));
i++;
}
}
var buf = new Buffer(bytes);
return iconv.decode(buf, charset);
}
function parse(qs, sep, eq, options) {
if (typeof sep === 'object') {
// parse(qs, options)
options = sep;
sep = null;
}
sep = sep || '&';
eq = eq || '=';
var obj = {};
if (typeof qs !== 'string' || qs.length === 0) {
return obj;
}
var regexp = /\+/g;
qs = qs.split(sep);
var maxKeys = 1000;
var charset = null;
if (options) {
if (typeof options.maxKeys === 'number') {
maxKeys = options.maxKeys;
}
if (typeof options.charset === 'string') {
charset = options.charset;
}
}
var len = qs.length;
// maxKeys <= 0 means that we should not limit keys count
if (maxKeys > 0 && len > maxKeys) {
len = maxKeys;
}
for (var i = 0; i < len; ++i) {
var x = qs[i].replace(regexp, '%20');
var idx = x.indexOf(eq);
var kstr, vstr, k, v;
if (idx >= 0) {
kstr = x.substr(0, idx);
vstr = x.substr(idx + 1);
} else {
kstr = x;
vstr = '';
}
if (kstr && kstr.indexOf('%') >= 0) {
try {
k = decode(kstr, charset);
} catch (e) {
k = kstr;
}
} else {
k = kstr;
}
if (vstr && vstr.indexOf('%') >= 0) {
try {
v = decode(vstr, charset);
} catch (e) {
v = vstr;
}
} else {
v = vstr;
}
if (!has(obj, k)) {
obj[k] = v;
} else if (Array.isArray(obj[k])) {
obj[k].push(v);
} else {
obj[k] = [obj[k], v];
}
}
return obj;
}
function has(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}
function isASCII(str) {
return (/^[\x00-\x7F]*$/).test(str);
}
function encodeComponent(item, charset) {
item = String(item);
if (isASCII(item)) {
item = encodeURIComponent(item);
} else {
item = encode(item, charset);
}
return item;
}
var stringify = function(obj, prefix, options) {
if (typeof prefix !== 'string') {
options = prefix || {};
prefix = null;
}
var charset = options.charset || 'utf-8';
if (Array.isArray(obj)) {
return stringifyArray(obj, prefix, options);
} else if ('[object Object]' === {}.toString.call(obj)) {
return stringifyObject(obj, prefix, options);
} else if ('string' === typeof obj) {
return stringifyString(obj, prefix, options);
} else {
return prefix + '=' + encodeComponent(String(obj), charset);
}
};
function stringifyString(str, prefix, options) {
if (!prefix) {
throw new TypeError('stringify expects an object');
}
var charset = options.charset;
return prefix + '=' + encodeComponent(str, charset);
}
function stringifyArray(arr, prefix, options) {
var ret = [];
if (!prefix) {
throw new TypeError('stringify expects an object');
}
for (var i = 0; i < arr.length; i++) {
ret.push(stringify(arr[i], prefix + '[' + i + ']', options));
}
return ret.join('&');
}
function stringifyObject(obj, prefix, options) {
var ret = [];
var keys = Object.keys(obj);
var key;
var charset = options.charset;
for (var i = 0, len = keys.length; i < len; ++i) {
key = keys[i];
if ('' === key) {
continue;
}
if (null === obj[key]) {
ret.push(encode(key, charset) + '=');
} else {
ret.push(stringify(
obj[key],
prefix ? prefix + '[' + encodeComponent(key, charset) + ']': encodeComponent(key, charset),
options));
}
}
return ret.join('&');
}
module.exports = encode;
module.exports.encode = encode;
module.exports.decode = decode;
module.exports.parse = parse;
module.exports.stringify = stringify;
{
"_from": "urlencode",
"_id": "urlencode@1.1.0",
"_inBundle": false,
"_integrity": "sha1-HyuibwE8hfATP3o61v8nMK33y7c=",
"_location": "/urlencode",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "urlencode",
"name": "urlencode",
"escapedName": "urlencode",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/urlencode/-/urlencode-1.1.0.tgz",
"_shasum": "1f2ba26f013c85f0133f7a3ad6ff2730adf7cbb7",
"_spec": "urlencode",
"_where": "C:\\Users\\tlsgml8847\\Documents\\oss\\Project\\OSS_project\\Chess",
"author": {
"name": "fengmk2",
"email": "fengmk2@gmail.com"
},
"bugs": {
"url": "https://github.com/node-modules/urlencode/issues"
},
"bundleDependencies": false,
"dependencies": {
"iconv-lite": "~0.4.11"
},
"deprecated": false,
"description": "encodeURIComponent with charset",
"devDependencies": {
"autod": "*",
"beautify-benchmark": "*",
"benchmark": "*",
"blanket": "*",
"contributors": "*",
"istanbul": "~0.3.17",
"jshint": "*",
"mocha": "*",
"should": "7"
},
"files": [
"lib"
],
"homepage": "https://github.com/node-modules/urlencode",
"keywords": [
"urlencode",
"urldecode",
"encodeURIComponent",
"decodeURIComponent",
"querystring",
"parse"
],
"license": "MIT",
"main": "lib/urlencode.js",
"name": "urlencode",
"repository": {
"type": "git",
"url": "git://github.com/node-modules/urlencode.git"
},
"scripts": {
"autod": "autod -w --prefix '~' -t test -e examples",
"benchmark": "node benchmark/urlencode.js && node benchmark/urlencode.decode.js",
"cnpm": "npm install --registry=https://registry.npm.taobao.org",
"jshint": "jshint .",
"test": "mocha -R spec -t 20000 -r should test/*.test.js",
"test-cov": "istanbul cover node_modules/.bin/_mocha -- -t 20000 -r should test/*.test.js",
"test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- -t 20000 -r should test/*.test.js"
},
"version": "1.1.0"
}
module.exports = function(app)
{
//TFT API를 이용한 코드 작성
}
\ No newline at end of file