1.0.0 • Published 7 years ago

setk v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

setk

Set 对象允许你存储任何类型的唯一值,无论是原始值或者是对象引用。——MDN

const Set = require('setk')

let set = new Set(['anything','you','want']) //{setObj:['anything','you','want']}

set.contains('anything') //return true

set.empty() //return false

set.size() //return 3

set.get() //return ['anything','you','want']

set.add(['something','else']) //return ['anything','you','want','something','else']

set.remove('something','else') //or set.remove(['something','else']) return ['anything','you','want']

set.clear() //return []

let anotherSet = new Set(['another','set'])
set.union(anotherSet) //return ['anything','you','want','another','set']
console.log(set) //['anything','you','want']

set.find(/anything/) //or set.find('anything') return ['anything']

包含的内置方法

* set.contains 参数为一个值,返回值为参数是否在当前Set中.

* set.empty 返回当前的Set对象是否为空.

* set.size 返回Set对象的length.

* set.get 将Set对象以数组形式返回.

* set.add 将一个值添加到Set对象的最后.

* set.remove 参数为数组或多个值,从Set对象中移除值.

* set.clear 清空Set对象.

* set.union 参数为另一个Set对象,返回值为另一个Set对象与当前Set对象结合后的新对象.

* set.find 参数为一个正则表达式,返回值为表达式测试通过的值的集合.
1.0.0

7 years ago

0.1.0

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago