feat: 초기 프로젝트 설정 및 룰.md 파일 추가
This commit is contained in:
20
api.hyungi.net/node_modules/fclone/LICENSE
generated
vendored
Normal file
20
api.hyungi.net/node_modules/fclone/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Clone javascript object without circular values
|
||||
Copyright © 2016 Antoine Bluchet <soyuka@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.
|
||||
56
api.hyungi.net/node_modules/fclone/README.md
generated
vendored
Normal file
56
api.hyungi.net/node_modules/fclone/README.md
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
# FClone
|
||||
|
||||
Clone objects by dropping circular references
|
||||
|
||||
[](https://travis-ci.org/soyuka/fclone)
|
||||
|
||||
This module clones a Javascript object in safe mode (eg: drops circular values) recursively. Circular values are replaced with a string: `'[Circular]'`.
|
||||
|
||||
Ideas from [tracker1/safe-clone-deep](https://github.com/tracker1/safe-clone-deep). I improved the workflow a bit by:
|
||||
- refactoring the code (complete rewrite)
|
||||
- fixing node 6+
|
||||
- micro optimizations
|
||||
- use of `Array.isArray` and `Buffer.isBuffer`
|
||||
|
||||
Node 0.10 compatible, distributed files are translated to es2015.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install fclone
|
||||
# or
|
||||
bower install fclone
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
const fclone = require('fclone');
|
||||
|
||||
let a = {c: 'hello'};
|
||||
a.b = a;
|
||||
|
||||
let o = fclone(a);
|
||||
|
||||
console.log(o);
|
||||
// outputs: { c: 'hello', b: '[Circular]' }
|
||||
|
||||
//JSON.stringify is now safe
|
||||
console.log(JSON.stringify(o));
|
||||
```
|
||||
|
||||
## Benchmarks
|
||||
|
||||
Some benchs:
|
||||
|
||||
```
|
||||
fclone x 17,081 ops/sec ±0.71% (79 runs sampled)
|
||||
fclone + json.stringify x 9,433 ops/sec ±0.91% (81 runs sampled)
|
||||
util.inspect (outputs a string) x 2,498 ops/sec ±0.77% (90 runs sampled)
|
||||
jsan x 5,379 ops/sec ±0.82% (91 runs sampled)
|
||||
circularjson x 4,719 ops/sec ±1.16% (91 runs sampled)
|
||||
deepcopy x 5,478 ops/sec ±0.77% (86 runs sampled)
|
||||
json-stringify-safe x 5,828 ops/sec ±1.30% (84 runs sampled)
|
||||
clone x 8,713 ops/sec ±0.68% (88 runs sampled)
|
||||
Fastest is util.format (outputs a string)
|
||||
```
|
||||
57
api.hyungi.net/node_modules/fclone/bench/index.js
generated
vendored
Normal file
57
api.hyungi.net/node_modules/fclone/bench/index.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
'use strict'
|
||||
const Benchmark = require('benchmark')
|
||||
const suite = new Benchmark.Suite
|
||||
|
||||
function Complex() {
|
||||
this.bar = 'foo'
|
||||
this.foo = new Array(100).fill(0).map(e => Math.random())
|
||||
}
|
||||
|
||||
Complex.prototype.method = function() {}
|
||||
|
||||
const a = {b: 'hello', c: {foo: 'bar', bar: 'foo', error: new Error('Test')}, complex: new Complex()}
|
||||
|
||||
a.a = a
|
||||
a.c.complex = a.complex
|
||||
a.env = process.env
|
||||
|
||||
const fclone = require('../dist/fclone.js')
|
||||
const clone = require('clone')
|
||||
const deepcopy = require('deepcopy')
|
||||
const jsonstringifysafe = require('json-stringify-safe')
|
||||
const jsan = require('jsan')
|
||||
const circularjson = require('circular-json-es6')
|
||||
const util = require('util')
|
||||
|
||||
suite
|
||||
.add('fclone', function() {
|
||||
let b = fclone(a)
|
||||
})
|
||||
.add('fclone + json.stringify', function() {
|
||||
let b = JSON.stringify(fclone(a))
|
||||
})
|
||||
.add('util.inspect (outputs a string)', function() {
|
||||
let b = util.inspect(a)
|
||||
})
|
||||
.add('jsan', function() {
|
||||
let b = jsan.stringify(a)
|
||||
})
|
||||
.add('circularjson', function() {
|
||||
let b = circularjson.stringify(a)
|
||||
})
|
||||
.add('deepcopy', function() {
|
||||
let b = deepcopy(a)
|
||||
})
|
||||
.add('json-stringify-safe', function() {
|
||||
let b = jsonstringifysafe(a)
|
||||
})
|
||||
.add('clone', function() {
|
||||
let b = clone(a)
|
||||
})
|
||||
.on('cycle', function(event) {
|
||||
console.log(String(event.target))
|
||||
})
|
||||
.on('complete', function() {
|
||||
console.log('Fastest is ' + this.filter('fastest').map('name'))
|
||||
})
|
||||
.run({ 'async': true })
|
||||
33
api.hyungi.net/node_modules/fclone/bench/looparr.js
generated
vendored
Normal file
33
api.hyungi.net/node_modules/fclone/bench/looparr.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict'
|
||||
const Benchmark = require('benchmark')
|
||||
const suite = new Benchmark.Suite
|
||||
|
||||
let arr = new Array(100).fill(Math.random() * 100)
|
||||
|
||||
suite
|
||||
.add('for', function() {
|
||||
let l = arr.length
|
||||
for (let i = 0; i < l; i++) {
|
||||
let o = arr[i]
|
||||
}
|
||||
})
|
||||
.add('while --', function() {
|
||||
let l = arr.length
|
||||
while(l--) {
|
||||
let o = arr[l]
|
||||
}
|
||||
})
|
||||
.add('while ++', function() {
|
||||
let l = arr.length
|
||||
let i = -1
|
||||
while(l > ++i) {
|
||||
let o = arr[i]
|
||||
}
|
||||
})
|
||||
.on('cycle', function(event) {
|
||||
console.log(String(event.target))
|
||||
})
|
||||
.on('complete', function() {
|
||||
console.log('Fastest is ' + this.filter('fastest').map('name'))
|
||||
})
|
||||
.run({ 'async': true })
|
||||
34
api.hyungi.net/node_modules/fclone/bench/loopobj.js
generated
vendored
Normal file
34
api.hyungi.net/node_modules/fclone/bench/loopobj.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict'
|
||||
const Benchmark = require('benchmark')
|
||||
const suite = new Benchmark.Suite
|
||||
|
||||
let obj = process.env
|
||||
|
||||
suite
|
||||
.add('for in', function() {
|
||||
for(let i in obj) {
|
||||
let o = obj[i]
|
||||
}
|
||||
})
|
||||
.add('while --', function() {
|
||||
let keys = Object.keys(obj)
|
||||
let l = keys.length
|
||||
while(l--) {
|
||||
let o = obj[keys[l]]
|
||||
}
|
||||
})
|
||||
.add('while shift', function() {
|
||||
let keys = Object.keys(obj)
|
||||
let k
|
||||
|
||||
while(k = keys.shift()) {
|
||||
let o = obj[k]
|
||||
}
|
||||
})
|
||||
.on('cycle', function(event) {
|
||||
console.log(String(event.target))
|
||||
})
|
||||
.on('complete', function() {
|
||||
console.log('Fastest is ' + this.filter('fastest').map('name'))
|
||||
})
|
||||
.run({ 'async': true })
|
||||
20
api.hyungi.net/node_modules/fclone/bench/package.json
generated
vendored
Normal file
20
api.hyungi.net/node_modules/fclone/bench/package.json
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "bench",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"benchmark": "^2.1.0",
|
||||
"clone": "^1.0.2",
|
||||
"circular-json-es6": "^2.0.0",
|
||||
"deepcopy": "^0.6.3",
|
||||
"jsan": "^3.1.2",
|
||||
"json-stringify-safe": "^5.0.1"
|
||||
}
|
||||
}
|
||||
30
api.hyungi.net/node_modules/fclone/bower.json
generated
vendored
Normal file
30
api.hyungi.net/node_modules/fclone/bower.json
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "fclone",
|
||||
"description": "Fastest JSON cloning module that handles circular references",
|
||||
"main": "dist/fclone.js",
|
||||
"authors": [
|
||||
"soyuka"
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"clone",
|
||||
"deep",
|
||||
"circular",
|
||||
"json",
|
||||
"stringify",
|
||||
"fast"
|
||||
],
|
||||
"homepage": "https://github.com/soyuka/fclone",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test.js",
|
||||
"!dist/dpicker.js",
|
||||
"!dist/dpicker.min.js",
|
||||
"screen.png",
|
||||
"gulpfile.js",
|
||||
"demo",
|
||||
"bump.sh"
|
||||
]
|
||||
}
|
||||
3
api.hyungi.net/node_modules/fclone/dist/fclone.d.ts
generated
vendored
Normal file
3
api.hyungi.net/node_modules/fclone/dist/fclone.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare module 'fclone' {
|
||||
export default function fclone<T>(obj: T): T;
|
||||
}
|
||||
83
api.hyungi.net/node_modules/fclone/dist/fclone.js
generated
vendored
Normal file
83
api.hyungi.net/node_modules/fclone/dist/fclone.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD
|
||||
define('fclone', [], factory);
|
||||
} else if (typeof module === 'object' && module.exports) {
|
||||
//node
|
||||
module.exports = factory();
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.fclone = factory();
|
||||
}
|
||||
}(this, function () {
|
||||
'use strict';
|
||||
|
||||
// see if it looks and smells like an iterable object, and do accept length === 0
|
||||
|
||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
|
||||
|
||||
function isArrayLike(item) {
|
||||
if (Array.isArray(item)) return true;
|
||||
|
||||
var len = item && item.length;
|
||||
return typeof len === 'number' && (len === 0 || len - 1 in item) && typeof item.indexOf === 'function';
|
||||
}
|
||||
|
||||
function fclone(obj, refs) {
|
||||
if (!obj || "object" !== (typeof obj === 'undefined' ? 'undefined' : _typeof(obj))) return obj;
|
||||
|
||||
if (obj instanceof Date) {
|
||||
return new Date(obj);
|
||||
}
|
||||
|
||||
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(obj)) {
|
||||
return new Buffer(obj);
|
||||
}
|
||||
|
||||
// typed array Int32Array etc.
|
||||
if (typeof obj.subarray === 'function' && /[A-Z][A-Za-z\d]+Array/.test(Object.prototype.toString.call(obj))) {
|
||||
return obj.subarray(0);
|
||||
}
|
||||
|
||||
if (!refs) {
|
||||
refs = [];
|
||||
}
|
||||
|
||||
if (isArrayLike(obj)) {
|
||||
refs[refs.length] = obj;
|
||||
var _l = obj.length;
|
||||
var i = -1;
|
||||
var _copy = [];
|
||||
|
||||
while (_l > ++i) {
|
||||
_copy[i] = ~refs.indexOf(obj[i]) ? '[Circular]' : fclone(obj[i], refs);
|
||||
}
|
||||
|
||||
refs.length && refs.length--;
|
||||
return _copy;
|
||||
}
|
||||
|
||||
refs[refs.length] = obj;
|
||||
var copy = {};
|
||||
|
||||
if (obj instanceof Error) {
|
||||
copy.name = obj.name;
|
||||
copy.message = obj.message;
|
||||
copy.stack = obj.stack;
|
||||
}
|
||||
|
||||
var keys = Object.keys(obj);
|
||||
var l = keys.length;
|
||||
|
||||
while (l--) {
|
||||
var k = keys[l];
|
||||
copy[k] = ~refs.indexOf(obj[k]) ? '[Circular]' : fclone(obj[k], refs);
|
||||
}
|
||||
|
||||
refs.length && refs.length--;
|
||||
return copy;
|
||||
}
|
||||
|
||||
fclone.default = fclone;
|
||||
return fclone
|
||||
}));
|
||||
1
api.hyungi.net/node_modules/fclone/dist/fclone.min.js
generated
vendored
Normal file
1
api.hyungi.net/node_modules/fclone/dist/fclone.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(e,t){"function"==typeof define&&define.amd?define("fclone",[],t):"object"==typeof module&&module.exports?module.exports=t():e.fclone=t()}(this,function(){"use strict";function e(e){if(Array.isArray(e))return!0;var t=e&&e.length;return"number"==typeof t&&(0===t||t-1 in e)&&"function"==typeof e.indexOf}function t(r,f){if(!r||"object"!==("undefined"==typeof r?"undefined":n(r)))return r;if(r instanceof Date)return new Date(r);if("undefined"!=typeof Buffer&&Buffer.isBuffer(r))return new Buffer(r);if("function"==typeof r.subarray&&/[A-Z][A-Za-z\d]+Array/.test(Object.prototype.toString.call(r)))return r.subarray(0);if(f||(f=[]),e(r)){f[f.length]=r;for(var o=r.length,u=-1,i=[];o>++u;)i[u]=~f.indexOf(r[u])?"[Circular]":t(r[u],f);return f.length&&f.length--,i}f[f.length]=r;var a={};r instanceof Error&&(a.name=r.name,a.message=r.message,a.stack=r.stack);for(var c=Object.keys(r),l=c.length;l--;){var y=c[l];a[y]=~f.indexOf(r[y])?"[Circular]":t(r[y],f)}return f.length&&f.length--,a}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};return t["default"]=t,t});
|
||||
3
api.hyungi.net/node_modules/fclone/fclone.d.ts
generated
vendored
Normal file
3
api.hyungi.net/node_modules/fclone/fclone.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare module 'fclone' {
|
||||
export default function fclone<T>(obj: T): T;
|
||||
}
|
||||
34
api.hyungi.net/node_modules/fclone/package.json
generated
vendored
Normal file
34
api.hyungi.net/node_modules/fclone/package.json
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "fclone",
|
||||
"version": "1.0.11",
|
||||
"description": "Clone objects by dropping circular references",
|
||||
"main": "dist/fclone",
|
||||
"scripts": {
|
||||
"test": "./node_modules/.bin/_mocha",
|
||||
"build": "./node_modules/.bin/gulp"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/soyuka/fclone.git"
|
||||
},
|
||||
"keywords": [
|
||||
"clone",
|
||||
"deep",
|
||||
"circular",
|
||||
"json",
|
||||
"stringify",
|
||||
"fast"
|
||||
],
|
||||
"author": "soyuka <soyuka@gmail.com>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"babel-preset-es2015": "^6.9.0",
|
||||
"chai": "^3.5.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-babel": "^6.1.2",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-uglify": "^1.5.4",
|
||||
"gulp-wrap": "^0.13.0",
|
||||
"mocha": "^2.5.3"
|
||||
}
|
||||
}
|
||||
64
api.hyungi.net/node_modules/fclone/src/fclone.js
generated
vendored
Normal file
64
api.hyungi.net/node_modules/fclone/src/fclone.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
'use strict';
|
||||
|
||||
// see if it looks and smells like an iterable object, and do accept length === 0
|
||||
function isArrayLike(item) {
|
||||
if (Array.isArray(item)) return true;
|
||||
|
||||
const len = item && item.length;
|
||||
return typeof len === 'number' && (len === 0 || (len - 1) in item) && typeof item.indexOf === 'function';
|
||||
}
|
||||
|
||||
function fclone(obj, refs) {
|
||||
if (!obj || "object" !== typeof obj) return obj;
|
||||
|
||||
if (obj instanceof Date) {
|
||||
return new Date(obj);
|
||||
}
|
||||
|
||||
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(obj)) {
|
||||
return new Buffer(obj);
|
||||
}
|
||||
|
||||
// typed array Int32Array etc.
|
||||
if (typeof obj.subarray === 'function' && /[A-Z][A-Za-z\d]+Array/.test(Object.prototype.toString.call(obj))) {
|
||||
return obj.subarray(0);
|
||||
}
|
||||
|
||||
if (!refs) { refs = []; }
|
||||
|
||||
if (isArrayLike(obj)) {
|
||||
refs[refs.length] = obj;
|
||||
let l = obj.length;
|
||||
let i = -1;
|
||||
let copy = [];
|
||||
|
||||
while (l > ++i) {
|
||||
copy[i] = ~refs.indexOf(obj[i]) ? '[Circular]' : fclone(obj[i], refs);
|
||||
}
|
||||
|
||||
refs.length && refs.length--;
|
||||
return copy;
|
||||
}
|
||||
|
||||
refs[refs.length] = obj;
|
||||
let copy = {};
|
||||
|
||||
if (obj instanceof Error) {
|
||||
copy.name = obj.name;
|
||||
copy.message = obj.message;
|
||||
copy.stack = obj.stack;
|
||||
}
|
||||
|
||||
let keys = Object.keys(obj);
|
||||
let l = keys.length;
|
||||
|
||||
while(l--) {
|
||||
let k = keys[l];
|
||||
copy[k] = ~refs.indexOf(obj[k]) ? '[Circular]' : fclone(obj[k], refs);
|
||||
}
|
||||
|
||||
refs.length && refs.length--;
|
||||
return copy;
|
||||
}
|
||||
|
||||
fclone.default = fclone
|
||||
Reference in New Issue
Block a user