Skip to content

Commit

Permalink
release for version 0.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sasaplus1 committed Jun 12, 2016
2 parents 6fd0cc3 + 86481e2 commit c3734d9
Show file tree
Hide file tree
Showing 13 changed files with 208 additions and 93 deletions.
37 changes: 34 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
{
"stage": 0,
"loose": "all",
"plugins": [
"babel-plugin-espower"
"check-es2015-constants",
"transform-es2015-parameters",
"transform-es2015-block-scoping",
[
"transform-es2015-arrow-functions", {
"spec": true
}
],
[
"transform-es2015-computed-properties", {
"loose": true
}
],
[
"transform-es2015-template-literals", {
"loose": true,
"spec": true
}
],
"add-module-exports",
[
"transform-es2015-modules-commonjs", {
"loose": true
}
],
[
"transform-strict-mode", {
"strict": true
}
],
"transform-undefined-to-void",
"transform-es3-property-literals",
"transform-es3-member-expression-literals",
"espower"
]
}
8 changes: 5 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
./build/deepcopy.js
./build/deepcopy.min.js
./lib
build/deepcopy.js
build/deepcopy.min.js
index.js
lib/
webpack.config.js
File renamed without changes.
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.babelrc
.eslintignore
.eslintrc
.eslintrc.yaml
.gitignore
.travis.yml
karma.conf.coffee
Expand Down
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ node_js:
- "0.10"
- "0.11"
- "0.12"
- "4.2"
- "5.3"
- "4"
- "5"
- "6"

sudo: false

Expand Down
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.6.2 / 2016-06-12

- fixed #10

# 0.6.1 / 2016-01-13

- fixed #9
Expand Down
82 changes: 41 additions & 41 deletions build/deepcopy.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ return /******/ (function(modules) { // webpackBootstrap
return false;
};

var getKeys = Object.keys ? function getKeys(obj) {
var getKeys = typeof Object.keys === 'function' ? function getKeys(obj) {
return Object.keys(obj);
} : function getKeys(obj) {
var objType = typeof obj;

if (obj === null || objType !== 'function' || objType !== 'object') {
if (obj === null || objType !== 'function' && objType !== 'object') {
throw new TypeError('obj must be an Object');
}

var resultKeys = [],
key = undefined;
key = void 0;

for (key in obj) {
obj.hasOwnProperty(key) && resultKeys.push(key);
Object.prototype.hasOwnProperty.call(obj, key) && resultKeys.push(key);
}

return resultKeys;
Expand All @@ -116,31 +116,31 @@ return /******/ (function(modules) { // webpackBootstrap
throw new TypeError('array must be an Array');
}

var i = undefined,
len = undefined,
value = undefined;
var i = void 0,
len = void 0,
value = void 0;

for (i = 0, len = array.length; i < len; ++i) {
value = array[i];

// it is SameValue algorithm
// http://stackoverflow.com/questions/27144277/comparing-a-variable-with-itself
// NOTE:
//
// it is SameValue algorithm
// http://stackoverflow.com/questions/27144277/comparing-a-variable-with-itself
//
// eslint-disable-next-line no-self-compare
if (value === s || value !== value && s !== s) {
// eslint-disable-line no-self-compare
return i;
}
}

return -1;
}

exports['default'] = {
getKeys: getKeys,
getSymbols: getSymbols,
indexOf: indexOf,
isBuffer: isBuffer
};
module.exports = exports['default'];
exports.getKeys = getKeys;
exports.getSymbols = getSymbols;
exports.indexOf = indexOf;
exports.isBuffer = isBuffer;

/***/ },
/* 2 */
Expand All @@ -149,6 +149,7 @@ return /******/ (function(modules) { // webpackBootstrap
'use strict';

exports.__esModule = true;
exports.copyValue = exports.copyCollection = exports.copy = void 0;

var _polyfill = __webpack_require__(1);

Expand Down Expand Up @@ -206,7 +207,7 @@ return /******/ (function(modules) { // webpackBootstrap
return target;
} else {
// user defined function
return new Function('return ' + source)();
return new Function('return ' + String(source))();
}
}

Expand Down Expand Up @@ -236,7 +237,7 @@ return /******/ (function(modules) { // webpackBootstrap
// +date; // 1420909757913
// +new Date(date); // 1420909757913
// +new Date(+date); // 1420909757913
return new Date(+target);
return new Date(target.getTime());
}

if (targetClass === '[object RegExp]') {
Expand All @@ -256,7 +257,7 @@ return /******/ (function(modules) { // webpackBootstrap
return new RegExp(regexpText.slice(1, slashIndex), regexpText.slice(slashIndex + 1));
}

if (_polyfill.isBuffer(target)) {
if ((0, _polyfill.isBuffer)(target)) {
var buffer = new Buffer(target.length);

target.copy(buffer);
Expand Down Expand Up @@ -285,12 +286,9 @@ return /******/ (function(modules) { // webpackBootstrap
return null;
}

exports['default'] = {
copy: copy,
copyCollection: copyCollection,
copyValue: copyValue
};
module.exports = exports['default'];
exports.copy = copy;
exports.copyCollection = copyCollection;
exports.copyValue = copyValue;

/***/ },
/* 3 */
Expand All @@ -309,21 +307,21 @@ return /******/ (function(modules) { // webpackBootstrap
}

function deepcopy(target) {
var customizer = arguments.length <= 1 || arguments[1] === undefined ? defaultCustomizer : arguments[1];
var customizer = arguments.length <= 1 || arguments[1] === void 0 ? defaultCustomizer : arguments[1];

if (target === null) {
// copy null
return null;
}

var resultValue = _copy.copyValue(target);
var resultValue = (0, _copy.copyValue)(target);

if (resultValue !== null) {
// copy some primitive types
return resultValue;
}

var resultCollection = _copy.copyCollection(target, customizer),
var resultCollection = (0, _copy.copyCollection)(target, customizer),
clone = resultCollection !== null ? resultCollection : target;

var visited = [target],
Expand All @@ -339,37 +337,39 @@ return /******/ (function(modules) { // webpackBootstrap
return null;
}

var resultValue = _copy.copyValue(target);
var resultValue = (0, _copy.copyValue)(target);

if (resultValue !== null) {
// copy some primitive types
return resultValue;
}

var keys = _polyfill.getKeys(target).concat(_polyfill.getSymbols(target));
var keys = (0, _polyfill.getKeys)(target).concat((0, _polyfill.getSymbols)(target));

var i = undefined,
len = undefined;
var i = void 0,
len = void 0;

var key = undefined,
value = undefined,
index = undefined,
resultCopy = undefined,
result = undefined,
ref = undefined;
var key = void 0,
value = void 0,
index = void 0,
resultCopy = void 0,
result = void 0,
ref = void 0;

for (i = 0, len = keys.length; i < len; ++i) {
key = keys[i];
value = target[key];
index = _polyfill.indexOf(visited, value);
index = (0, _polyfill.indexOf)(visited, value);

if (index === -1) {
resultCopy = _copy.copy(value, customizer);
resultCopy = (0, _copy.copy)(value, customizer);
result = resultCopy !== null ? resultCopy : value;

if (value !== null && /^(?:function|object)$/.test(typeof value)) {
visited.push(value);
reference.push(result);
} else {
ref = result;
}
} else {
// circular reference
Expand Down
2 changes: 1 addition & 1 deletion build/deepcopy.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 37 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deepcopy",
"version": "0.6.1",
"version": "0.6.2",
"author": "sasa+1 <sasaplus1@gmail.com>",
"contributors": [
"kjirou <kjirou.web@gmail.com>"
Expand All @@ -15,40 +15,54 @@
},
"scripts": {
"babel": "babel --out-dir ./lib ./src",
"build": "npm ru clean && npm ru babel && npm ru compile && npm ru minify",
"clean": "npm ru rimraf -- ./build ./lib",
"compile": "npm ru webpack -- --output-filename ./build/deepcopy.js",
"develop": " parallelshell 'npm ru babel -- -w' 'npm ru compile -- -w' 'npm ru minify -- -w'",
"build": "npm run clean && npm run babel && npm run compile && npm run minify",
"clean": "npm run rimraf -- ./build ./lib",
"compile": "npm run webpack -- --output-filename ./build/deepcopy.js",
"develop": " parallelshell 'npm run babel -- -w' 'npm run compile -- -w' 'npm run minify -- -w'",
"eslint": "eslint",
"karma": "karma",
"lint": "npm ru eslint -- --ext .js .",
"minify": "npm ru webpack -- --optimize-minimize --output-filename ./build/deepcopy.min.js",
"lint": "npm run eslint -- --ext .js .",
"minify": "npm run webpack -- --optimize-minimize --output-filename ./build/deepcopy.min.js",
"mocha": "mocha",
"posttest": "npm ru karma -- start --single-run --browsers Chrome,Firefox,Safari",
"prepublish": "npm ru build",
"posttest": "npm run karma -- start --single-run --browsers Chrome,Firefox,Safari",
"prepublish": "npm run build",
"rimraf": "rimraf",
"test": "npm ru mocha",
"travis": "npm ru mocha",
"test": "npm run mocha",
"travis": "npm run mocha",
"webpack": "webpack --colors --display-error-details --progress"
},
"devDependencies": {
"babel": "5.8.34",
"babel-eslint": "4.1.6",
"babel-loader": "5.3.3",
"babel-plugin-espower": "1.0.1",
"babel": "^6.5.2",
"babel-cli": "^6.6.5",
"babel-core": "^6.7.2",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.4",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-check-es2015-constants": "^6.7.2",
"babel-plugin-espower": "^2.1.2",
"babel-plugin-transform-es2015-arrow-functions": "^6.5.2",
"babel-plugin-transform-es2015-block-scoping": "^6.7.1",
"babel-plugin-transform-es2015-computed-properties": "^6.6.5",
"babel-plugin-transform-es2015-modules-commonjs": "^6.7.0",
"babel-plugin-transform-es2015-parameters": "^6.7.0",
"babel-plugin-transform-es2015-template-literals": "^6.6.5",
"babel-plugin-transform-es3-member-expression-literals": "^6.5.0",
"babel-plugin-transform-es3-property-literals": "^6.5.0",
"babel-plugin-transform-strict-mode": "^6.6.5",
"babel-plugin-transform-undefined-to-void": "^6.5.0",
"coffee-script": "^1.10.0",
"eslint": "^1.10.3",
"eslint-config-sasaplus1": "git://github.com/sasaplus1-prototype/eslint-config-sasaplus1.git",
"espower-babel": "3.3.0",
"eslint": "^2.4.0",
"eslint-config-sasaplus1": "sasaplus1-prototype/eslint-config-sasaplus1.git",
"espower-babel": "4.0.3",
"karma": "^0.13.15",
"karma-chrome-launcher": "^0.2.2",
"karma-firefox-launcher": "^0.1.7",
"karma-mocha": "^0.2.1",
"karma-safari-launcher": "^0.1.1",
"karma-chrome-launcher": "^1.0.1",
"karma-firefox-launcher": "^1.0.0",
"karma-mocha": "^1.0.1",
"karma-safari-launcher": "^1.0.0",
"karma-webpack": "^1.7.0",
"mocha": "^2.3.4",
"parallelshell": "^2.0.0",
"power-assert": "^1.2.0",
"power-assert": "^1.3.1",
"rimraf": "^2.4.4",
"webpack": "^1.12.9"
}
Expand Down
4 changes: 2 additions & 2 deletions src/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function copyCollection(target, customizer) {
// +date; // 1420909757913
// +new Date(date); // 1420909757913
// +new Date(+date); // 1420909757913
return new Date(+target);
return new Date(target.getTime());
}

if (targetClass === '[object RegExp]') {
Expand Down Expand Up @@ -136,7 +136,7 @@ function copyValue(target) {
return null;
}

export default {
export {
copy,
copyCollection,
copyValue,
Expand Down
Loading

0 comments on commit c3734d9

Please sign in to comment.