-
Notifications
You must be signed in to change notification settings - Fork 0
/
Set.cljs
142 lines (97 loc) · 3.61 KB
/
Set.cljs
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
(ns js.Set
"The Set object lets you store unique values of any type, whether
values or object references."
(:refer-clojure :exclude []))
(defn add
"Method.
The add() method appends a new element with a specified value
the end of a Set object.
`mySet.add(value);`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add`"
[this value]
(-> this (.add value)))
(defn clear
"Method.
The clear() method removes all elements from a Set object.
`mySet.clear();`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear`"
[this ]
(-> this (.clear)))
(defn delete
"Method.
The delete() method removes the specified element from a Set
`mySet.delete(value);`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete`"
[this value]
(-> this (.delete value)))
(defn entries
"Method.
The entries() method returns a new Iterator object that contains
array of [value, value] for each element in the Set object, in
order. For Set objects there is no key like in Map objects. However,
keep the API similar to the Map object, each entry has the same
for its key and value here, so that an array [value, value] is
`mySet.entries()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries`"
[this ]
(-> this (.entries)))
(defn for-each
"Method.
The forEach() method executes a provided function once for each
in the Set object, in insertion order.
`mySet.forEach(callback[, thisArg])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach`"
[this & args]
(-> this .-forEach (.apply this (clj->js args))))
(defn has
"Method.
The has() method returns a boolean indicating whether an element
the specified value exists in a Set object or not.
`mySet.has(value);`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has`"
[this value]
(-> this (.has value)))
(defn values
"Method.
The values() method returns a new Iterator object that contains
values for each element in the Set object in insertion order.
`mySet.values();`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values`"
[this ]
(-> this (.values)))
(defn length
"Property.
The value of the length property is 0."
[this]
(-> this (.-length)))
(defn set-length!
"Property.
The value of the length property is 0."
[this val]
(aset this "length" val))
(defn prototype
"Property.
The Set.prototype property represents the prototype for the `js.Set`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/prototype`"
[this]
(-> this (.-prototype)))
(defn set-prototype!
"Property.
The Set.prototype property represents the prototype for the `js.Set`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/prototype`"
[this val]
(aset this "prototype" val))
(defn size
"Property.
The size accessor property returns the number of (unique) elements
a `js.Set` object.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/size`"
[this]
(-> this (.-size)))
(defn set-size!
"Property.
The size accessor property returns the number of (unique) elements
a `js.Set` object.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/size`"
[this val]
(aset this "size" val))