Bar graph added.

This commit is contained in:
prabhatdev
2020-07-28 00:48:25 +05:30
parent d0a6e2667d
commit 194b41124d
3468 changed files with 640611 additions and 169 deletions

27
node_modules/vega-util/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,27 @@
Copyright (c) 2015-2018, University of Washington Interactive Data Lab
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

555
node_modules/vega-util/README.md generated vendored Normal file
View File

@@ -0,0 +1,555 @@
# vega-util
JavaScript utilities for Vega. Provides a set of helper methods used throughout Vega modules, including function generators, type checkers, log messages, and additional utilities for Object, Array and String values.
## API Reference
- [Functions](#functions)
- [Type Checkers](#type-checkers)
- [Type Coercion](#type-coercion)
- [Objects](#objects)
- [Arrays](#arrays)
- [Dates](#dates)
- [Logging](#logging)
- [Errors](#errors)
### Functions
Functions and function generators for accessing and comparing values.
<a name="accessor" href="#accessor">#</a>
vega.<b>accessor</b>(<i>function</i>[, <i>fields</i>, <i>name</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/accessor.js "Source")
Annotates a *function* instance with a string array of dependent data *fields* and a string *name*, and returns the input *function*. Assumes the input function takes an object (data tuple) as input, and that strings in the *fields* array correspond to object properties accessed by the function. Once annotated, Vega dataflows can track data field dependencies and generate appropriate output names (e.g., when computing aggregations) if the function is used as an accessor.
Internally, this method assigns the field array to the `fields` property of the input *function*, and the name to the `fname` property. To be future-proof, clients should not access these properties directly. Instead, use the [accessorFields](#accessorFields) and [accessorName](#accessorName) methods.
<a name="accessorFields" href="#accessorFields">#</a>
vega.<b>accessorFields</b>(<i>accessor</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/accessor.js "Source")
Returns the array of dependent field names for a given *accessor* function. Returns null if no field names have been set.
<a name="accessorName" href="#accessorName">#</a>
vega.<b>accessorName</b>(<i>accessor</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/accessor.js "Source")
Returns the name string for a given *accessor* function. Returns null if no name has been set.
<a name="compare" href="#compare">#</a>
vega.<b>compare</b>(<i>fields</i>[, <i>orders</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/compare.js "Source")
Generates a comparator function for sorting data values, based on the given set of *fields* and optional sort *orders*. The *fields* argument must be either a string, an accessor function, or an array of either. Strings indicate the name of object properties to sort by, in precedence order. Field strings may include nested properties (e.g., `foo.bar.baz`). The *orders* argument must be either a string or an array of strings; the valid string values are `'ascending'` (for ascending sort order of the corresponding field) or `'descending'` (for descending sort order of the corresponding field). If the *orders* argument is omitted, is shorter than the *fields* array, or includes values other than `'ascending'` or `'descending'`, corresponding fields will default to ascending order.
<a name="constant" href="#constant">#</a>
vega.<b>constant</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/constant.js "Source")
Given an input *value*, returns a function that simply returns that value. If the input *value* is itself a function, that function is returned directly.
<a name="debounce" href="#debounce">#</a>
vega.<b>debounce</b>(<i>delay</i>, <i>func</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/debounce.js "Source")
Generates a "debounced" function that delays invoking *func* until after *delay* milliseconds have elapsed since the last time the debounced function was invoked. Invocation passes up to one argument from the debounced function to *func* and does not preserve the *this* context.
<a name="field" href="#field">#</a>
vega.<b>field</b>(<i>field</i>[, <i>name</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/field.js "Source")
Generates an accessor function for retrieving the specified *field* value. The input *field* string may include nested properties (e.g., `foo.bar.baz`). An optional *name* argument indicates the accessor name for the generated function; if excluded the field string will be used as the name (see the [accessor](#accessor) method for more details).
```js
var fooField = vega.field('foo');
fooField({foo: 5}); // 5
vega.accessorName(fooField); // 'foo'
vega.accessorFields(fooField); // ['foo']
var pathField = vega.field('foo.bar', 'path');
pathField({foo: {bar: 'vega'}}); // 'vega'
pathField({foo: 5}); // undefined
vega.accessorName(pathField); // 'path'
vega.accessorFields(pathField); // ['foo.bar']
```
<a name="id" href="#id">#</a>
vega.<b>id</b>(<i>object</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/accessors.js "Source")
An accessor function that returns the value of the `id` property of an input *object*.
<a name="identity" href="#identity">#</a>
vega.<b>identity</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/accessors.js "Source")
An accessor function that simply returns its *value* argument.
<a name="key" href="#key">#</a>
vega.<b>key</b>(<i>fields</i>[, <i>flat</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/key.js "Source")
Generates an accessor function that returns a key string (suitable for using as an object property name) for a set of object *fields*. The *fields* argument must be either a string or string array, with each entry indicating a property of an input object to be used to produce representative key values. The resulting key function is an [accessor](#accessor) instance with the accessor name `'key'`. The optional *flat* argument is a boolean flag indicating if the field names should be treated as flat property names, side-stepping nested field lookups normally indicated by dot or bracket notation. By default, *flat* is `false` and nested property lookup is performed.
```js
var keyf = vega.key(['foo', 'bar']);
keyf({foo:'hi', bar:5}); // 'hi|5'
vega.accessorName(keyf); // 'key'
vega.accessorFields(keyf); // ['foo', 'bar']
```
<a name="one" href="#one">#</a>
vega.<b>one</b>()
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/accessors.js "Source")
An accessor function that simply returns the value one (`1`).
<a name="zero" href="#zero">#</a>
vega.<b>zero</b>()
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/accessors.js "Source")
An accessor function that simply returns the value zero (`0`).
<a name="truthy" href="#truthy">#</a>
vega.<b>truthy</b>()
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/accessors.js "Source")
An accessor function that simply returns the boolean `true` value.
<a name="falsy" href="#falsy">#</a>
vega.<b>falsy</b>()
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/accessors.js "Source")
An accessor function that simply returns the boolean `false` value.
### Type Checkers
Functions for checking the type of JavaScript values.
<a name="isArray" href="#isArray">#</a>
vega.<b>isArray</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/isArray.js "Source")
Returns `true` if the input *value* is an Array instance, `false` otherwise.
<a name="isBoolean" href="#isBoolean">#</a>
vega.<b>isBoolean</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/isBoolean.js "Source")
Returns `true` if the input *value* is a Boolean instance, `false` otherwise.
<a name="isDate" href="#isDate">#</a>
vega.<b>isDate</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/isDate.js "Source")
Returns `true` if the input *value* is a Date instance, `false` otherwise.
<a name="isFunction" href="#isFunction">#</a>
vega.<b>isFunction</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/isFunction.js "Source")
Returns `true` if the input *value* is a Function instance, `false` otherwise.
<a name="isNumber" href="#isNumber">#</a>
vega.<b>isNumber</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/isNumber.js "Source")
Returns `true` if the input *value* is a Number instance, `false` otherwise.
<a name="isObject" href="#isObject">#</a>
vega.<b>isObject</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/isObject.js "Source")
Returns `true` if the input *value* is an Object instance, `false` otherwise.
<a name="isRegExp" href="#isRegExp">#</a>
vega.<b>isRegExp</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/isRegExp.js "Source")
Returns `true` if the input *value* is a RegExp instance, `false` otherwise.
<a name="isString" href="#isString">#</a>
vega.<b>isString</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/isString.js "Source")
Returns `true` if the input *value* is a String instance, `false` otherwise.
### Type Coercion
Functions for coercing values to a desired type.
<a name="toBoolean" href="#toBoolean">#</a>
vega.<b>toBoolean</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/toBoolean.js "Source")
Coerces the input _value_ to a boolean. The strings `"true"` and `"1"` map to `true`; the strings `"false"` and `"0"` map to `false`. Null values and empty strings are mapped to `null`.
<a name="toDate" href="#toDate">#</a>
vega.<b>toDate</b>(<i>value</i>[, <i>parser</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/toDate.js "Source")
Coerces the input _value_ to a Date timestamp. Null values and empty strings are mapped to `null`. Date objects are passed through unchanged. If an optional _parser_ function is provided, it is used to perform date parsing. By default, numbers (timestamps) are passed through unchanged and otherwise `Date.parse` is used. Be aware that `Date.parse` has different implementations across browsers!
<a name="toNumber" href="#toNumber">#</a>
vega.<b>toNumber</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/toNumber.js "Source")
Coerces the input _value_ to a number. Null values and empty strings are mapped to `null`.
<a name="toString" href="#toString">#</a>
vega.<b>toString</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/toString.js "Source")
Coerces the input _value_ to a string. Null values and empty strings are mapped to `null`.
### Objects
Functions for manipulating JavaScript Object values.
<a name="extend" href="#extend">#</a>
vega.<b>extend</b>(<i>target</i>[, <i>source1</i>, <i>source2</i>, …])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/extend.js "Source")
Extends a *target* object by copying (in order) all enumerable properties of the input *source* objects.
<a name="inherits" href="#inherits">#</a>
vega.<b>inherits</b>(<i>child</i>, <i>parent</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/inherits.js "Source")
A convenience method for setting up object-oriented inheritance. Assigns the `prototype` property of the input *child* function, such that the *child* inherits the properties of the *parent* function's prototype via prototypal inheritance. Returns the new child prototype object.
<a name="lruCache" href="#lruCache">#</a>
vega.<b>lruCache</b>([<i>maxsize</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/lruCache.js "Source")
Provides a key/value cache, keyed by string, that evicts least recently used (LRU) entries. Supports *has*, *get*, *set*, and *clear* methods. The optional *maxsize* argument (default 10,000) determines the maximum number of elements that can be added before items are evicted.
In the internal implementation two caches are used: a current cache and a previous cache. When then current cache fills, it becomes the previous cache and a new, empty current cache is created. Subsequent *get* calls will promote elements in the previous cache to the current cache. Once the current cache fills, the caches are again turned over and all LRU items still residing in the previous cache are dropped.
```js
var cache = vega.lruCache(1); // use 1-element cache to demonstrate
cache.set('a', 1); // current cache has a->1
cache.set('b', 2); // current cache has b->2, previous cache has a->1
cache.get('a'); // -> 1 (a now in current cache, b in previous cache)
cache.set('c', 3); // current cache has c->3, previous cache has a->1
cache.has('c'); // -> true (c is in the current cache)
cache.has('b'); // -> false (b has been evicted)
cache.has('a'); // -> true (a is in the previous cache)
cache.get('c'); // -> 3
cache.clear();
```
<a name="fastmap" href="#fastmap">#</a>
vega.<b>fastmap</b>([<i>object</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/fastmap.js "Source")
Provides a key/value map data structure, keyed by string. Supports a subset of the [ES6 Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) API, including *has*, *get*, *set*, *delete* and *clear* methods and a *size* property. If the optional *object* argument is provided, all key/values on the input object will be added to the new map instance.
```js
var map = vega.fastmap({foo:1, bar:2});
map.has('foo'); // -> true
map.get('foo'); // -> 1
map.delete('bar');
map.has('bar'); // -> false
map.set('baz', 0);
map.get('baz'); // -> 0
map.size; // -> 2
map.empty; // -> 1 (number of empty entries)
map.clean(); // invoke garbage collection, clears empty entries
```
By using basic JavaScript objects to hash values and avoiding calls to the built-in JavaScript `delete` operator, fastmaps provide good performance. However, this speed comes at the cost of some object bloat, requiring periodic garbage collection in the case of many deletions. The fastmap object provides a *clean* method for requesting garbage collection of empty map entries. The *test* method is a getter/setter for providing an optional boolean-valued function that indicates additional objects (not just empty entries from deleted keys) that should be removed during garbage collection.
<a name="hasOwnProperty" href="#hasOwnProperty">#</a>
vega.<b>hasOwnProperty</b>(<i>object</i>, <i>property</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/hasOwnProperty.js "Source")
Returns `true` if the input *object* has a named *property* defined on it, otherwise `false`. This method concerns the input object only, ignoring properties defined up the prototype chain. The method is equivalent to [`Object.hasOwnProperty`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), but improves security by guarding against overridden Object prototype built-ins.
<a name="mergeConfig" href="#mergeConfig">#</a>
vega.<b>mergeConfig</b>(<i>...config</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/mergeConfig.js "Source")
Merges a collection of Vega configuration objects into a single combined object. Configuration objects with higher index positions in the arguments list have higher precedence, and so may override settings provided by earlier objects.
<a name="writeConfig" href="#writeConfig">#</a>
vega.<b>writeConfig</b>(<i>config</i>, <i>key</i>, <i>value</i>[, <i>recurse</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/mergeConfig.js "Source")
Writes a value to a Vega configuration object. Given a *config* object and a configuration property *key* and *value*, appropriately assign the value to the config object. The *recurse* parameter controls if recursive merging (as opposed to overwriting) is performed: if `false` or undefined, no recursion is performed; if `true` one level of recursive merge is performed; if *recurse* is object-valued, one level of recursive merge is performed for keys that the *recurse* object maps to a truthy value. This method is a helper method used within *mergeConfig*.
### Arrays
Functions for manipulating JavaScript Array values.
<a name="array" href="#array">#</a>
vega.<b>array</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/array.js "Source")
Ensures that the input *value* is an Array instance. If so, the *value* is simply returned. If not, the *value* is wrapped within a new single-element an array, returning `[value]`.
<a name="clampRange" href="#clampRange">#</a>
vega.<b>clampRange</b>(<i>range</i>, <i>min</i>, <i>max</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/clampRange.js "Source")
Span-preserving range clamp. If the span of the input *range* is less than (*max* - *min*) and an endpoint exceeds either the *min* or *max* value, the range is translated such that the span is preserved and one endpoint touches the boundary of the min/max range. If the span exceeds (*max* - *min*), returns the range `[min, max]`.
<a name="extent" href="#extent">#</a>
vega.<b>extent</b>(<i>array</i>[, <i>accessor</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/extent.js "Source")
Returns an array with the minimum and maximum values in the input *array*, in the form `[min, max]`. Ignores null, undefined, and NaN values. The optional *accessor* argument provides a function that is first applied to each array value prior to comparison.
<a name="extentIndex" href="#extentIndex">#</a>
vega.<b>extentIndex</b>(<i>array</i>[, <i>accessor</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/extentIndex.js "Source")
Returns the array indices for the minimum and maximum values in the input *array* (as a `[minIndex, maxIndex]` array), according to natural ordering. The optional *accessor* argument provides a function that is first applied to each array value prior to comparison.
```js
vega.extentIndex([1,5,3,0,4,2]); // [3, 1]
vega.extentIndex([
{a: 3, b:2},
{a: 2, b:1},
{a: 1, b:3}
], vega.field('b')); // [1, 2]
```
<a name="flush" href="#flush">#</a>
vega.<b>flush</b>(<i>range</i>, <i>value</i>, <i>threshold</i>, <i>left</i>, <i>right</i>, <i>center</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/inrange.js "Source")
Selects among potential return values if the provided *value* is flush with the input numeric *range*. Returns *left* if *value is within the *threshold* distance of the minimum element of the *range*. Returns *right* if *value is within the *threshold* distance of the maximum element of the *range*. Otherwise, returns *center*.
<a name="inrange" href="#inrange">#</a>
vega.<b>inrange</b>(<i>value</i>, <i>range</i>[, <i>left</i>, <i>right</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/inrange.js "Source")
Returns `true` if the input *value* lies within the span of the given *range* array. The *left* and *right* boolean flags control the use of inclusive (true) or exclusive (false) comparisons; if unspecified, inclusive tests are used.
<a name="lerp" href="#lerp">#</a>
vega.<b>lerp</b>(<i>array</i>, <i>fraction</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/lerp.js "Source")
Returns the linearly interpolated value between the first and last entries in the *array* for the provided interpolation *fraction* (typically between 0 and 1). For example, *lerp([0, 50], 0.5)* returns 25.
<a name="merge" href="#merge">#</a>
vega.<b>merge</b>(<i>compare</i>, <i>array1</i>, <i>array2</i>[, <i>output</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/merge.js "Source")
Merge two sorted arrays into a single sorted array. The input *compare* function is a comparator for sorting elements and should correspond to the pre-sorted orders of the *array1* and *array2* source arrays. The merged array contents are written to the *output* array, if provided. If *output* is not specified, a new array is generated and returned.
<a name="panLinear" href="#panLinear">#</a>
vega.<b>panLinear</b>(<i>domain</i>, <i>delta</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/transform.js "Source")
Given an input numeric _domain_ (sorted in increasing order), returns a new domain array that translates the domain by a _delta_ using a linear transform. The _delta_ value is expressed as a fraction of the current domain span, and may be positive or negative to indicate the translation direction. The return value is a two-element array indicating the starting and ending value of the translated (panned) domain.
<a name="panLog" href="#panLog">#</a>
vega.<b>panLog</b>(<i>domain</i>, <i>delta</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/transform.js "Source")
Given an input numeric _domain_ (sorted in increasing order), returns a new domain array that translates the domain by a _delta_ using a logarithmic transform. The _delta_ value is expressed as a fraction of the current domain span, and may be positive or negative to indicate the translation direction. The return value is a two-element array indicating the starting and ending value of the translated (panned) domain.
<a name="panPow" href="#panPow">#</a>
vega.<b>panPow</b>(<i>domain</i>, <i>delta</i>, <i>exponent</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/transform.js "Source")
Given an input numeric _domain_ (sorted in increasing order), returns a new domain array that translates the domain by a _delta_ using a power scale transform parameterized by the provided _exponent_. The _delta_ value is expressed as a fraction of the current domain span, and may be positive or negative to indicate the translation direction. The return value is a two-element array indicating the starting and ending value of the translated (panned) domain.
<a name="panSymlog" href="#panSymlog">#</a>
vega.<b>panSymlog</b>(<i>domain</i>, <i>delta</i>, <i>constant</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/transform.js "Source")
Given an input numeric _domain_ (sorted in increasing order), returns a new domain array that translates the domain by a _delta_ using a symlog (symmetric log) scale transform parameterized by the provided _constant_. The _delta_ value is expressed as a fraction of the current domain span, and may be positive or negative to indicate the translation direction. The return value is a two-element array indicating the starting and ending value of the translated (panned) domain.
<a name="peek" href="#peek">#</a>
vega.<b>peek</b>(<i>array</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/peek.js "Source")
Returns the last element in the input *array*. Similar to the built-in `Array.pop` method, except that it does not remove the last element. This method is a convenient shorthand for `array[array.length - 1]`.
<a name="span" href="#span">#</a>
vega.<b>span</b>(<i>array</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/span.js "Source")
Returns the numerical span of the input *array*: the difference between the last and first values.
<a name="toSet" href="#toSet">#</a>
vega.<b>toSet</b>(<i>array</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/toSet.js "Source")
Given an input *array* of values, returns a new Object instance whose property keys are the values in *array*, each assigned a property value of `1`. Each value in *array* is coerced to a String value and so should map to a reasonable string key value.
```js
vega.toSet([1, 2, 3]); // {'1':1, '2':1, '3':1}
```
<a name="visitArray" href="#visitArray">#</a>
vega.<b>visitArray</b>(<i>array</i>, [<i>filter</i>,] <i>visitor</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/visitArray.js "Source")
Vists the values in an input *array*, invoking the *visitor* function for each array value that passes an optional *filter*. If specified, the *filter* function is called with each individual array value. If the *filter* function return value is truthy, the returned value is then passed as input to the *visitor* function. Thus, the *filter* not only performs filtering, it can serve as a value transformer. If the *filter* function is not specified, all values in the *array* are passed to the *visitor* function. Similar to the built-in `Array.forEach` method, the *visitor* function is invoked with three arguments: the value to visit, the current index into the source *array*, and a reference to the soure *array*.
```js
// console output: 1 0; 3 2
vega.visitArray([0, -1, 2],
function(x) { return x + 1; },
function(v, i, array) { console.log(v, i); });
```
<a name="zoomLinear" href="#zoomLinear">#</a>
vega.<b>zoomLinear</b>(<i>domain</i>, <i>anchor</i>, <i>scale</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/transform.js "Source")
Given an input numeric _domain_ (sorted in increasing order), returns a new domain array that scales (zooms) the domain by a _scale_ factor using a linear transform, centered on the given _anchor_ value. If _anchor_ is `null`, the midpoint of the domain is used instead. The return value is a two-element array indicating the starting and ending value of the scaled (zoomed) domain.
<a name="zoomLog" href="#zoomLog">#</a>
vega.<b>zoomLog</b>(<i>domain</i>, <i>anchor</i>, <i>scale</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/transform.js "Source")
Given an input numeric _domain_ (sorted in increasing order), returns a new domain array that scales (zooms) the domain by a _scale_ factor using a logarithmic transform, centered on the given _anchor_ value. If _anchor_ is `null`, the midpoint of the domain is used instead. The return value is a two-element array indicating the starting and ending value of the scaled (zoomed) domain.
<a name="zoomPow" href="#zoomPow">#</a>
vega.<b>zoomPow</b>(<i>domain</i>, <i>anchor</i>, <i>scale</i>, <i>exponent</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/transform.js "Source")
Given an input numeric _domain_ (sorted in increasing order), returns a new domain array that scales (zooms) the domain by a _scale_ factor using a power scale transform parameterized by the provided _exponent_, centered on the given _anchor_ value. If _anchor_ is `null`, the midpoint of the domain is used instead. The return value is a two-element array indicating the starting and ending value of the scaled (zoomed) domain.
<a name="zoomSymlog" href="#zoomSymlog">#</a>
vega.<b>zoomSymlog</b>(<i>domain</i>, <i>anchor</i>, <i>scale</i>, <i>constant</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/transform.js "Source")
Given an input numeric _domain_ (sorted in increasing order), returns a new domain array that scales (zooms) the domain by a _scale_ factor using a symlog (symmetric log) scale transform parameterized by the provided _constant_, centered on the given _anchor_ value. If _anchor_ is `null`, the midpoint of the domain is used instead. The return value is a two-element array indicating the starting and ending value of the scaled (zoomed) domain.
### Dates
Functions for manipulating JavaScript Date values.
<a name="quarter" href="#quarter">#</a>
vega.<b>quarter</b>(<i>date</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/quarter.js "Source")
Returns the quarter of the year (an integer between 1 and 4) for an input *date* object or timestamp for the local timezone.
<a name="utcquarter" href="#utcquarter">#</a>
vega.<b>utcquarter</b>(<i>date</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/quarter.js "Source")
Returns the quarter of the year (an integer between 1 and 4) for an input *date* object or timestamp for Coordinated Universal Time (UTC).
### Strings
Functions for generating and manipulating JavaScript String values.
<a name="pad" href="#pad">#</a>
vega.<b>pad</b>(<i>string</i>, <i>length</i>[, <i>character</i>, <i>align</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/pad.js "Source")
Pads a *string* value with repeated instances of a *character* up to a specified *length*. If *character* is not specified, a space (`' '`) is used. By default, padding is added to the end of a string. An optional *align* parameter specifies if padding should be added to the `'left'` (beginning), `'center'`, or `'right'` (end) of the input string.
```js
vega.pad('15', 5, '0', 'left'); // '00015'
```
<a name="repeat" href="#repeat">#</a>
vega.<b>repeat</b>(<i>string</i>, <i>count</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/repeat.js "Source")
Given an input *string*, returns a new string that repeats the input *count* times.
```js
vega.repeat('0', 5); // '00000'
```
<a name="splitAccessPath" href="#splitAccessPath">#</a>
vega.<b>splitAccessPath</b>(<i>path</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/splitAccessPath.js "Source")
Splits an input string representing an access *path* for JavaScript object properties into an array of constituent path elements.
```js
vega.splitAccessPath('foo'); // ['foo']
vega.splitAccessPath('foo.bar'); // ['foo', 'bar']
vega.splitAccessPath('foo["bar"]'); // ['foo', 'bar']
vega.splitAccessPath('foo[0].bar'); // ['foo', '0', 'bar']
```
<a name="stringValue" href="#stringValue">#</a>
vega.<b>stringValue</b>(<i>value</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/stringValue.js "Source")
Returns an output representation of an input value that is both JSON and JavaScript compliant. For Object and String values, `JSON.stringify` is used to generate the output string. Primitive types such as Number or Boolean are returned as-is. This method can be used to generate values that can then be included in runtime-compiled code snippets (for example, via the Function constructor).
<a name="truncate" href="#truncate">#</a>
vega.<b>truncate</b>(<i>string</i>, <i>length</i>[, <i>align</i>, <i>ellipsis</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/truncate.js "Source")
Truncates an input *string* to a target *length*. The optional *align* argument indicates what part of the string should be truncated: `'left'` (the beginning), `'center'`, or `'right'` (the end). By default, the `'right'` end of the string is truncated. The optional *ellipsis* argument indicates the string to use to indicate truncated content; by default the ellipsis character (`…`, same as `\u2026`) is used.
### Logging
<a name="logger" href="#logger">#</a>
vega.<b>logger</b>([<i>level</i>, <i>method</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/logger.js "Source")
Generates a new logger instance for selectively writing log messages to the JavaScript console. The optional *level* argument indicates the initial log level to use (one of [None](#none), [Warn](#warn), [Info](#info), or [Debug](#debug)), and defaults to [None](#none) if not specified.
The generated logger instance provides the following methods:
- <b>level</b>(<i>value</i>): Sets the current logging level. Only messages with a log level less than or equal to *value* will be written to the console.
- <b>error</b>(<i>message1</i>[, <i>message2</i>, …]): Logs an error message. The messages will be written to the console using the `console.error` method if the current log level is [Error](#error) or higher.
- <b>warn</b>(<i>message1</i>[, <i>message2</i>, …]): Logs a warning message. The messages will be written to the console using the `console.warn` method if the current log level is [Warn](#warn) or higher.
- <b>info</b>(<i>message1</i>[, <i>message2</i>, …]): Logs an informative message. The messages will be written to the console using the `console.log` method if the current log level is [Info](#info) or higher.
- <b>debug</b>(<i>message1</i>[, <i>message2</i>, …]): Logs a debugging message. The messages will be written to the console using the `console.log` method if the current log level is [Debug](#debug) or higher.
To override the choice of console method invoked (`console.log`, `console.warn`, or `console.error`), use the optional *method* argument (one of `"log"`, `"warn"`, or `"error"`) to route all log messages through the same method.
<a name="None" href="#None">#</a>
vega.<b>None</b>
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/logger.js "Source")
Constant value indicating a log level of 'None'. If set as the log level of a [logger](#logger) instance, all log messages will be suppressed.
<a name="Error" href="#Error">#</a>
vega.<b>Error</b>
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/logger.js "Source")
Constant value indicating a log level of 'Error'. If set as the log level of a [logger](#logger) instance, only error messages will be presented.
<a name="Warn" href="#Warn">#</a>
vega.<b>Warn</b>
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/logger.js "Source")
Constant value indicating a log level of 'Warn'. If set as the log level of a [logger](#logger) instance, both error and warning messages will be presented.
<a name="Info" href="#Info">#</a>
vega.<b>Info</b>
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/logger.js "Source")
Constant value indicating a log level of 'Info'. If set as the log level of a [logger](#logger) instance, error, warning and info messages will be presented.
<a name="Debug" href="#Debug">#</a>
vega.<b>Debug</b>
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/logger.js "Source")
Constant value indicating a log level of 'Debug'. If set as the log level of a [logger](#logger) instance, all log messages (error, warning, info and debug) will be presented.
### Errors
<a name="error" href="#error">#</a>
vega.<b>error</b>(<i>message</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-util/src/error.js "Source")
Throws a new error with the provided error *message*. This is a convenience method adding a layer of indirection for error handling, for example allowing error conditions to be included in expression chains.
```js
vega.error('Uh oh'); // equivalent to: throw Error('Uh oh')
// embed error in an expression
return isOk ? returnValue : vega.error('Not OK');
```

931
node_modules/vega-util/build/vega-util.js generated vendored Normal file
View File

@@ -0,0 +1,931 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.vega = {}));
}(this, (function (exports) { 'use strict';
function accessor(fn, fields, name) {
fn.fields = fields || [];
fn.fname = name;
return fn;
}
function accessorName(fn) {
return fn == null ? null : fn.fname;
}
function accessorFields(fn) {
return fn == null ? null : fn.fields;
}
function getter(path) {
return path.length === 1 ? get1(path[0]) : getN(path);
}
const get1 = field => function(obj) {
return obj[field];
};
const getN = path => {
const len = path.length;
return function(obj) {
for (let i = 0; i < len; ++i) {
obj = obj[path[i]];
}
return obj;
};
};
function error(message) {
throw Error(message);
}
function splitAccessPath(p) {
var path = [],
q = null,
b = 0,
n = p.length,
s = '',
i, j, c;
p = p + '';
function push() {
path.push(s + p.substring(i, j));
s = '';
i = j + 1;
}
for (i=j=0; j<n; ++j) {
c = p[j];
if (c === '\\') {
s += p.substring(i, j);
s += p.substring(++j, ++j);
i = j;
} else if (c === q) {
push();
q = null;
b = -1;
} else if (q) {
continue;
} else if (i === b && c === '"') {
i = j + 1;
q = c;
} else if (i === b && c === "'") {
i = j + 1;
q = c;
} else if (c === '.' && !b) {
if (j > i) {
push();
} else {
i = j + 1;
}
} else if (c === '[') {
if (j > i) push();
b = i = j + 1;
} else if (c === ']') {
if (!b) error('Access path missing open bracket: ' + p);
if (b > 0) push();
b = 0;
i = j + 1;
}
}
if (b) error('Access path missing closing bracket: ' + p);
if (q) error('Access path missing closing quote: ' + p);
if (j > i) {
j++;
push();
}
return path;
}
function field(field, name, opt) {
const path = splitAccessPath(field);
field = path.length === 1 ? path[0] : field;
return accessor(
(opt && opt.get || getter)(path),
[field],
name || field
);
}
var empty = [];
var id = field('id');
var identity = accessor(function(_) { return _; }, empty, 'identity');
var zero = accessor(function() { return 0; }, empty, 'zero');
var one = accessor(function() { return 1; }, empty, 'one');
var truthy = accessor(function() { return true; }, empty, 'true');
var falsy = accessor(function() { return false; }, empty, 'false');
function log(method, level, input) {
var args = [level].concat([].slice.call(input));
console[method].apply(console, args); // eslint-disable-line no-console
}
var None = 0;
var Error$1 = 1;
var Warn = 2;
var Info = 3;
var Debug = 4;
function logger(_, method) {
var level = _ || None;
return {
level: function(_) {
if (arguments.length) {
level = +_;
return this;
} else {
return level;
}
},
error: function() {
if (level >= Error$1) log(method || 'error', 'ERROR', arguments);
return this;
},
warn: function() {
if (level >= Warn) log(method || 'warn', 'WARN', arguments);
return this;
},
info: function() {
if (level >= Info) log(method || 'log', 'INFO', arguments);
return this;
},
debug: function() {
if (level >= Debug) log(method || 'log', 'DEBUG', arguments);
return this;
}
};
}
var isArray = Array.isArray;
function isObject(_) {
return _ === Object(_);
}
const isLegalKey = key => key !== '__proto__';
function mergeConfig(...configs) {
return configs.reduce((out, source) => {
for (var key in source) {
if (key === 'signals') {
// for signals, we merge the signals arrays
// source signals take precedence over
// existing signals with the same name
out.signals = mergeNamed(out.signals, source.signals);
} else {
// otherwise, merge objects subject to recursion constraints
// for legend block, recurse for the layout entry only
// for style block, recurse for all properties
// otherwise, no recursion: objects overwrite, no merging
var r = key === 'legend' ? {layout: 1}
: key === 'style' ? true
: null;
writeConfig(out, key, source[key], r);
}
}
return out;
}, {});
}
function writeConfig(output, key, value, recurse) {
if (!isLegalKey(key)) return;
var k, o;
if (isObject(value) && !isArray(value)) {
o = isObject(output[key]) ? output[key] : (output[key] = {});
for (k in value) {
if (recurse && (recurse === true || recurse[k])) {
writeConfig(o, k, value[k]);
} else if (isLegalKey(k)) {
o[k] = value[k];
}
}
} else {
output[key] = value;
}
}
function mergeNamed(a, b) {
if (a == null) return b;
const map = {}, out = [];
function add(_) {
if (!map[_.name]) {
map[_.name] = 1;
out.push(_);
}
}
b.forEach(add);
a.forEach(add);
return out;
}
function peek(array) {
return array[array.length - 1];
}
function toNumber(_) {
return _ == null || _ === '' ? null : +_;
}
function exp(sign) {
return function(x) { return sign * Math.exp(x); };
}
function log$1(sign) {
return function(x) { return Math.log(sign * x); };
}
function symlog(c) {
return function(x) { return Math.sign(x) * Math.log1p(Math.abs(x / c)); };
}
function symexp(c) {
return function(x) { return Math.sign(x) * Math.expm1(Math.abs(x)) * c; };
}
function pow(exponent) {
return function(x) {
return x < 0 ? -Math.pow(-x, exponent) : Math.pow(x, exponent);
};
}
function pan(domain, delta, lift, ground) {
var d0 = lift(domain[0]),
d1 = lift(peek(domain)),
dd = (d1 - d0) * delta;
return [
ground(d0 - dd),
ground(d1 - dd)
];
}
function panLinear(domain, delta) {
return pan(domain, delta, toNumber, identity);
}
function panLog(domain, delta) {
var sign = Math.sign(domain[0]);
return pan(domain, delta, log$1(sign), exp(sign));
}
function panPow(domain, delta, exponent) {
return pan(domain, delta, pow(exponent), pow(1/exponent));
}
function panSymlog(domain, delta, constant) {
return pan(domain, delta, symlog(constant), symexp(constant));
}
function zoom(domain, anchor, scale, lift, ground) {
var d0 = lift(domain[0]),
d1 = lift(peek(domain)),
da = anchor != null ? lift(anchor) : (d0 + d1) / 2;
return [
ground(da + (d0 - da) * scale),
ground(da + (d1 - da) * scale)
];
}
function zoomLinear(domain, anchor, scale) {
return zoom(domain, anchor, scale, toNumber, identity);
}
function zoomLog(domain, anchor, scale) {
var sign = Math.sign(domain[0]);
return zoom(domain, anchor, scale, log$1(sign), exp(sign));
}
function zoomPow(domain, anchor, scale, exponent) {
return zoom(domain, anchor, scale, pow(exponent), pow(1/exponent));
}
function zoomSymlog(domain, anchor, scale, constant) {
return zoom(domain, anchor, scale, symlog(constant), symexp(constant));
}
function quarter(date) {
return 1 + ~~(new Date(date).getMonth() / 3);
}
function utcquarter(date) {
return 1 + ~~(new Date(date).getUTCMonth() / 3);
}
function array(_) {
return _ != null ? (isArray(_) ? _ : [_]) : [];
}
/**
* Span-preserving range clamp. If the span of the input range is less
* than (max - min) and an endpoint exceeds either the min or max value,
* the range is translated such that the span is preserved and one
* endpoint touches the boundary of the min/max range.
* If the span exceeds (max - min), the range [min, max] is returned.
*/
function clampRange(range, min, max) {
var lo = range[0],
hi = range[1],
span;
if (hi < lo) {
span = hi;
hi = lo;
lo = span;
}
span = hi - lo;
return span >= (max - min)
? [min, max]
: [
(lo = Math.min(Math.max(lo, min), max - span)),
lo + span
];
}
function isFunction(_) {
return typeof _ === 'function';
}
const DESCENDING = 'descending';
function compare(fields, orders, opt) {
opt = opt || {};
orders = array(orders) || [];
const ord = [], get = [], fmap = {},
gen = opt.comparator || comparator;
array(fields).forEach((f, i) => {
if (f == null) return;
ord.push(orders[i] === DESCENDING ? -1 : 1);
get.push(f = isFunction(f) ? f : field(f, null, opt));
(accessorFields(f) || []).forEach(_ => fmap[_] = 1);
});
return get.length === 0
? null
: accessor(gen(get, ord), Object.keys(fmap));
}
const compare$1 = (u, v) => (u < v || u == null) && v != null ? -1
: (u > v || v == null) && u != null ? 1
: ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? -1
: v !== v && u === u ? 1
: 0;
const comparator = (fields, orders) => fields.length === 1
? compare1(fields[0], orders[0])
: compareN(fields, orders, fields.length);
const compare1 = (field, order) => function(a, b) {
return compare$1(field(a), field(b)) * order;
};
const compareN = (fields, orders, n) => {
orders.push(0); // pad zero for convenient lookup
return function(a, b) {
let f, c = 0, i = -1;
while (c === 0 && ++i < n) {
f = fields[i];
c = compare$1(f(a), f(b));
}
return c * orders[i];
};
};
function constant(_) {
return isFunction(_) ? _ : function() { return _; };
}
function debounce(delay, handler) {
var tid, evt;
function callback() {
handler(evt);
tid = evt = null;
}
return function(e) {
evt = e;
if (tid) clearTimeout(tid);
tid = setTimeout(callback, delay);
};
}
function extend(_) {
for (var x, k, i=1, len=arguments.length; i<len; ++i) {
x = arguments[i];
for (k in x) { _[k] = x[k]; }
}
return _;
}
/**
* Return an array with minimum and maximum values, in the
* form [min, max]. Ignores null, undefined, and NaN values.
*/
function extent(array, f) {
var i = 0, n, v, min, max;
if (array && (n = array.length)) {
if (f == null) {
// find first valid value
for (v = array[i]; i < n && (v == null || v !== v); v = array[++i]);
min = max = v;
// visit all other values
for (; i<n; ++i) {
v = array[i];
// skip null/undefined; NaN will fail all comparisons
if (v != null) {
if (v < min) min = v;
if (v > max) max = v;
}
}
} else {
// find first valid value
for (v = f(array[i]); i < n && (v == null || v !== v); v = f(array[++i]));
min = max = v;
// visit all other values
for (; i<n; ++i) {
v = f(array[i]);
// skip null/undefined; NaN will fail all comparisons
if (v != null) {
if (v < min) min = v;
if (v > max) max = v;
}
}
}
}
return [min, max];
}
function extentIndex(array, f) {
var i = -1,
n = array.length,
a, b, c, u, v;
if (f == null) {
while (++i < n) {
b = array[i];
if (b != null && b >= b) {
a = c = b;
break;
}
}
if (i === n) return [-1, -1];
u = v = i;
while (++i < n) {
b = array[i];
if (b != null) {
if (a > b) {
a = b;
u = i;
}
if (c < b) {
c = b;
v = i;
}
}
}
} else {
while (++i < n) {
b = f(array[i], i, array);
if (b != null && b >= b) {
a = c = b;
break;
}
}
if (i === n) return [-1, -1];
u = v = i;
while (++i < n) {
b = f(array[i], i, array);
if (b != null) {
if (a > b) {
a = b;
u = i;
}
if (c < b) {
c = b;
v = i;
}
}
}
}
return [u, v];
}
const hop = Object.prototype.hasOwnProperty;
function has(object, property) {
return hop.call(object, property);
}
var NULL = {};
function fastmap(input) {
var obj = {},
map,
test;
function has$1(key) {
return has(obj, key) && obj[key] !== NULL;
}
map = {
size: 0,
empty: 0,
object: obj,
has: has$1,
get(key) {
return has$1(key) ? obj[key] : undefined;
},
set(key, value) {
if (!has$1(key)) {
++map.size;
if (obj[key] === NULL) --map.empty;
}
obj[key] = value;
return this;
},
delete(key) {
if (has$1(key)) {
--map.size;
++map.empty;
obj[key] = NULL;
}
return this;
},
clear() {
map.size = map.empty = 0;
map.object = obj = {};
},
test(_) {
if (arguments.length) {
test = _;
return map;
} else {
return test;
}
},
clean() {
var next = {},
size = 0,
key, value;
for (key in obj) {
value = obj[key];
if (value !== NULL && (!test || !test(value))) {
next[key] = value;
++size;
}
}
map.size = size;
map.empty = 0;
map.object = (obj = next);
}
};
if (input) Object.keys(input).forEach(function(key) {
map.set(key, input[key]);
});
return map;
}
function flush(range, value, threshold, left, right, center) {
if (!threshold && threshold !== 0) return center;
var a = range[0],
b = peek(range),
t = +threshold,
l, r;
// swap endpoints if range is reversed
if (b < a) {
l = a; a = b; b = l;
}
// compare value to endpoints
l = Math.abs(value - a);
r = Math.abs(b - value);
// adjust if value is within threshold distance of endpoint
return l < r && l <= t ? left : r <= t ? right : center;
}
function inherits(child, parent) {
var proto = (child.prototype = Object.create(parent.prototype));
proto.constructor = child;
return proto;
}
/**
* Predicate that returns true if the value lies within the span
* of the given range. The left and right flags control the use
* of inclusive (true) or exclusive (false) comparisons.
*/
function inrange(value, range, left, right) {
var r0 = range[0], r1 = range[range.length-1], t;
if (r0 > r1) {
t = r0;
r0 = r1;
r1 = t;
}
left = left === undefined || left;
right = right === undefined || right;
return (left ? r0 <= value : r0 < value) &&
(right ? value <= r1 : value < r1);
}
function isBoolean(_) {
return typeof _ === 'boolean';
}
function isDate(_) {
return Object.prototype.toString.call(_) === '[object Date]';
}
function isNumber(_) {
return typeof _ === 'number';
}
function isRegExp(_) {
return Object.prototype.toString.call(_) === '[object RegExp]';
}
function isString(_) {
return typeof _ === 'string';
}
function key(fields, flat, opt) {
if (fields) {
fields = flat
? array(fields).map(f => f.replace(/\\(.)/g, '$1'))
: array(fields);
}
const len = fields && fields.length,
gen = opt && opt.get || getter,
map = f => gen(flat ? [f] : splitAccessPath(f));
let fn;
if (!len) {
fn = function() { return ''; };
} else if (len === 1) {
const get = map(fields[0]);
fn = function(_) { return '' + get(_); };
} else {
const get = fields.map(map);
fn = function(_) {
let s = '' + get[0](_), i = 0;
while (++i < len) s += '|' + get[i](_);
return s;
};
}
return accessor(fn, fields, 'key');
}
function lerp(array, frac) {
const lo = array[0],
hi = peek(array),
f = +frac;
return !f ? lo : f === 1 ? hi : lo + f * (hi - lo);
}
const DEFAULT_MAX_SIZE = 10000;
// adapted from https://github.com/dominictarr/hashlru/ (MIT License)
function lruCache(maxsize) {
maxsize = +maxsize || DEFAULT_MAX_SIZE;
let curr, prev, size;
const clear = () => {
curr = {};
prev = {};
size = 0;
};
const update = (key, value) => {
if (++size > maxsize) {
prev = curr;
curr = {};
size = 1;
}
return (curr[key] = value);
};
clear();
return {
clear,
has: key => has(curr, key) || has(prev, key),
get: key => has(curr, key) ? curr[key]
: has(prev, key) ? update(key, prev[key])
: undefined,
set: (key, value) => has(curr, key)
? (curr[key] = value)
: update(key, value)
};
}
function merge(compare, array0, array1, output) {
var n0 = array0.length,
n1 = array1.length;
if (!n1) return array0;
if (!n0) return array1;
var merged = output || new array0.constructor(n0 + n1),
i0 = 0, i1 = 0, i = 0;
for (; i0<n0 && i1<n1; ++i) {
merged[i] = compare(array0[i0], array1[i1]) > 0
? array1[i1++]
: array0[i0++];
}
for (; i0<n0; ++i0, ++i) {
merged[i] = array0[i0];
}
for (; i1<n1; ++i1, ++i) {
merged[i] = array1[i1];
}
return merged;
}
function repeat(str, reps) {
var s = '';
while (--reps >= 0) s += str;
return s;
}
function pad(str, length, padchar, align) {
var c = padchar || ' ',
s = str + '',
n = length - s.length;
return n <= 0 ? s
: align === 'left' ? repeat(c, n) + s
: align === 'center' ? repeat(c, ~~(n/2)) + s + repeat(c, Math.ceil(n/2))
: s + repeat(c, n);
}
/**
* Return the numerical span of an array: the difference between
* the last and first values.
*/
function span(array) {
return array && (peek(array) - array[0]) || 0;
}
function $(x) {
return isArray(x) ? '[' + x.map($) + ']'
: isObject(x) || isString(x) ?
// Output valid JSON and JS source strings.
// See http://timelessrepo.com/json-isnt-a-javascript-subset
JSON.stringify(x).replace('\u2028','\\u2028').replace('\u2029', '\\u2029')
: x;
}
function toBoolean(_) {
return _ == null || _ === '' ? null : !_ || _ === 'false' || _ === '0' ? false : !!_;
}
function defaultParser(_) {
return isNumber(_) ? _ : isDate(_) ? _ : Date.parse(_);
}
function toDate(_, parser) {
parser = parser || defaultParser;
return _ == null || _ === '' ? null : parser(_);
}
function toString(_) {
return _ == null || _ === '' ? null : _ + '';
}
function toSet(_) {
for (var s={}, i=0, n=_.length; i<n; ++i) s[_[i]] = true;
return s;
}
function truncate(str, length, align, ellipsis) {
var e = ellipsis != null ? ellipsis : '\u2026',
s = str + '',
n = s.length,
l = Math.max(0, length - e.length);
return n <= length ? s
: align === 'left' ? e + s.slice(n - l)
: align === 'center' ? s.slice(0, Math.ceil(l/2)) + e + s.slice(n - ~~(l/2))
: s.slice(0, l) + e;
}
function visitArray(array, filter, visitor) {
if (array) {
if (filter) {
var i = 0, n = array.length, t;
for (; i<n; ++i) {
if (t = filter(array[i])) visitor(t, i, array);
}
} else {
array.forEach(visitor);
}
}
}
exports.Debug = Debug;
exports.Error = Error$1;
exports.Info = Info;
exports.None = None;
exports.Warn = Warn;
exports.accessor = accessor;
exports.accessorFields = accessorFields;
exports.accessorName = accessorName;
exports.array = array;
exports.clampRange = clampRange;
exports.compare = compare;
exports.constant = constant;
exports.debounce = debounce;
exports.error = error;
exports.extend = extend;
exports.extent = extent;
exports.extentIndex = extentIndex;
exports.falsy = falsy;
exports.fastmap = fastmap;
exports.field = field;
exports.flush = flush;
exports.hasOwnProperty = has;
exports.id = id;
exports.identity = identity;
exports.inherits = inherits;
exports.inrange = inrange;
exports.isArray = isArray;
exports.isBoolean = isBoolean;
exports.isDate = isDate;
exports.isFunction = isFunction;
exports.isNumber = isNumber;
exports.isObject = isObject;
exports.isRegExp = isRegExp;
exports.isString = isString;
exports.key = key;
exports.lerp = lerp;
exports.logger = logger;
exports.lruCache = lruCache;
exports.merge = merge;
exports.mergeConfig = mergeConfig;
exports.one = one;
exports.pad = pad;
exports.panLinear = panLinear;
exports.panLog = panLog;
exports.panPow = panPow;
exports.panSymlog = panSymlog;
exports.peek = peek;
exports.quarter = quarter;
exports.repeat = repeat;
exports.span = span;
exports.splitAccessPath = splitAccessPath;
exports.stringValue = $;
exports.toBoolean = toBoolean;
exports.toDate = toDate;
exports.toNumber = toNumber;
exports.toSet = toSet;
exports.toString = toString;
exports.truncate = truncate;
exports.truthy = truthy;
exports.utcquarter = utcquarter;
exports.visitArray = visitArray;
exports.writeConfig = writeConfig;
exports.zero = zero;
exports.zoomLinear = zoomLinear;
exports.zoomLog = zoomLog;
exports.zoomPow = zoomPow;
exports.zoomSymlog = zoomSymlog;
Object.defineProperty(exports, '__esModule', { value: true });
})));

1
node_modules/vega-util/build/vega-util.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

162
node_modules/vega-util/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,162 @@
// Functions
type Fn<R> = (...args: readonly any[]) => R;
export type AccessorFn<R = any> = Fn<R> & { fname?: string; fields: readonly string[] };
export function accessor<R>(fn: Fn<R>, fields?: readonly string[], name?: string): AccessorFn<R>;
export function accessorFields(fn: AccessorFn): string[];
export function accessorName(fn: AccessorFn): string;
export type Order = 'ascending' | 'descending';
export function compare(fields: string | readonly string[] | AccessorFn | readonly AccessorFn[], orders?: Order | readonly Order[]): (a: any, b: any) => number;
export function constant<V>(v: V): () => V;
export function debounce<F extends Function>(delay: number, func: F): F;
export function field(field: string, name?: string): AccessorFn;
export function id(_: object): symbol;
export function identity<V>(v: V): V;
export function key(fields: readonly string[], flat?: boolean): (_: object) => string;
export function one(): 1;
export function zero(): 0;
export function truthy(): true;
export function falsy(): false;
// Type Checkers
export function isArray<T>(a: any | T[]): a is T[];
export function isArray<T>(a: any | readonly T[]): a is readonly T[];
export function isBoolean(a: any): a is boolean;
export function isDate(a: any): a is Date;
export function isFunction(a: any): a is Function;
export function isNumber(a: any): a is number;
export function isObject(a: any): a is object;
export function isRegExp(a: any): a is RegExp;
export function isString(a: any): a is string;
// Type Coercion
export function toBoolean(a: any): boolean;
export function toDate(a: any, parser?: (_: any) => number): number;
export function toNumber(a: any): number;
export function toString(a: any): string;
// Objects
export function extend<T>(target: T, ...source: readonly Partial<T>[]): T;
export function inherits<C extends object, P extends object>(
child: C,
parent: P
): C & P;
export function hasOwnProperty(object: object, property: PropertyKey): boolean;
export interface FastMap {
size: number;
empty: number;
has: (f: string) => boolean;
get: (f: string) => any;
set: (f: string, v: any) => void;
delete: (f: string) => void;
clean: () => void;
}
export function fastmap(_?: object): FastMap;
export function mergeConfig<C extends object>(...c: C[]): C;
export function writeConfig<C extends object>(c: C, key: string, value: any, recurse?: boolean | object): void;
// Arrays
export function array<T>(v: T | T[]): T[];
export function array<T>(v: T | readonly T[]): readonly T[];
export function clampRange(range: readonly number[], min: number, max: number): number[];
export function extent(array: readonly number[], accessor?: AccessorFn): number[];
export function extentIndex(array: readonly number[], accessor?: AccessorFn): number[];
export function flush<T extends any>(range: readonly number[], value: number, threshold: number, left: T, right: T, center: T): T;
export function inrange(value: number, range: readonly number[], left: boolean, right: boolean): boolean;
export function lerp(array: readonly number[], fraction: number): number;
export function merge(compare: (a: any, b: any) => number,
array1: any[], array2: any[]): any[];
export function merge(compare: (a: any, b: any) => number,
array1: any[], array2: any[], output?: any[]): void;
export function panLinear(domain: readonly number[], delta: number): number[];
export function panLog(domain: readonly number[], delta: number): number[];
export function panPow(domain: readonly number[], delta: number, exponent: number): number[];
export function panSymlog(domain: readonly number[], delta: number, constant: number): number[];
export function peek(array: readonly any[]): any;
export function span(array: readonly number[]): number;
export function toSet<T>(array: readonly T[]): { [T: string]: true }
export function visitArray(array: readonly any[] | undefined,
filter: (any: any) => boolean | undefined,
visitor: (v: any, i: number, arr: readonly any[]) => void): void;
export function zoomLinear(domain: readonly number[],
anchor: number | null, scale: number): number[];
export function zoomLog(domain: readonly number[],
anchor: number | null, scale: number): number[];
export function zoomPow(domain: readonly number[],
anchor: number | null, scale: number, exponent: number): number[];
export function zoomSymlog(domain: readonly number[],
anchor: number | null, scale: number, constant: number): number[];
// Dates
export function quarter(date: number): number;
export function quarter(date: Date): number;
export function utcquarter(date: number): number;
export function utcquarter(date: Date): number;
// Strings
export function pad(str: string, len: number,
char?: string, align?: 'left' | 'center' | 'right'): string;
export function repeat(str: string, count: number): string;
export function splitAccessPath(path: string): string[];
export function stringValue(a: any): string;
export function truncate(a: string, length: number,
align?: 'left' | 'center' | 'right', ellipsis?: string): string;
// Logging
export interface LoggerInterface {
level(_: number): this;
level(): number;
error(...args: readonly any[]): this;
warn(...args: readonly any[]): this;
info(...args: readonly any[]): this;
debug(...args: readonly any[]): this;
}
export const None: number;
export const Error: number;
export const Warn: number;
export const Info: number;
export const Debug: number;
export function logger(_?: number, method?: string): LoggerInterface;
export function log(...args: readonly any[]): void;
export function error(msg: string): Error;

85
node_modules/vega-util/index.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
export {
default as accessor,
accessorName,
accessorFields
} from './src/accessor';
export {
id,
identity,
zero,
one,
truthy,
falsy
} from './src/accessors';
export {
default as logger,
None,
Error,
Warn,
Info,
Debug
} from './src/logger';
export {
mergeConfig,
writeConfig
} from './src/mergeConfig';
export {
panLinear,
panLog,
panPow,
panSymlog,
zoomLinear,
zoomLog,
zoomPow,
zoomSymlog
} from './src/transform';
export {
quarter,
utcquarter
} from './src/quarter';
export {default as array} from './src/array';
export {default as clampRange} from './src/clampRange';
export {default as compare} from './src/compare';
export {default as constant} from './src/constant';
export {default as debounce} from './src/debounce';
export {default as error} from './src/error';
export {default as extend} from './src/extend';
export {default as extent} from './src/extent';
export {default as extentIndex} from './src/extentIndex';
export {default as fastmap} from './src/fastmap';
export {default as field} from './src/field';
export {default as flush} from './src/flush';
export {default as hasOwnProperty} from './src/hasOwnProperty';
export {default as inherits} from './src/inherits';
export {default as inrange} from './src/inrange';
export {default as isArray} from './src/isArray';
export {default as isBoolean} from './src/isBoolean';
export {default as isDate} from './src/isDate';
export {default as isFunction} from './src/isFunction';
export {default as isNumber} from './src/isNumber';
export {default as isObject} from './src/isObject';
export {default as isRegExp} from './src/isRegExp';
export {default as isString} from './src/isString';
export {default as key} from './src/key';
export {default as lerp} from './src/lerp';
export {default as lruCache} from './src/lruCache';
export {default as merge} from './src/merge';
export {default as pad} from './src/pad';
export {default as peek} from './src/peek';
export {default as repeat} from './src/repeat';
export {default as span} from './src/span';
export {default as splitAccessPath} from './src/splitAccessPath';
export {default as stringValue} from './src/stringValue';
export {default as toBoolean} from './src/toBoolean';
export {default as toDate} from './src/toDate';
export {default as toNumber} from './src/toNumber';
export {default as toString} from './src/toString';
export {default as toSet} from './src/toSet';
export {default as truncate} from './src/truncate';
export {default as visitArray} from './src/visitArray';

85
node_modules/vega-util/package.json generated vendored Normal file
View File

@@ -0,0 +1,85 @@
{
"_from": "vega-util@~1.14.1",
"_id": "vega-util@1.14.1",
"_inBundle": false,
"_integrity": "sha512-pSKJ8OCkgfgHZDTljyj+gmGltgulceWbk1BV6LWrXqp6P3J8qPA/oZA8+a93YNApYxXZ3yzIVUDOo5O27xk0jw==",
"_location": "/vega-util",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "vega-util@~1.14.1",
"name": "vega-util",
"escapedName": "vega-util",
"rawSpec": "~1.14.1",
"saveSpec": null,
"fetchSpec": "~1.14.1"
},
"_requiredBy": [
"/vega",
"/vega-crossfilter",
"/vega-dataflow",
"/vega-encode",
"/vega-expression",
"/vega-force",
"/vega-format",
"/vega-functions",
"/vega-geo",
"/vega-hierarchy",
"/vega-lite",
"/vega-loader",
"/vega-parser",
"/vega-regression",
"/vega-runtime",
"/vega-scale",
"/vega-scenegraph",
"/vega-selections",
"/vega-time",
"/vega-transforms",
"/vega-typings",
"/vega-view",
"/vega-view-transforms",
"/vega-voronoi",
"/vega-wordcloud"
],
"_resolved": "https://registry.npmjs.org/vega-util/-/vega-util-1.14.1.tgz",
"_shasum": "0fb614277764f98738ba0b80e5cdfbe663426183",
"_spec": "vega-util@~1.14.1",
"_where": "/home/prabhatdev/Documents/opensource/gitHubStats/waka-readme-stats/node_modules/vega",
"author": {
"name": "Jeffrey Heer",
"url": "http://idl.cs.washington.edu"
},
"bugs": {
"url": "https://github.com/vega/vega/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "JavaScript utilities for Vega.",
"gitHead": "62565bbe084a422c4a0cbc6e19c6f7c45a3e5137",
"homepage": "https://github.com/vega/vega#readme",
"keywords": [
"vega",
"utilities"
],
"license": "BSD-3-Clause",
"main": "build/vega-util.js",
"module": "index",
"name": "vega-util",
"repository": {
"type": "git",
"url": "git+https://github.com/vega/vega.git"
},
"scripts": {
"build": "yarn rollup",
"postbuild": "terser build/vega-util.js -c -m -o build/vega-util.min.js",
"postpublish": "git push && git push --tags",
"prebuild": "rimraf build && mkdir build",
"prepublishOnly": "yarn test && yarn build",
"pretest": "yarn prebuild && yarn rollup",
"rollup": "rollup -f umd -n vega -o build/vega-util.js -- index.js",
"test": "tape 'test/**/*-test.js'"
},
"types": "index.d.ts",
"version": "1.14.1"
}

13
node_modules/vega-util/src/accessor.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
export default function(fn, fields, name) {
fn.fields = fields || [];
fn.fname = name;
return fn;
}
export function accessorName(fn) {
return fn == null ? null : fn.fname;
}
export function accessorFields(fn) {
return fn == null ? null : fn.fields;
}

16
node_modules/vega-util/src/accessors.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import accessor from './accessor';
import field from './field';
var empty = [];
export var id = field('id');
export var identity = accessor(function(_) { return _; }, empty, 'identity');
export var zero = accessor(function() { return 0; }, empty, 'zero');
export var one = accessor(function() { return 1; }, empty, 'one');
export var truthy = accessor(function() { return true; }, empty, 'true');
export var falsy = accessor(function() { return false; }, empty, 'false');

5
node_modules/vega-util/src/array.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import isArray from './isArray';
export default function(_) {
return _ != null ? (isArray(_) ? _ : [_]) : [];
}

26
node_modules/vega-util/src/clampRange.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
/**
* Span-preserving range clamp. If the span of the input range is less
* than (max - min) and an endpoint exceeds either the min or max value,
* the range is translated such that the span is preserved and one
* endpoint touches the boundary of the min/max range.
* If the span exceeds (max - min), the range [min, max] is returned.
*/
export default function(range, min, max) {
var lo = range[0],
hi = range[1],
span;
if (hi < lo) {
span = hi;
hi = lo;
lo = span;
}
span = hi - lo;
return span >= (max - min)
? [min, max]
: [
(lo = Math.min(Math.max(lo, min), max - span)),
lo + span
];
}

51
node_modules/vega-util/src/compare.js generated vendored Normal file
View File

@@ -0,0 +1,51 @@
import {default as accessor, accessorFields} from './accessor';
import array from './array';
import field from './field';
import isFunction from './isFunction';
const DESCENDING = 'descending';
export default function(fields, orders, opt) {
opt = opt || {};
orders = array(orders) || [];
const ord = [], get = [], fmap = {},
gen = opt.comparator || comparator;
array(fields).forEach((f, i) => {
if (f == null) return;
ord.push(orders[i] === DESCENDING ? -1 : 1);
get.push(f = isFunction(f) ? f : field(f, null, opt));
(accessorFields(f) || []).forEach(_ => fmap[_] = 1);
});
return get.length === 0
? null
: accessor(gen(get, ord), Object.keys(fmap));
}
const compare = (u, v) => (u < v || u == null) && v != null ? -1
: (u > v || v == null) && u != null ? 1
: ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? -1
: v !== v && u === u ? 1
: 0;
const comparator = (fields, orders) => fields.length === 1
? compare1(fields[0], orders[0])
: compareN(fields, orders, fields.length);
const compare1 = (field, order) => function(a, b) {
return compare(field(a), field(b)) * order;
};
const compareN = (fields, orders, n) => {
orders.push(0); // pad zero for convenient lookup
return function(a, b) {
let f, c = 0, i = -1;
while (c === 0 && ++i < n) {
f = fields[i];
c = compare(f(a), f(b));
}
return c * orders[i];
};
};

5
node_modules/vega-util/src/constant.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import isFunction from './isFunction';
export default function(_) {
return isFunction(_) ? _ : function() { return _; };
}

14
node_modules/vega-util/src/debounce.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
export default function(delay, handler) {
var tid, evt;
function callback() {
handler(evt);
tid = evt = null;
}
return function(e) {
evt = e;
if (tid) clearTimeout(tid);
tid = setTimeout(callback, delay);
};
}

3
node_modules/vega-util/src/error.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function(message) {
throw Error(message);
}

7
node_modules/vega-util/src/extend.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
export default function(_) {
for (var x, k, i=1, len=arguments.length; i<len; ++i) {
x = arguments[i];
for (k in x) { _[k] = x[k]; }
}
return _;
}

41
node_modules/vega-util/src/extent.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
/**
* Return an array with minimum and maximum values, in the
* form [min, max]. Ignores null, undefined, and NaN values.
*/
export default function(array, f) {
var i = 0, n, v, min, max;
if (array && (n = array.length)) {
if (f == null) {
// find first valid value
for (v = array[i]; i < n && (v == null || v !== v); v = array[++i]);
min = max = v;
// visit all other values
for (; i<n; ++i) {
v = array[i];
// skip null/undefined; NaN will fail all comparisons
if (v != null) {
if (v < min) min = v;
if (v > max) max = v;
}
}
} else {
// find first valid value
for (v = f(array[i]); i < n && (v == null || v !== v); v = f(array[++i]));
min = max = v;
// visit all other values
for (; i<n; ++i) {
v = f(array[i]);
// skip null/undefined; NaN will fail all comparisons
if (v != null) {
if (v < min) min = v;
if (v > max) max = v;
}
}
}
}
return [min, max];
}

55
node_modules/vega-util/src/extentIndex.js generated vendored Normal file
View File

@@ -0,0 +1,55 @@
export default function(array, f) {
var i = -1,
n = array.length,
a, b, c, u, v;
if (f == null) {
while (++i < n) {
b = array[i];
if (b != null && b >= b) {
a = c = b;
break;
}
}
if (i === n) return [-1, -1];
u = v = i;
while (++i < n) {
b = array[i];
if (b != null) {
if (a > b) {
a = b;
u = i;
}
if (c < b) {
c = b;
v = i;
}
}
}
} else {
while (++i < n) {
b = f(array[i], i, array);
if (b != null && b >= b) {
a = c = b;
break;
}
}
if (i === n) return [-1, -1];
u = v = i;
while (++i < n) {
b = f(array[i], i, array);
if (b != null) {
if (a > b) {
a = b;
u = i;
}
if (c < b) {
c = b;
v = i;
}
}
}
}
return [u, v];
}

72
node_modules/vega-util/src/fastmap.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
import hasOwnProperty from './hasOwnProperty';
var NULL = {};
export default function(input) {
var obj = {},
map,
test;
function has(key) {
return hasOwnProperty(obj, key) && obj[key] !== NULL;
}
map = {
size: 0,
empty: 0,
object: obj,
has: has,
get(key) {
return has(key) ? obj[key] : undefined;
},
set(key, value) {
if (!has(key)) {
++map.size;
if (obj[key] === NULL) --map.empty;
}
obj[key] = value;
return this;
},
delete(key) {
if (has(key)) {
--map.size;
++map.empty;
obj[key] = NULL;
}
return this;
},
clear() {
map.size = map.empty = 0;
map.object = obj = {};
},
test(_) {
if (arguments.length) {
test = _;
return map;
} else {
return test;
}
},
clean() {
var next = {},
size = 0,
key, value;
for (key in obj) {
value = obj[key];
if (value !== NULL && (!test || !test(value))) {
next[key] = value;
++size;
}
}
map.size = size;
map.empty = 0;
map.object = (obj = next);
}
};
if (input) Object.keys(input).forEach(function(key) {
map.set(key, input[key]);
});
return map;
}

13
node_modules/vega-util/src/field.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import accessor from './accessor';
import getter from './getter';
import splitAccessPath from './splitAccessPath';
export default function(field, name, opt) {
const path = splitAccessPath(field);
field = path.length === 1 ? path[0] : field;
return accessor(
(opt && opt.get || getter)(path),
[field],
name || field
);
}

22
node_modules/vega-util/src/flush.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import peek from './peek';
export default function(range, value, threshold, left, right, center) {
if (!threshold && threshold !== 0) return center;
var a = range[0],
b = peek(range),
t = +threshold,
l, r;
// swap endpoints if range is reversed
if (b < a) {
l = a; a = b; b = l;
}
// compare value to endpoints
l = Math.abs(value - a);
r = Math.abs(b - value);
// adjust if value is within threshold distance of endpoint
return l < r && l <= t ? left : r <= t ? right : center;
}

18
node_modules/vega-util/src/getter.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
export default function(path) {
return path.length === 1 ? get1(path[0]) : getN(path);
}
const get1 = field => function(obj) {
return obj[field];
};
const getN = path => {
const len = path.length;
return function(obj) {
for (let i = 0; i < len; ++i) {
obj = obj[path[i]];
}
return obj;
};
};

5
node_modules/vega-util/src/hasOwnProperty.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
const hop = Object.prototype.hasOwnProperty;
export default function(object, property) {
return hop.call(object, property);
}

5
node_modules/vega-util/src/inherits.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
export default function(child, parent) {
var proto = (child.prototype = Object.create(parent.prototype));
proto.constructor = child;
return proto;
}

18
node_modules/vega-util/src/inrange.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
/**
* Predicate that returns true if the value lies within the span
* of the given range. The left and right flags control the use
* of inclusive (true) or exclusive (false) comparisons.
*/
export default function(value, range, left, right) {
var r0 = range[0], r1 = range[range.length-1], t;
if (r0 > r1) {
t = r0;
r0 = r1;
r1 = t;
}
left = left === undefined || left;
right = right === undefined || right;
return (left ? r0 <= value : r0 < value) &&
(right ? value <= r1 : value < r1);
}

1
node_modules/vega-util/src/isArray.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export default Array.isArray;

3
node_modules/vega-util/src/isBoolean.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function(_) {
return typeof _ === 'boolean';
}

3
node_modules/vega-util/src/isDate.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function(_) {
return Object.prototype.toString.call(_) === '[object Date]';
}

3
node_modules/vega-util/src/isFunction.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function(_) {
return typeof _ === 'function';
}

3
node_modules/vega-util/src/isNumber.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function(_) {
return typeof _ === 'number';
}

3
node_modules/vega-util/src/isObject.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function(_) {
return _ === Object(_);
}

3
node_modules/vega-util/src/isRegExp.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function(_) {
return Object.prototype.toString.call(_) === '[object RegExp]';
}

3
node_modules/vega-util/src/isString.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function(_) {
return typeof _ === 'string';
}

33
node_modules/vega-util/src/key.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
import accessor from './accessor';
import array from './array';
import getter from './getter';
import splitAccessPath from './splitAccessPath';
export default function(fields, flat, opt) {
if (fields) {
fields = flat
? array(fields).map(f => f.replace(/\\(.)/g, '$1'))
: array(fields);
}
const len = fields && fields.length,
gen = opt && opt.get || getter,
map = f => gen(flat ? [f] : splitAccessPath(f));
let fn;
if (!len) {
fn = function() { return ''; };
} else if (len === 1) {
const get = map(fields[0]);
fn = function(_) { return '' + get(_); };
} else {
const get = fields.map(map);
fn = function(_) {
let s = '' + get[0](_), i = 0;
while (++i < len) s += '|' + get[i](_);
return s;
};
}
return accessor(fn, fields, 'key');
}

8
node_modules/vega-util/src/lerp.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import peek from './peek';
export default function(array, frac) {
const lo = array[0],
hi = peek(array),
f = +frac;
return !f ? lo : f === 1 ? hi : lo + f * (hi - lo);
}

40
node_modules/vega-util/src/logger.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
function log(method, level, input) {
var args = [level].concat([].slice.call(input));
console[method].apply(console, args); // eslint-disable-line no-console
}
export var None = 0;
export var Error = 1;
export var Warn = 2;
export var Info = 3;
export var Debug = 4;
export default function(_, method) {
var level = _ || None;
return {
level: function(_) {
if (arguments.length) {
level = +_;
return this;
} else {
return level;
}
},
error: function() {
if (level >= Error) log(method || 'error', 'ERROR', arguments);
return this;
},
warn: function() {
if (level >= Warn) log(method || 'warn', 'WARN', arguments);
return this;
},
info: function() {
if (level >= Info) log(method || 'log', 'INFO', arguments);
return this;
},
debug: function() {
if (level >= Debug) log(method || 'log', 'DEBUG', arguments);
return this;
}
};
}

38
node_modules/vega-util/src/lruCache.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
import has from './hasOwnProperty';
const DEFAULT_MAX_SIZE = 10000;
// adapted from https://github.com/dominictarr/hashlru/ (MIT License)
export default function(maxsize) {
maxsize = +maxsize || DEFAULT_MAX_SIZE;
let curr, prev, size;
const clear = () => {
curr = {};
prev = {};
size = 0;
};
const update = (key, value) => {
if (++size > maxsize) {
prev = curr;
curr = {};
size = 1;
}
return (curr[key] = value);
};
clear();
return {
clear,
has: key => has(curr, key) || has(prev, key),
get: key => has(curr, key) ? curr[key]
: has(prev, key) ? update(key, prev[key])
: undefined,
set: (key, value) => has(curr, key)
? (curr[key] = value)
: update(key, value)
};
}

26
node_modules/vega-util/src/merge.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
export default function(compare, array0, array1, output) {
var n0 = array0.length,
n1 = array1.length;
if (!n1) return array0;
if (!n0) return array1;
var merged = output || new array0.constructor(n0 + n1),
i0 = 0, i1 = 0, i = 0;
for (; i0<n0 && i1<n1; ++i) {
merged[i] = compare(array0[i0], array1[i1]) > 0
? array1[i1++]
: array0[i0++];
}
for (; i0<n0; ++i0, ++i) {
merged[i] = array0[i0];
}
for (; i1<n1; ++i1, ++i) {
merged[i] = array1[i1];
}
return merged;
}

62
node_modules/vega-util/src/mergeConfig.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
import isArray from './isArray';
import isObject from './isObject';
const isLegalKey = key => key !== '__proto__';
export function mergeConfig(...configs) {
return configs.reduce((out, source) => {
for (var key in source) {
if (key === 'signals') {
// for signals, we merge the signals arrays
// source signals take precedence over
// existing signals with the same name
out.signals = mergeNamed(out.signals, source.signals);
} else {
// otherwise, merge objects subject to recursion constraints
// for legend block, recurse for the layout entry only
// for style block, recurse for all properties
// otherwise, no recursion: objects overwrite, no merging
var r = key === 'legend' ? {layout: 1}
: key === 'style' ? true
: null;
writeConfig(out, key, source[key], r);
}
}
return out;
}, {});
}
export function writeConfig(output, key, value, recurse) {
if (!isLegalKey(key)) return;
var k, o;
if (isObject(value) && !isArray(value)) {
o = isObject(output[key]) ? output[key] : (output[key] = {});
for (k in value) {
if (recurse && (recurse === true || recurse[k])) {
writeConfig(o, k, value[k]);
} else if (isLegalKey(k)) {
o[k] = value[k];
}
}
} else {
output[key] = value;
}
}
function mergeNamed(a, b) {
if (a == null) return b;
const map = {}, out = [];
function add(_) {
if (!map[_.name]) {
map[_.name] = 1;
out.push(_);
}
}
b.forEach(add);
a.forEach(add);
return out;
}

12
node_modules/vega-util/src/pad.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
import repeat from './repeat';
export default function(str, length, padchar, align) {
var c = padchar || ' ',
s = str + '',
n = length - s.length;
return n <= 0 ? s
: align === 'left' ? repeat(c, n) + s
: align === 'center' ? repeat(c, ~~(n/2)) + s + repeat(c, Math.ceil(n/2))
: s + repeat(c, n);
}

3
node_modules/vega-util/src/peek.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function(array) {
return array[array.length - 1];
}

7
node_modules/vega-util/src/quarter.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
export function quarter(date) {
return 1 + ~~(new Date(date).getMonth() / 3);
}
export function utcquarter(date) {
return 1 + ~~(new Date(date).getUTCMonth() / 3);
}

5
node_modules/vega-util/src/repeat.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
export default function(str, reps) {
var s = '';
while (--reps >= 0) s += str;
return s;
}

9
node_modules/vega-util/src/span.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import peek from './peek';
/**
* Return the numerical span of an array: the difference between
* the last and first values.
*/
export default function(array) {
return array && (peek(array) - array[0]) || 0;
}

63
node_modules/vega-util/src/splitAccessPath.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
import error from './error';
export default function(p) {
var path = [],
q = null,
b = 0,
n = p.length,
s = '',
i, j, c;
p = p + '';
function push() {
path.push(s + p.substring(i, j));
s = '';
i = j + 1;
}
for (i=j=0; j<n; ++j) {
c = p[j];
if (c === '\\') {
s += p.substring(i, j);
s += p.substring(++j, ++j);
i = j;
} else if (c === q) {
push();
q = null;
b = -1;
} else if (q) {
continue;
} else if (i === b && c === '"') {
i = j + 1;
q = c;
} else if (i === b && c === "'") {
i = j + 1;
q = c;
} else if (c === '.' && !b) {
if (j > i) {
push();
} else {
i = j + 1;
}
} else if (c === '[') {
if (j > i) push();
b = i = j + 1;
} else if (c === ']') {
if (!b) error('Access path missing open bracket: ' + p);
if (b > 0) push();
b = 0;
i = j + 1;
}
}
if (b) error('Access path missing closing bracket: ' + p);
if (q) error('Access path missing closing quote: ' + p);
if (j > i) {
j++;
push();
}
return path;
}

12
node_modules/vega-util/src/stringValue.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
import isArray from './isArray';
import isObject from './isObject';
import isString from './isString';
export default function $(x) {
return isArray(x) ? '[' + x.map($) + ']'
: isObject(x) || isString(x) ?
// Output valid JSON and JS source strings.
// See http://timelessrepo.com/json-isnt-a-javascript-subset
JSON.stringify(x).replace('\u2028','\\u2028').replace('\u2029', '\\u2029')
: x;
}

3
node_modules/vega-util/src/toBoolean.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function(_) {
return _ == null || _ === '' ? null : !_ || _ === 'false' || _ === '0' ? false : !!_;
}

11
node_modules/vega-util/src/toDate.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import isDate from './isDate';
import isNumber from './isNumber';
function defaultParser(_) {
return isNumber(_) ? _ : isDate(_) ? _ : Date.parse(_);
}
export default function(_, parser) {
parser = parser || defaultParser;
return _ == null || _ === '' ? null : parser(_);
}

3
node_modules/vega-util/src/toNumber.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function(_) {
return _ == null || _ === '' ? null : +_;
}

4
node_modules/vega-util/src/toSet.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export default function(_) {
for (var s={}, i=0, n=_.length; i<n; ++i) s[_[i]] = true;
return s;
}

3
node_modules/vega-util/src/toString.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export default function(_) {
return _ == null || _ === '' ? null : _ + '';
}

81
node_modules/vega-util/src/transform.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
import {identity} from './accessors';
import peek from './peek';
import toNumber from './toNumber';
function exp(sign) {
return function(x) { return sign * Math.exp(x); };
}
function log(sign) {
return function(x) { return Math.log(sign * x); };
}
function symlog(c) {
return function(x) { return Math.sign(x) * Math.log1p(Math.abs(x / c)); };
}
function symexp(c) {
return function(x) { return Math.sign(x) * Math.expm1(Math.abs(x)) * c; };
}
function pow(exponent) {
return function(x) {
return x < 0 ? -Math.pow(-x, exponent) : Math.pow(x, exponent);
};
}
function pan(domain, delta, lift, ground) {
var d0 = lift(domain[0]),
d1 = lift(peek(domain)),
dd = (d1 - d0) * delta;
return [
ground(d0 - dd),
ground(d1 - dd)
];
}
export function panLinear(domain, delta) {
return pan(domain, delta, toNumber, identity);
}
export function panLog(domain, delta) {
var sign = Math.sign(domain[0]);
return pan(domain, delta, log(sign), exp(sign));
}
export function panPow(domain, delta, exponent) {
return pan(domain, delta, pow(exponent), pow(1/exponent));
}
export function panSymlog(domain, delta, constant) {
return pan(domain, delta, symlog(constant), symexp(constant));
}
function zoom(domain, anchor, scale, lift, ground) {
var d0 = lift(domain[0]),
d1 = lift(peek(domain)),
da = anchor != null ? lift(anchor) : (d0 + d1) / 2;
return [
ground(da + (d0 - da) * scale),
ground(da + (d1 - da) * scale)
];
}
export function zoomLinear(domain, anchor, scale) {
return zoom(domain, anchor, scale, toNumber, identity);
}
export function zoomLog(domain, anchor, scale) {
var sign = Math.sign(domain[0]);
return zoom(domain, anchor, scale, log(sign), exp(sign));
}
export function zoomPow(domain, anchor, scale, exponent) {
return zoom(domain, anchor, scale, pow(exponent), pow(1/exponent));
}
export function zoomSymlog(domain, anchor, scale, constant) {
return zoom(domain, anchor, scale, symlog(constant), symexp(constant));
}

11
node_modules/vega-util/src/truncate.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
export default function(str, length, align, ellipsis) {
var e = ellipsis != null ? ellipsis : '\u2026',
s = str + '',
n = s.length,
l = Math.max(0, length - e.length);
return n <= length ? s
: align === 'left' ? e + s.slice(n - l)
: align === 'center' ? s.slice(0, Math.ceil(l/2)) + e + s.slice(n - ~~(l/2))
: s.slice(0, l) + e;
}

12
node_modules/vega-util/src/visitArray.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
export default function(array, filter, visitor) {
if (array) {
if (filter) {
var i = 0, n = array.length, t;
for (; i<n; ++i) {
if (t = filter(array[i])) visitor(t, i, array);
}
} else {
array.forEach(visitor);
}
}
}

14
node_modules/vega-util/tsconfig.json generated vendored Normal file
View File

@@ -0,0 +1,14 @@
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts"
]
}