package.json 21.9 KB
Newer Older
Muddsair Sharif's avatar
Muddsair Sharif committed
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
{
  "_args": [
    [
      {
        "raw": "d3-collection@1.0.3",
        "scope": null,
        "escapedName": "d3-collection",
        "name": "d3-collection",
        "rawSpec": "1.0.3",
        "spec": "1.0.3",
        "type": "version"
      },
      "C:\\Users\\Giuliano\\worldwind\\nasaworldwind\\node\\node_modules\\d3"
    ]
  ],
  "_from": "d3-collection@1.0.3",
  "_id": "d3-collection@1.0.3",
  "_inCache": true,
  "_location": "/d3-collection",
  "_nodeVersion": "7.3.0",
  "_npmOperationalInternal": {
    "host": "packages-12-west.internal.npmjs.com",
    "tmp": "tmp/d3-collection-1.0.3.tgz_1489169626030_0.7458085720427334"
  },
  "_npmUser": {
    "name": "mbostock",
    "email": "mike@ocks.org"
  },
  "_npmVersion": "3.10.10",
  "_phantomChildren": {},
  "_requested": {
    "raw": "d3-collection@1.0.3",
    "scope": null,
    "escapedName": "d3-collection",
    "name": "d3-collection",
    "rawSpec": "1.0.3",
    "spec": "1.0.3",
    "type": "version"
  },
  "_requiredBy": [
    "/d3",
    "/d3-force",
    "/d3-request",
    "/d3-scale"
  ],
  "_resolved": "https://registry.npmjs.org/d3-collection/-/d3-collection-1.0.3.tgz",
  "_shasum": "00bdea94fbc1628d435abbae2f4dc2164e37dd34",
  "_shrinkwrap": null,
  "_spec": "d3-collection@1.0.3",
  "_where": "C:\\Users\\Giuliano\\worldwind\\nasaworldwind\\node\\node_modules\\d3",
  "author": {
    "name": "Mike Bostock",
    "url": "http://bost.ocks.org/mike"
  },
  "bugs": {
    "url": "https://github.com/d3/d3-collection/issues"
  },
  "dependencies": {},
  "description": "Handy data structures for elements keyed by string.",
  "devDependencies": {
    "d3-array": "1",
    "eslint": "3",
    "package-preamble": "0.0",
    "rollup": "0.41",
    "tape": "4",
    "uglify-js": "^2.8.11"
  },
  "directories": {},
  "dist": {
    "shasum": "00bdea94fbc1628d435abbae2f4dc2164e37dd34",
    "tarball": "https://registry.npmjs.org/d3-collection/-/d3-collection-1.0.3.tgz"
  },
  "gitHead": "110d0daf1c1773fc268bd5f7808fe08b186d953f",
  "homepage": "https://d3js.org/d3-collection/",
  "jsnext:main": "index",
  "keywords": [
    "d3",
    "d3-module",
    "nest",
    "data",
    "map",
    "set",
    "object",
    "collection"
  ],
  "license": "BSD-3-Clause",
  "main": "build/d3-collection.js",
  "maintainers": [
    {
      "name": "mbostock",
      "email": "mike@ocks.org"
    }
  ],
  "module": "index",
  "name": "d3-collection",
  "optionalDependencies": {},
  "readme": "# d3-collection\n\nHandy data structures for elements keyed by string.\n\n## Installing\n\nIf you use NPM, `npm install d3-collection`. Otherwise, download the [latest release](https://github.com/d3/d3-collection/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-collection.v1.min.js) or as part of [D3 4.0](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:\n\n```html\n<script src=\"https://d3js.org/d3-collection.v1.min.js\"></script>\n<script>\n\nvar map = d3.map()\n    .set(\"foo\", 1)\n    .set(\"bar\", 2);\n\n</script>\n```\n\n[Try d3-collection in your browser.](https://tonicdev.com/npm/d3-collection)\n\n## API Reference\n\n* [Objects](#objects)\n* [Maps](#maps)\n* [Sets](#sets)\n* [Nests](#nests)\n\n### Objects\n\nA common data type in JavaScript is the *associative array*, or more simply the *object*, which has a set of named properties. The standard mechanism for iterating over the keys (or property names) in an associative array is the [for…in loop](https://developer.mozilla.org/en/JavaScript/Reference/Statements/for...in). However, note that the iteration order is undefined. D3 provides several methods for converting associative arrays to standard arrays with numeric indexes.\n\nA word of caution: it is tempting to use plain objects as maps, but this causes [unexpected behavior](http://www.devthought.com/2012/01/18/an-object-is-not-a-hash/) when built-in property names are used as keys, such as `object[\"__proto__\"] = 42` and `\"hasOwnProperty\" in object`. If you cannot guarantee that map keys and set values will be safe, use [maps](#maps) and [sets](#sets) (or their ES6 equivalents) instead of plain objects.\n\n<a name=\"keys\" href=\"#keys\">#</a> d3.<b>keys</b>(<i>object</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/keys.js \"Source\")\n\nReturns an array containing the property names of the specified object (an associative array). The order of the returned array is undefined.\n\n<a name=\"values\" href=\"#values\">#</a> d3.<b>values</b>(<i>object</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/values.js \"Source\")\n\nReturns an array containing the property values of the specified object (an associative array). The order of the returned array is undefined.\n\n<a name=\"entries\" href=\"#entries\">#</a> d3.<b>entries</b>(<i>object</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/entries.js \"Source\")\n\nReturns an array containing the property keys and values of the specified object (an associative array). Each entry is an object with a key and value attribute, such as `{key: \"foo\", value: 42}`. The order of the returned array is undefined.\n\n```js\nd3.entries({foo: 42, bar: true}); // [{key: \"foo\", value: 42}, {key: \"bar\", value: true}]\n```\n\n### Maps\n\nLike [ES6 Maps](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map), but with a few differences:\n\n* Keys are coerced to strings.\n* [map.each](#map_each), not [map.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach). (Also, no *thisArg*.)\n* [map.remove](#map_remove), not [map.delete](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete).\n* [map.entries](#map_entries) returns an array of {key, value} objects, not an iterator of [key, value].\n* [map.size](#map_size) is a method, not a [property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size); also, there’s [map.empty](#map_empty).\n\n<a name=\"map\" href=\"#map\">#</a> d3.<b>map</b>([<i>object</i>[, <i>key</i>]]) [<>](https://github.com/d3/d3-collection/blob/master/src/map.js \"Source\")\n\nConstructs a new map. If *object* is specified, copies all enumerable properties from the specified object into this map. The specified object may also be an array or another map. An optional *key* function may be specified to compute the key for each value in the array. For example:\n\n```js\nvar map = d3.map([{name: \"foo\"}, {name: \"bar\"}], function(d) { return d.name; });\nmap.get(\"foo\"); // {\"name\": \"foo\"}\nmap.get(\"bar\"); // {\"name\": \"bar\"}\nmap.get(\"baz\"); // undefined\n```\n\nSee also [nests](#nests).\n\n<a name=\"map_has\" href=\"#map_has\">#</a> <i>map</i>.<b>has</b>(<i>key</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/map.js#L7 \"Source\")\n\nReturns true if and only if this map has an entry for the specified *key* string. Note: the value may be `null` or `undefined`.\n\n<a name=\"map_get\" href=\"#map_get\">#</a> <i>map</i>.<b>get</b>(<i>key</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/map.js#L10 \"Source\")\n\nReturns the value for the specified *key* string. If the map does not have an entry for the specified *key*, returns `undefined`.\n\n<a name=\"map_set\" href=\"#map_set\">#</a> <i>map</i>.<b>set</b>(<i>key</i>, <i>value</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/map.js#L13 \"Source\")\n\nSets 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:\n\n```js\nvar map = d3.map()\n    .set(\"foo\", 1)\n    .set(\"bar\", 2)\n    .set(\"baz\", 3);\n\nmap.get(\"foo\"); // 1\n```\n\n<a name=\"map_remove\" href=\"#map_remove\">#</a> <i>map</i>.<b>remove</b>(<i>key</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/map.js#L17 \"Source\")\n\nIf the map has an entry for the specified *key* string, removes the entry and returns true. Otherwise, this method does nothing and returns false.\n\n<a name=\"map_clear\" href=\"#map_clear\">#</a> <i>map</i>.<b>clear</b>() [<>](https://github.com/d3/d3-collection/blob/master/src/map.js#L21 \"Source\")\n\nRemoves all entries from this map.\n\n<a name=\"map_keys\" href=\"#map_keys\">#</a> <i>map</i>.<b>keys</b>() [<>](https://github.com/d3/d3-collection/blob/master/src/map.js#L24 \"Source\")\n\nReturns an array of string keys for every entry in this map. The order of the returned keys is arbitrary.\n\n<a name=\"map_values\" href=\"#map_values\">#</a> <i>map</i>.<b>values</b>() [<>](https://github.com/d3/d3-collection/blob/master/src/map.js#L29 \"Source\")\n\nReturns an array of values for every entry in this map. The order of the returned values is arbitrary.\n\n<a name=\"map_entries\" href=\"#map_entries\">#</a> <i>map</i>.<b>entries</b>() [<>](https://github.com/d3/d3-collection/blob/master/src/map.js#L34 \"Source\")\n\nReturns an array of key-value objects for each entry in this map. The order of the returned entries is arbitrary. Each entry’s key is a string, but the value has arbitrary type.\n\n<a name=\"map_each\" href=\"#map_each\">#</a> <i>map</i>.<b>each</b>(<i>function</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/map.js#L48 \"Source\")\n\nCalls the specified *function* for each entry in this map, passing the entry’s value and key as arguments, followed by the map itself. Returns undefined. The iteration order is arbitrary.\n\n<a name=\"map_empty\" href=\"#map_empty\">#</a> <i>map</i>.<b>empty</b>() [<>](https://github.com/d3/d3-collection/blob/master/src/map.js#L44 \"Source\")\n\nReturns true if and only if this map has zero entries.\n\n<a name=\"map_size\" href=\"#map_size\">#</a> <i>map</i>.<b>size</b>() [<>](https://github.com/d3/d3-collection/blob/master/src/map.js#L39 \"Source\")\n\nReturns the number of entries in this map.\n\n### Sets\n\nLike [ES6 Sets](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set), but with a few differences:\n\n* Values are coerced to strings.\n* [set.each](#set_each), not [set.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/forEach). (Also, no *thisArg*.)\n* [set.remove](#set_remove), not [set.delete](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete).\n* [set.size](#set_size) is a method, not a [property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/size); also, there’s [set.empty](#set_empty).\n\n<a name=\"set\" href=\"#set\">#</a> d3.<b>set</b>([<i>array</i>[, <i>accessor</i>]]) [<>](https://github.com/d3/d3-collection/blob/master/src/set.js \"Source\")\n\nConstructs a new set. If *array* is specified, adds the given *array* of string values to the returned set. The specified array may also be another set. An optional *accessor* function may be specified, which is equivalent to calling *array.map(accessor)* before constructing the set.\n\n<a name=\"set_has\" href=\"#set_has\">#</a> <i>set</i>.<b>has</b>(<i>value</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/set.js#L9 \"Source\")\n\nReturns true if and only if this set has an entry for the specified *value* string.\n\n<a name=\"set_add\" href=\"#set_add\">#</a> <i>set</i>.<b>add</b>(<i>value</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/set.js#L10 \"Source\")\n\nAdds the specified *value* string to this set. Returns the set, allowing chaining. For example:\n\n```js\nvar set = d3.set()\n    .add(\"foo\")\n    .add(\"bar\")\n    .add(\"baz\");\n\nset.has(\"foo\"); // true\n```\n\n<a name=\"set_remove\" href=\"#set_remove\">#</a> <i>set</i>.<b>remove</b>(<i>value</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/set.js#L15 \"Source\")\n\nIf the set contains the specified *value* string, removes it and returns true. Otherwise, this method does nothing and returns false.\n\n<a name=\"set_clear\" href=\"#set_clear\">#</a> <i>set</i>.<b>clear</b>() [<>](https://github.com/d3/d3-collection/blob/master/src/set.js#L16 \"Source\")\n\nRemoves all values from this set.\n\n<a name=\"set_values\" href=\"#set_values\">#</a> <i>set</i>.<b>values</b>() [<>](https://github.com/d3/d3-collection/blob/master/src/set.js#L17 \"Source\")\n\nReturns an array of the string values in this set. The order of the returned values is arbitrary. Can be used as a convenient way of computing the unique values for a set of strings. For example:\n\n```js\nd3.set([\"foo\", \"bar\", \"foo\", \"baz\"]).values(); // \"foo\", \"bar\", \"baz\"\n```\n\n<a name=\"set_each\" href=\"#set_each\">#</a> <i>set</i>.<b>each</b>(<i>function</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/set.js#L20 \"Source\")\n\nCalls the specified *function* for each value in this set, passing the value as the first two arguments (for symmetry with [*map*.each](#map_each)), followed by the set itself. Returns undefined. The iteration order is arbitrary.\n\n<a name=\"set_empty\" href=\"#set_empty\">#</a> <i>set</i>.<b>empty</b>() [<>](https://github.com/d3/d3-collection/blob/master/src/set.js#L19 \"Source\")\n\nReturns true if and only if this set has zero values.\n\n<a name=\"set_size\" href=\"#set_size\">#</a> <i>set</i>.<b>size</b>() [<>](https://github.com/d3/d3-collection/blob/master/src/set.js#L18 \"Source\")\n\nReturns the number of values in this set.\n\n### Nests\n\nNesting allows elements in an array to be grouped into a hierarchical tree structure; think of it like the GROUP BY operator in SQL, except you can have multiple levels of grouping, and the resulting output is a tree rather than a flat table. The levels in the tree are specified by key functions. The leaf nodes of the tree can be sorted by value, while the internal nodes can be sorted by key. An optional rollup function will collapse the elements in each leaf node using a summary function. The nest operator (the object returned by [nest](#nest)) is reusable, and does not retain any references to the data that is nested.\n\nFor example, consider the following tabular data structure of Barley yields, from various sites in Minnesota during 1931-2:\n\n```js\nvar yields = [\n  {yield: 27.00, variety: \"Manchuria\", year: 1931, site: \"University Farm\"},\n  {yield: 48.87, variety: \"Manchuria\", year: 1931, site: \"Waseca\"},\n  {yield: 27.43, variety: \"Manchuria\", year: 1931, site: \"Morris\"},\n  ...\n];\n```\n\nTo facilitate visualization, it may be useful to nest the elements first by year, and then by variety, as follows:\n\n```js\nvar entries = d3.nest()\n    .key(function(d) { return d.year; })\n    .key(function(d) { return d.variety; })\n    .entries(yields);\n```\n\nThis returns a nested array. Each element of the outer array is a key-values pair, listing the values for each distinct key:\n\n```js\n[{key: \"1931\", values: [\n   {key: \"Manchuria\", values: [\n     {yield: 27.00, variety: \"Manchuria\", year: 1931, site: \"University Farm\"},\n     {yield: 48.87, variety: \"Manchuria\", year: 1931, site: \"Waseca\"},\n     {yield: 27.43, variety: \"Manchuria\", year: 1931, site: \"Morris\"}, ...]},\n   {key: \"Glabron\", values: [\n     {yield: 43.07, variety: \"Glabron\", year: 1931, site: \"University Farm\"},\n     {yield: 55.20, variety: \"Glabron\", year: 1931, site: \"Waseca\"}, ...]}, ...]},\n {key: \"1932\", values: ...}]\n```\n\nThe nested form allows easy iteration and generation of hierarchical structures in SVG or HTML.\n\nFor a longer introduction to nesting, see:\n\n* Phoebe Bright’s [D3 Nest Tutorial and examples](http://bl.ocks.org/phoebebright/raw/3176159/)\n* Shan Carter’s [Mister Nester](http://bl.ocks.org/shancarter/raw/4748131/)\n\n<a name=\"nest\" href=\"#nest\">#</a> d3.<b>nest</b>() [<>](https://github.com/d3/d3-collection/blob/master/src/nest.js \"Source\")\n\nCreates a new nest operator. The set of keys is initially empty.\n\n<a name=\"nest_key\" href=\"#nest_key\">#</a> <i>nest</i>.<b>key</b>(<i>key</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/nest.js#L4 \"Source\")\n\nRegisters a new *key* function. The *key* function will be invoked for each element in the input array and must return a string identifier to assign the element to its group. Most often, the function is a simple accessor, such as the year and variety accessors above. (Keys functions are *not* passed the input array index.) Each time a key is registered, it is pushed onto the end of the internal array of keys, and the nest operator applies an additional level of nesting.\n\n<a name=\"nest_sortKeys\" href=\"#nest_sortKeys\">#</a> <i>nest</i>.<b>sortKeys</b>(<i>comparator</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/nest.js#L5 \"Source\")\n\nSorts key values for the [current key](#nest_key) using the specified *comparator* function, such as [d3.ascending](https://github.com/d3/d3-array#ascending) or [d3.descending](https://github.com/d3/d3-array#descending). If no comparator is specified for the current key, the order in which keys will be returned is undefined. For example, to sort years in ascending order and varieties in descending order:\n\n```js\nvar entries = d3.nest()\n    .key(function(d) { return d.year; }).sortKeys(d3.ascending)\n    .key(function(d) { return d.variety; }).sortKeys(d3.descending)\n    .entries(yields);\n```\n\nNote that this only affects the result of [*nest*.entries](#nest_entries); the order of keys returned by [*nest*.map](#nest_map) and [*nest*.object](#nest_object) is always undefined, regardless of comparator.\n\n<a name=\"nest_sortValues\" href=\"#nest_sortValues\">#</a> <i>nest</i>.<b>sortValues</b>(<i>comparator</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/nest.js#L6 \"Source\")\n\nSorts leaf elements using the specified *comparator* function, such as [d3.ascending](https://github.com/d3/d3-array#ascending) or [d3.descending](https://github.com/d3/d3-array#descending). This is roughly equivalent to sorting the input array before applying the nest operator; however it is typically more efficient as the size of each group is smaller. If no value comparator is specified, elements will be returned in the order they appeared in the input array. This applies to [*nest*.map](#nest_map), [*nest*.entries](#nest_entries) and [*nest*.object](#nest_object).\n\n<a name=\"nest_rollup\" href=\"#nest_rollup\">#</a> <i>nest</i>.<b>rollup</b>(<i>function</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/nest.js#L7 \"Source\")\n\nSpecifies a rollup *function* to be applied on each group of leaf elements. The return value of the rollup function will replace the array of leaf values in either the associative array returned by [*nest*.map](#nest_map) or [*nest*.object](#nest_object); for [*nest*.entries](#nest_entries), it replaces the leaf *entry*.values with *entry*.value.\n\n<a name=\"nest_map\" href=\"#nest_map\">#</a> <i>nest</i>.<b>map</b>(<i>array</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/nest.js#L50 \"Source\")\n\nApplies the nest operator to the specified *array*, returning a nested [map](#map). Each entry in the returned map corresponds to a distinct key value returned by the first key function. The entry value depends on the number of registered key functions: if there is an additional key, the value is another map; otherwise, the value is the array of elements filtered from the input *array* that have the given key value. If no keys are defined, returns the input *array*.\n\n<a name=\"nest_object\" href=\"#nest_object\">#</a> <i>nest</i>.<b>object</b>(<i>array</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/nest.js#L49 \"Source\")\n\nApplies the nest operator to the specified *array*, returning a nested object. Each entry in the returned associative array corresponds to a distinct key value returned by the first key function. The entry value depends on the number of registered key functions: if there is an additional key, the value is another associative array; otherwise, the value is the array of elements filtered from the input *array* that have the given key value.\n\nNote: this method is unsafe if any of the keys conflict with built-in JavaScript properties, such as `__proto__`. If you cannot guarantee that the keys will be safe, you should use [nest.map](#nest_map) instead.\n\n<a name=\"nest_entries\" href=\"#nest_entries\">#</a> <i>nest</i>.<b>entries</b>(<i>array</i>) [<>](https://github.com/d3/d3-collection/blob/master/src/nest.js#L51 \"Source\")\n\nApplies the nest operator to the specified *array*, returning an array of key-values entries. Conceptually, this is similar to applying [*map*.entries](#map_entries) to the associative array returned by [*nest*.map](#nest_map), but it applies to every level of the hierarchy rather than just the first (outermost) level. Each entry in the returned array corresponds to a distinct key value returned by the first key function. The entry value depends on the number of registered key functions: if there is an additional key, the value is another nested array of entries; otherwise, the value is the array of elements filtered from the input *array* that have the given key value.\n",
  "readmeFilename": "README.md",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/d3/d3-collection.git"
  },
  "scripts": {
    "postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../d3-collection/build/d3-collection.js d3-collection.v1.js && cp ../d3-collection/build/d3-collection.min.js d3-collection.v1.min.js && git add d3-collection.v1.js d3-collection.v1.min.js && git commit -m \"d3-collection ${npm_package_version}\" && git push && cd - && zip -j build/d3-collection.zip -- LICENSE README.md build/d3-collection.js build/d3-collection.min.js",
    "prepublish": "npm run test && uglifyjs --preamble \"$(preamble)\" build/d3-collection.js -c -m -o build/d3-collection.min.js",
    "pretest": "rm -rf build && mkdir build && rollup --banner \"$(preamble)\" -f umd -n d3 -o build/d3-collection.js -- index.js",
    "test": "tape 'test/**/*-test.js' && eslint index.js src"
  },
  "version": "1.0.3"
}