deno.land / x / rambda@v9.1.1 / src / _internals / set.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { _indexOf } from '../equals.js'import { type as typeMethod } from '../type.js'
export class _Set{ constructor(){ this.set = new Set() this.items = {} }
checkUniqueness(item){ const type = typeMethod(item) if ([ 'Null', 'Undefined', 'NaN' ].includes(type)){ if (type in this.items){ return false } this.items[ type ] = true
return true } if (![ 'Object', 'Array' ].includes(type)){ const prevSize = this.set.size this.set.add(item)
return this.set.size !== prevSize }
if (!(type in this.items)){ this.items[ type ] = [ item ]
return true }
if (_indexOf(item, this.items[ type ]) === -1){ this.items[ type ].push(item)
return true }
return false }}
rambda

Version Info

Tagged at
a year ago