Skip to content

Commit fd136e5

Browse files
committed
Bump version.
1 parent dd52ee8 commit fd136e5

4 files changed

Lines changed: 32 additions & 32 deletions

File tree

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,16 @@ Returns the value for the specified *key* string. If the map does not have an en
273273

274274
<a name="map_set" href="#map_set">#</a> <i>map</i>.<b>set</b>(<i>key</i>, <i>value</i>)
275275

276-
Sets the *value* for the specified *key* string. If the map previously had an entry for the same *key* string, the old entry is replaced with the new value. Returns the map, allowing chaining.
276+
Sets the *value* for the specified *key* string. If the map previously had an entry for the same *key* string, the old entry is replaced with the new value. Returns the map, allowing chaining. For example:
277+
278+
```js
279+
var m = map()
280+
.set("foo", 1)
281+
.set("bar", 2)
282+
.set("baz", 3);
283+
284+
m.get("foo"); // 1
285+
```
277286

278287
<a name="map_remove" href="#map_remove">#</a> <i>map</i>.<b>remove</b>(<i>key</i>)
279288

@@ -326,7 +335,16 @@ Returns true if and only if this set has an entry for the specified *value* stri
326335

327336
<a name="set_add" href="#set_add">#</a> <i>set</i>.<b>add</b>(<i>value</i>)
328337

329-
Adds the specified *value* string to this set. Returns the set, allowing chaining.
338+
Adds the specified *value* string to this set. Returns the set, allowing chaining. For example:
339+
340+
```js
341+
var s = set()
342+
.add("foo")
343+
.add("bar")
344+
.add("baz");
345+
346+
s.has("foo"); // true
347+
```
330348

331349
<a name="set_remove" href="#set_remove">#</a> <i>set</i>.<b>remove</b>(<i>value</i>)
332350

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "d3-arrays",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"description": "Array manipulation, ordering, searching, summarizing, etc.",
55
"keywords": [
66
"d3",

test/map-test.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ tape("map.size() returns the number of distinct keys", function(test) {
9292
});
9393

9494
tape("map.clear() removes all entries", function(test) {
95-
var m = arrays.map();
96-
m.set("foo", 1);
97-
m.set("bar", 2);
98-
m.set("foo", 3);
95+
var m = arrays.map().set("foo", 1).set("bar", 2).set("foo", 3);
96+
test.equal(m.size(), 2);
9997
m.clear();
10098
test.equal(m.size(), 0);
10199
test.deepEqual(m.entries(), []);
@@ -159,9 +157,7 @@ tape("map.keys() returns an array of string keys", function(test) {
159157
});
160158

161159
tape("map.keys() properly unescapes zero-prefixed keys", function(test) {
162-
var m = arrays.map();
163-
m.set("__proto__", 42);
164-
m.set("$weird", 42);
160+
var m = arrays.map().set("__proto__", 42).set("$weird", 42);
165161
test.deepEqual(m.keys().sort(), ["$weird", "__proto__"]);
166162
test.end();
167163
});
@@ -222,17 +218,13 @@ tape("map.has(key) empty maps do not have object built-ins", function(test) {
222218
});
223219

224220
tape("map.has(key) can has keys using built-in names", function(test) {
225-
var m = arrays.map();
226-
m.set("__proto__", 42);
221+
var m = arrays.map().set("__proto__", 42);
227222
test.equal(m.has("__proto__"), true);
228223
test.end();
229224
});
230225

231226
tape("map.has(key) can has keys with null or undefined properties", function(test) {
232-
var m = arrays.map();
233-
m.set("", "");
234-
m.set("null", null);
235-
m.set("undefined", undefined);
227+
var m = arrays.map().set("", "").set("null", null).set("undefined", undefined);
236228
test.equal(m.has(""), true);
237229
test.equal(m.has("null"), true);
238230
test.equal(m.has("undefined"), true);
@@ -348,10 +340,7 @@ tape("map.set(key, value) can replace values", function(test) {
348340
});
349341

350342
tape("map.set(key, value) can set null, undefined or empty string values", function(test) {
351-
var m = arrays.map();
352-
m.set("", "");
353-
m.set("null", null);
354-
m.set("undefined", undefined);
343+
var m = arrays.map().set("", "").set("null", null).set("undefined", undefined);
355344
test.equal(m.get(""), "");
356345
test.equal(m.get("null"), null);
357346
test.equal(m.get("undefined"), undefined);

test/set-test.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ tape("set.size() returns the number of distinct values", function(test) {
5252
});
5353

5454
tape("set.clear() removes all values", function(test) {
55-
var s = arrays.set();
56-
s.add("foo");
57-
s.add("bar");
58-
s.add("foo");
55+
var s = arrays.set().add("foo").add("bar").add("foo");
56+
test.equal(s.size(), 2);
5957
s.clear();
6058
test.equal(s.size(), 0);
6159
test.deepEqual(s.values(), []);
@@ -202,15 +200,13 @@ tape("set.add(value) returns the set", function(test) {
202200
});
203201

204202
tape("set.add(value) can add values using built-in names", function(test) {
205-
var s = arrays.set();
206-
s.add("__proto__");
203+
var s = arrays.set().add("__proto__");
207204
test.equal(s.has("__proto__"), true);
208205
test.end();
209206
});
210207

211208
tape("set.add(value) can add values using zero-prefixed names", function(test) {
212-
var s = arrays.set();
213-
s.add("$weird");
209+
var s = arrays.set().add("$weird");
214210
test.equal(s.has("$weird"), true);
215211
test.end();
216212
});
@@ -228,10 +224,7 @@ tape("set.add(value) coerces values to strings", function(test) {
228224
});
229225

230226
tape("set.add(value) can add null, undefined or empty string values", function(test) {
231-
var s = arrays.set();
232-
s.add("");
233-
s.add("null");
234-
s.add("undefined");
227+
var s = arrays.set().add("").add("null").add("undefined");
235228
test.equal(s.has(""), true);
236229
test.equal(s.has("null"), true);
237230
test.equal(s.has("undefined"), true);

0 commit comments

Comments
 (0)