Skip to content

Commit a34d8f8

Browse files
committed
release for version 0.6.0
2 parents 6fffac0 + 7b3bb26 commit a34d8f8

27 files changed

+1281
-586
lines changed

.babelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"stage": 0,
3+
"loose": "all",
4+
"plugins": [
5+
"babel-plugin-espower"
6+
]
7+
}

.closurelinter

Lines changed: 0 additions & 4 deletions
This file was deleted.

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
./build/deepcopy.js
2+
./build/deepcopy.min.js
3+
./lib

.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extends:
2+
- sasaplus1
3+
4+
# vim:ft=yaml:

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
# node.js
12
npm-debug.log
2-
test/test.pwr.js
3-
bower_components/
43
node_modules/
4+
5+
# generate files
6+
/lib/

.npmignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
deepcopy.min.js
2-
.closurelinter
1+
.babelrc
2+
.eslintignore
3+
.eslintrc
4+
.gitignore
35
.travis.yml
6+
karma.conf.coffee
47
test/
8+
webpack.config.coffee
9+
webpack.config.js

.travis.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
language: node_js
2+
23
node_js:
4+
- "iojs"
35
- "0.10"
46
- "0.11"
57
- "0.12"
6-
- "iojs"
8+
- "4.2"
9+
- "5.3"
10+
711
sudo: false
12+
813
cache:
914
directories:
1015
- node_modules
11-
- bower_components
16+
1217
notifications:
1318
email: false
14-
before_script:
15-
- export DISPLAY=:99.0
16-
- sh -e /etc/init.d/xvfb start
17-
- sleep 5
19+
1820
script:
19-
- npm run bower
20-
- npm run test
2121
- npm run travis

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 0.6.0 / 2015-12-29
2+
3+
- fixed #7
4+
- added customizer argument
5+
16
# 0.5.0 / 2015-04-11
27

38
- supported for Symbol

README.md

Lines changed: 76 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,25 @@
33
[![Build Status](https://travis-ci.org/sasaplus1/deepcopy.js.svg)](https://travis-ci.org/sasaplus1/deepcopy.js)
44
[![Dependency Status](https://gemnasium.com/sasaplus1/deepcopy.js.svg)](https://gemnasium.com/sasaplus1/deepcopy.js)
55
[![NPM version](https://badge.fury.io/js/deepcopy.svg)](http://badge.fury.io/js/deepcopy)
6-
[![Bower version](https://badge.fury.io/bo/deepcopy.svg)](http://badge.fury.io/bo/deepcopy)
76

87
deep copy for any data
98

10-
## Installation
9+
## Playground
1110

12-
### npm
11+
[REPL powered by Tonic](https://tonicdev.com/npm/deepcopy)
1312

14-
```sh
15-
$ npm install deepcopy
16-
```
17-
18-
### bower
13+
## Installation
1914

2015
```sh
21-
$ bower install deepcopy
16+
$ npm install deepcopy
2217
```
2318

2419
## Usage
2520

2621
### node.js
2722

2823
```js
29-
var deepcopy = require('deepcopy');
24+
var deepcopy = require("deepcopy");
3025
```
3126

3227
### browser
@@ -35,121 +30,101 @@ var deepcopy = require('deepcopy');
3530
<script src="deepcopy.min.js"></script>
3631
```
3732

38-
define `deepcopy` by `define()` if using AMD loader.
39-
40-
otherwise `deepcopy` export to global.
41-
4233
### Example
4334

35+
basic usage:
36+
4437
```js
45-
var data, shallow, deep;
46-
47-
data = {
48-
objects: {
49-
array: [
50-
null, undefined, new Date, /deepcopy/ig
51-
],
52-
object: {
53-
number: NaN,
54-
string: 'A',
55-
boolean: true
56-
},
57-
to: null
58-
}
38+
var base, copy;
39+
40+
base = {
41+
desserts: [
42+
{ name: "cake" },
43+
{ name: "ice cream" },
44+
{ name: "pudding" }
45+
]
5946
};
6047

61-
// circular reference
62-
data.objects.to = data;
63-
64-
// shallow copy and deep copy
65-
shallow = data;
66-
deep = deepcopy(data);
67-
68-
// remove entry
69-
delete data.objects;
70-
71-
// results
72-
console.log(data);
73-
// {}
74-
console.log(shallow);
75-
// {}
76-
console.log(require('util').inspect(deep, { depth: null }));
77-
// { objects:
78-
// { array:
79-
// [ null,
80-
// undefined,
81-
// Sat Jan 10 2015 03:18:32 GMT+0900 (JST),
82-
// /deepcopy/gi ],
83-
// object: { number: NaN, string: 'A', boolean: true },
84-
// to: [Circular] } }
85-
```
48+
copy = deepcopy(base);
49+
base.desserts = null;
8650

87-
```js
88-
var data, deep;
51+
console.log(base);
52+
// { desserts: null }
53+
console.log(copy);
54+
// { desserts: [ { name: 'cake' }, { name: 'ice cream' }, { name: 'pudding' } ] }
55+
```
8956

90-
data = { object: {} };
91-
data.object[Symbol.for('sym')] = 123;
57+
customize deepcopy:
9258

93-
deep = deepcopy(data);
59+
```js
60+
function MyClass(id) {
61+
this._id = id;
62+
}
63+
64+
var base, copy;
65+
66+
base = {
67+
myClasses: [
68+
new MyClass(1),
69+
new MyClass(2),
70+
new MyClass(3)
71+
]
72+
};
9473

95-
delete data.object;
74+
copy = deepcopy(base, function(target) {
75+
if (target.constructor === MyClass) {
76+
return new MyClass(target._id);
77+
}
78+
});
79+
base.myClasses = null;
9680

97-
console.log(data.object);
98-
// undefined
99-
console.log(deep.object[Symbol.for('sym')]);
100-
// 123
81+
console.log(base);
82+
// { myClasses: null }
83+
console.log(copy);
84+
// { myClasses: [ MyClass { _id: 1 }, MyClass { _id: 2 }, MyClass { _id: 3 } ] }
10185
```
10286

10387
## Functions
10488

105-
### deepcopy(value)
106-
107-
* `value`
108-
* `*` - copy target value
109-
* `return`
110-
* `*` - deep copied value
111-
112-
return deep copied value.
113-
114-
supported types are below:
115-
116-
* Number
117-
* String
118-
* Boolean
119-
* Null
120-
* Undefined
121-
* Function (shallow copy)
122-
* Date
123-
* RegExp
124-
* Array
125-
* recursive copy
126-
* also can copy if it has circular reference
127-
* Object
128-
* recursive copy
129-
* also can copy if it has circular reference
130-
* Buffer (node.js only)
131-
* Symbol
89+
### deepcopy(value[, customizer])
90+
91+
- `value`
92+
- `*` - target value
93+
- `customizer`
94+
- `Function` - customize function
95+
- `return`
96+
- `*` - copied value
97+
98+
support types are below:
99+
100+
- Number
101+
- String
102+
- Boolean
103+
- Null
104+
- Undefined
105+
- Function
106+
- shallow copy if it is native function
107+
- Date
108+
- RegExp
109+
- Array
110+
- support recursive copy
111+
- also can copy if it has circular reference
112+
- Object
113+
- support recursive copy
114+
- also can copy if it has circular reference
115+
- Buffer (node.js only)
116+
- Symbol
132117

133118
## Test
134119

135-
### node.js
136-
137120
```sh
138121
$ npm install
139122
$ npm test
140123
```
141124

142-
### browser
143-
144-
```sh
145-
$ npm install
146-
$ npm run bower
147-
$ npm run testem
148-
```
149-
150125
## Contributors
151126

152-
* [kjirou](https://github.com/kjirou)
127+
- [kjirou](https://github.com/kjirou)
153128

154129
## License
155130

bower.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)