Skip to content

Commit b1121ef

Browse files
committed
Merge branch feature/example into master
::SUMMARY:: Branch feature/example commits: feat: add methods feat: add dependency Branch master commits: * * * * * * * * * * * * * * * * * * * * * * * * * ::DETAILS:: commit > 4274e7a Author: Hemerson Vianna <hemerson.lourenco@gmail.com> Date: Thu Jul 23 16:33:16 2020 -0300 feat: add methods commit > 096d390 Author: Hemerson Vianna <hemerson.lourenco@gmail.com> Date: Thu Jul 23 15:45:20 2020 -0300 feat: add dependency
2 parents dbf5dfe + 4274e7a commit b1121ef

24 files changed

+2260
-4
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10.15.3
1+
v12.18.2

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
## Prerequisites
1212

13-
- [Node = v10.15.x](https://nodejs.org/en/)
14-
- NPM >= v6.4.x
13+
- [Node = v12.18.x](https://nodejs.org/en/)
14+
- NPM >= v6.14.x
1515
- [Yarn >= v1.22.0](https://yarnpkg.com/en/docs/install#linux-tab) or `npm install -g yarn`
1616

1717
## Log

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@
1919
"devDependencies": {
2020
"release-it": "12.4.3"
2121
},
22-
"dependencies": {}
22+
"dependencies": {
23+
"immutable": "4.0.0-rc.12"
24+
}
2325
}

source/collection.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Collection
2+
3+
// Collection.Keyed
4+
5+
// Collection.Keyed<K, V>(collection: Iterable<[K, V]>): Collection.Keyed<K, V>
6+
// Collection.Keyed<V>(obj: {[key: string]: V}): Collection.Keyed<string, V>
7+
8+
// Collection.Indexed
9+
10+
// Collection.Indexed<T>(collection: Iterable<T>): Collection.Indexed<T>
11+
12+
// Collection.Set
13+
14+
const { Collection } = require('immutable')
15+
const seq = Collection.Set([ 'A', 'B', 'C' ])
16+
// Seq { "A", "B", "C" }
17+
seq.forEach((v, k) =>
18+
assert.equal(v, k)
19+
)

source/from-js.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// fromJS(
2+
// jsValue: any,
3+
// reviver?: (
4+
// key: string | number,
5+
// sequence: Collection.Keyed<string, any> | Collection.Indexed<any>,
6+
// path?: Array<string | number>
7+
// ) => any
8+
// ): any
9+
10+
const { fromJS, isKeyed } = require('immutable')
11+
fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) {
12+
console.log(key, value, path)
13+
return isKeyed(value) ? value.toOrderedMap() : value.toList()
14+
})

source/get.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// get<K, V>(collection: Collection<K, V>, key: K): V | undefined
2+
// get<K, V, NSV>(collection: Collection<K, V>, key: K, notSetValue: NSV): V | NSV
3+
// get<TProps, K>(record: Record<TProps>, key: K, notSetValue: any): TProps[K]
4+
// get<V>(collection: Array<V>, key: number): V | undefined
5+
// get<V, NSV>(collection: Array<V>, key: number, notSetValue: NSV): V | NSV
6+
// get<C, K>(object: C, key: K, notSetValue: any): C[K]
7+
// get<V>(collection: {[key: string]: V}, key: string): V | undefined
8+
// get<V, NSV>(
9+
// collection: {[key: string]: V},
10+
// key: string,
11+
// notSetValue: NSV
12+
// ): V | NSV
13+
14+
const { get } = require("immutable");
15+
get(["dog", "frog", "cat"], 2); // 'frog'
16+
get({ x: 123, y: 456 }, "x"); // 123
17+
get({ x: 123, y: 456 }, "z", "ifNotSet"); // 'ifNotSet'

source/has.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const { has } = require("immutable");
2+
has(["dog", "frog", "cat"], 2); // true
3+
has(["dog", "frog", "cat"], 5); // false
4+
has({ x: 123, y: 456 }, "x"); // true
5+
has({ x: 123, y: 456 }, "z"); // false

source/hash.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// hash(value: any): number

source/in.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// getIn()
2+
3+
const { getIn } = require('immutable')
4+
getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123
5+
getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet'
6+
7+
// hasIn()
8+
9+
const { hasIn } = require('immutable')
10+
hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true
11+
hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false
12+
13+
// removeIn()
14+
15+
const { removeIn } = require('immutable')
16+
const original = { x: { y: { z: 123 }}}
17+
removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}}
18+
console.log(original) // { x: { y: { z: 123 }}}
19+
20+
// setIn()
21+
22+
const { setIn } = require('immutable')
23+
const original = { x: { y: { z: 123 }}}
24+
setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}}
25+
console.log(original) // { x: { y: { z: 123 }}}
26+
27+
// updateIn()
28+
29+
// updateIn<C>(
30+
// collection: C,
31+
// keyPath: Iterable<any>,
32+
// updater: (value: any) => any
33+
// ): C
34+
// updateIn<C>(
35+
// collection: C,
36+
// keyPath: Iterable<any>,
37+
// notSetValue: any,
38+
// updater: (value: any) => any
39+
// ): C
40+
41+
const { updateIn } = require('immutable')
42+
const original = { x: { y: { z: 123 }}}
43+
updateIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}}
44+
console.log(original) // { x: { y: { z: 123 }}}

source/is.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// is
2+
3+
const { Map, is } = require('immutable')
4+
const map1 = Map({ a: 1, b: 1, c: 1 })
5+
const map2 = Map({ a: 1, b: 1, c: 1 })
6+
assert.equal(map1 !== map2, true)
7+
assert.equal(Object.is(map1, map2), false)
8+
assert.equal(is(map1, map2), true)
9+
10+
// isImmutable()
11+
12+
const { isImmutable, Map, List, Stack } = require('immutable');
13+
isImmutable([]); // false
14+
isImmutable({}); // false
15+
isImmutable(Map()); // true
16+
isImmutable(List()); // true
17+
isImmutable(Stack()); // true
18+
isImmutable(Map().asMutable()); // true
19+
20+
// isCollection()
21+
22+
const { isCollection, Map, List, Stack } = require('immutable');
23+
isCollection([]); // false
24+
isCollection({}); // false
25+
isCollection(Map()); // true
26+
isCollection(List()); // true
27+
isCollection(Stack()); // true
28+
29+
// isKeyed()
30+
31+
const { isKeyed, Map, List, Stack } = require('immutable');
32+
isKeyed([]); // false
33+
isKeyed({}); // false
34+
isKeyed(Map()); // true
35+
isKeyed(List()); // false
36+
isKeyed(Stack()); // false
37+
38+
// isIndexed()
39+
40+
const { isIndexed, Map, List, Stack, Set } = require('immutable');
41+
isIndexed([]); // false
42+
isIndexed({}); // false
43+
isIndexed(Map()); // false
44+
isIndexed(List()); // true
45+
isIndexed(Stack()); // true
46+
isIndexed(Set()); // false
47+
48+
// isAssociative()
49+
50+
const { isAssociative, Map, List, Stack, Set } = require('immutable');
51+
isAssociative([]); // false
52+
isAssociative({}); // false
53+
isAssociative(Map()); // true
54+
isAssociative(List()); // true
55+
isAssociative(Stack()); // true
56+
isAssociative(Set()); // false
57+
58+
// isOrdered()
59+
60+
const { isOrdered, Map, OrderedMap, List, Set } = require('immutable');
61+
isOrdered([]); // false
62+
isOrdered({}); // false
63+
isOrdered(Map()); // false
64+
isOrdered(OrderedMap()); // true
65+
isOrdered(List()); // true
66+
isOrdered(Set()); // false
67+
68+
// isValueObject()
69+
// isSeq()
70+
// isList()
71+
// isMap()
72+
// isOrderedMap()
73+
// isStack()
74+
// isSet()
75+
// isOrderedSet()
76+
// isRecord()
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
89+
90+
91+
92+
93+
94+
95+
96+
97+
98+
99+
100+
101+
102+

0 commit comments

Comments
 (0)