Skip to content
This repository was archived by the owner on Jul 20, 2020. It is now read-only.

Commit 61aed6f

Browse files
Merge 97b5f77 into c4e6c7e
2 parents c4e6c7e + 97b5f77 commit 61aed6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3221
-1549
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.DS_Store
2-
node_modules/
2+
.nyc_output
3+
node_modules/
4+
package-lock.json

.npmignore

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
.DS_Store
2+
.nyc_output
23
.travis.yml
3-
src/*
4-
test/*
5-
template/*
6-
template/license.after
7-
template/license.before
8-
utils/*
9-
node_modules/*
10-
build/*.amd.js
11-
Makefile
12-
index.html
13-
testrunner.js
4+
node_modules/
5+
rollup/
6+
test/
7+
package-lock.json

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
language: node_js
22
node_js:
3-
- 4
4-
- 6
5-
- 7
3+
- stable
64
git:
75
depth: 1
86
branches:
97
only:
108
- master
9+
after_success:
10+
- "npm run coveralls"

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"git.ignoreLimitWarning": true
3+
}

LICENSE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ISC License
2+
3+
Copyright (c) 2020, Andrea Giammarchi, @WebReflection
4+
5+
Permission to use, copy, modify, and/or distribute this software for any
6+
purpose with or without fee is hereby granted, provided that the above
7+
copyright notice and this permission notice appear in all copies.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14+
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15+
PERFORMANCE OF THIS SOFTWARE.

LICENSE.txt

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

Makefile

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

README.md

Lines changed: 7 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,13 @@
1-
cloner [![build status](https://secure.travis-ci.org/WebReflection/cloner.svg)](http://travis-ci.org/WebReflection/cloner)
2-
==============
1+
# cloner
32

4-
An ES5+ compatible utility to deep or shallow copy and merge objects.
3+
[![Build Status](https://travis-ci.com/WebReflection/cloner.svg?branch=master)](https://travis-ci.com/WebReflection/cloner) [![Coverage Status](https://coveralls.io/repos/github/WebReflection/cloner/badge.svg?branch=master)](https://coveralls.io/github/WebReflection/cloner?branch=master)
54

6-
### API
7-
The module has two sub modules: `shallow` and `deep`.
8-
Both of them will have two methods: `copy` and `merge`.
9-
10-
#### cloner.shallow.copy(object):shallowCopy
11-
Will loop over all own keys and copy them to a new object. The equivalent operation can be described as such:
5+
An utility to deeply clone objects.
126

137
```js
14-
// it's based on descriptors
15-
Object.defineProperties(
16-
// it preserves inheritance
17-
Object.create(
18-
Object.getPrototypeOf(source)
19-
),
20-
// it does shallow copy
21-
Reflect.ownKeys(source).reduce(function (d, k) {
22-
d[k] = Object.getOwnPropertyDescriptor(source, k);
23-
}, {})
24-
// or Reflect.getOwnPropertyDescriptors(source)
25-
);
26-
```
27-
The `cloner.shallow.copy` utility is most likely what you are looking for instead of the underpowered `Object.assign` one.
28-
29-
#### cloner.shallow.merge(target, source1[, source2, sourceN]):target
30-
Preserves what's already in the `target` and merge all own keys found in one or more passed sources.
31-
```js
32-
var a = {a: 1, b: 2};
33-
var b = cloner.shallow.merge({a: 3}, a);
34-
35-
b; // {a: 3, b: 2}
36-
```
37-
Probably the best option to merge states, ideal for statics or immutable properties.
38-
39-
40-
#### cloner.deep.copy(object):deepCopy
41-
Same as `cloner.shallow.copy` beside the fact every single own key will be deeply copied.
42-
Like its shallow counterpart, it does preserve inheritance and it's **recursion aware**, meaning it shouldn't fail with recursive properties, as already [tested](test/cloner.js).
43-
44-
45-
#### cloner.deep.merge(target, source1[, source2, sourceN]):target
46-
Same as `cloner.shallow.merge` but each new own key will be deeply copied.
47-
48-
49-
### How to use
50-
`npm install cloner` should do, otherwise [grab the file you like the most](build/) in here.
51-
52-
53-
### License
54-
```
55-
Copyright (C) 2015 by Andrea Giammarchi - @WebReflection
56-
57-
Permission is hereby granted, free of charge, to any person obtaining a copy
58-
of this software and associated documentation files (the "Software"), to deal
59-
in the Software without restriction, including without limitation the rights
60-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
61-
copies of the Software, and to permit persons to whom the Software is
62-
furnished to do so, subject to the following conditions:
63-
64-
The above copyright notice and this permission notice shall be included in
65-
all copies or substantial portions of the Software.
66-
67-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
68-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
69-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
70-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
71-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
72-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
73-
THE SOFTWARE.
8+
import cloner from 'cloner';
9+
// const cloner = require('cloner');
10+
// <script src=//unpkg.com/cloner></script>
7411

12+
const target = cloner(source);
7513
```

build/cloner.amd.js

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

build/cloner.js

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

0 commit comments

Comments
 (0)