Skip to content

Commit ece8885

Browse files
authored
Merge pull request #32 from yeikos/develop
v2.0.0
2 parents b31e67f + 43ffa43 commit ece8885

File tree

294 files changed

+5873
-29946
lines changed

Some content is hidden

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

294 files changed

+5873
-29946
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[{*.ts,*.md,*.html,*.json,webpack.config.js}]
4+
end_of_line = lf
5+
charset = utf-8
6+
indent_style = tab
7+
indent_size = 4
8+
9+
[package-lock.json]
10+
indent_style = space
11+
indent_size = 2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.npmignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

LICENSE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 yeikos
4-
53
Permission is hereby granted, free of charge, to any person obtaining a copy
64
of this software and associated documentation files (the "Software"), to deal
75
in the Software without restriction, including without limitation the rights

README.md

Lines changed: 58 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,84 @@
11
# Merge
22

3-
Merge multiple objects into one, optionally creating a new cloned object.
4-
Similar to the jQuery.extend but more flexible. Works in Node.js and the
5-
browser.
3+
(recursive)? merging of (cloned)? objects.
64

7-
## Node.js Usage
5+
# Install
6+
7+
## Node.js
88

99
```sh
10-
npm install merge --save
10+
npm i merge
11+
```
12+
```js
13+
import merge from 'merge'
1114
```
1215

16+
## Browser
17+
18+
```html
19+
<script src="https://cdn.jsdelivr.net/gh/yeikos/js.merge/dist/merge.browser.min.js"></script>
20+
```
1321
```js
14-
var merge = require('merge'), original, cloned;
22+
window.merge
23+
```
1524

16-
console.log(merge({one:'hello'}, {two: 'world'}));
17-
// -> {"one": "hello", "two": "world"}
25+
# API
1826

19-
original = { x: { y: 1 } };
20-
cloned = merge(true, original);
21-
cloned.x.y++;
27+
```typescript
28+
merge(clone: boolean, ...items: Object[])
29+
merge(...items: Object[])
30+
merge.recursive(clone: boolean, ...items: Object[])
31+
merge.recursive(...items: Object[])
32+
```
2233

23-
console.log(original.x.y, cloned.x.y);
24-
// -> 1, 2
34+
# Examples
2535

26-
console.log(merge.recursive(true, original, { x: { z: 2 } }));
27-
// -> {"x": { "y": 1, "z": 2 } }
36+
```js
2837

29-
```
38+
// Merge
3039

31-
## Browser Usage
40+
{
41+
var objectA = {}
3242

33-
```html
34-
<script src="https://cdn.jsdelivr.net/gh/yeikos/js.merge/merge.js"></script>
35-
<script>
36-
var original, cloned;
43+
merge(objectA,
44+
{ value: 1 },
45+
{ str: 'hello world' }
46+
)
3747

38-
console.log(merge({one:'hello'}, {two: 'world'}));
39-
// -> {"one": "hello", "two": "world"}
48+
var objectB = merge(true, objectA,
49+
{ value: 2 }
50+
)
4051

41-
original = { x: { y: 1 } };
42-
cloned = merge(true, original);
43-
cloned.x.y++;
52+
objectA // { value: 1, str: 'hello world' }
53+
objectB // { value: 2, str: 'hello world' }
54+
}
4455

45-
console.log(original.x.y, cloned.x.y);
46-
// -> 1, 2
56+
// Recursive merge
4757

48-
console.log(merge.recursive(true, original, { x: { z: 2 } }));
49-
// -> {"x": { "y": 1, "z": 2 } }
58+
{
59+
var objectA = {}
5060

51-
</script>
61+
merge.recursive(objectA,
62+
{ level: { value: 1 } },
63+
{ level: { str: 'hello world' } }
64+
)
65+
var objectB = merge.recursive(true, objectA,
66+
{ level: { value: 2 } }
67+
)
68+
69+
objectA.level // { value: 1, str: 'hello world' }
70+
objectB.level // { value: 2, str: 'hello world' }
71+
}
5272
```
73+
# Test
5374

54-
## Tests
75+
## Node.js
5576

5677
```sh
5778
npm test
5879
```
80+
## Browser
81+
82+
```
83+
./dist/merge.browser.test.html
84+
```

bower.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
2-
"name": "merge",
3-
"version": "1.2.1",
4-
"homepage": "https://github.com/yeikos/js.merge",
5-
"authors": [
6-
"yeikos <yeikos@gmail.com>"
7-
],
8-
"description": "Merge multiple objects into one, optionally creating a new cloned object. Similar to the jQuery.extend but more flexible. Works in Node.js and the browser.",
9-
"main": "merge.js",
10-
"keywords": [
11-
"merge",
12-
"recursive",
13-
"extend",
14-
"clone",
15-
"object",
16-
"browser"
17-
],
18-
"license": "MIT",
19-
"ignore": [
20-
"tests"
21-
]
22-
}
2+
"name": "merge",
3+
"version": "1.2.1",
4+
"homepage": "https://github.com/yeikos/js.merge",
5+
"authors": [
6+
"yeikos"
7+
],
8+
"description": "(recursive)? merging of (cloned)? objects.",
9+
"main": "dist/merge.browser.min.js",
10+
"keywords": [
11+
"merge",
12+
"recursive",
13+
"extend",
14+
"clone",
15+
"object",
16+
"browser"
17+
],
18+
"license": "MIT",
19+
"ignore": [
20+
"tests"
21+
]
22+
}

dist/merge.browser.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/merge.browser.test.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Mocha Tests</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
8+
</head>
9+
<body>
10+
<div id="mocha"></div>
11+
<script src="../node_modules/chai/chai.js"></script>
12+
<script src="../node_modules/mocha/mocha.js"></script>
13+
<script class="mocha-init">
14+
mocha.setup('bdd');
15+
mocha.checkLeaks();
16+
</script>
17+
<script src="./merge.browser.min.js"></script>
18+
<script src="./merge.browser.test.js"></script>
19+
<script class="mocha-exec">
20+
mocha.run();
21+
</script>
22+
</body>
23+
</html>

0 commit comments

Comments
 (0)