content_type stringclasses 8 values | main_lang stringclasses 7 values | message stringlengths 1 50 | sha stringlengths 40 40 | patch stringlengths 52 962k | file_count int64 1 300 |
|---|---|---|---|---|---|
Python | Python | remove redundant imports | b88a6785b44844b0b4054d9c77aa4a7d7b6bb1ff | <ide><path>numpy/distutils/mingw32ccompiler.py
<ide> def __init__ (self,
<ide> # we need to support 3.2 which doesn't match the standard
<ide> # get_versions methods regex
<ide> if self.gcc_version is None:
<del> import re
<ide> p = subprocess.Popen(['gcc', '-dumpversion'], shell=True,
<ide> stdout=subprocess.PIPE)
<ide> out_string = p.stdout.read()
<ide><path>numpy/distutils/misc_util.py
<ide> def generate_svn_version_py():
<ide> f.write('version = %r\n' % (version))
<ide> f.close()
<ide>
<del> import atexit
<ide> def rm_file(f=target,p=self.info):
<ide> if delete:
<ide> try: os.remove(f); p('removed '+f)
<ide> def generate_hg_version_py():
<ide> f.write('version = %r\n' % (version))
<ide> f.close()
<ide>
<del> import atexit
<ide> def rm_file(f=target,p=self.info):
<ide> if delete:
<ide> try: os.remove(f); p('removed '+f)
<ide><path>numpy/lib/utils.py
<ide> def __call__(self, func, *args, **kwargs):
<ide> new_name = self.new_name
<ide> message = self.message
<ide>
<del> import warnings
<ide> if old_name is None:
<ide> try:
<ide> old_name = func.__name__ | 3 |
Mixed | Javascript | fix assert.fail with zero arguments | fc463639fa38434a3360a1e3695d7ded029242c3 | <ide><path>doc/api/assert.md
<ide> If the values are not equal, an `AssertionError` is thrown with a `message`
<ide> property set equal to the value of the `message` parameter. If the `message`
<ide> parameter is undefined, a default error message is assigned.
<ide>
<del>## assert.fail(message)
<add>## assert.fail([message])
<ide> ## assert.fail(actual, expected, message, operator)
<ide> <!-- YAML
<ide> added: v0.1.21
<ide> -->
<ide> * `actual` {any}
<ide> * `expected` {any}
<del>* `message` {any}
<add>* `message` {any} (default: 'Failed')
<ide> * `operator` {string} (default: '!=')
<ide>
<ide> Throws an `AssertionError`. If `message` is falsy, the error message is set as
<ide> the values of `actual` and `expected` separated by the provided `operator`.
<ide> Otherwise, the error message is the value of `message`.
<add>If no arguments are provided at all, a default message will be used instead.
<ide>
<ide> ```js
<ide> const assert = require('assert');
<ide> assert.fail('boom');
<ide>
<ide> assert.fail('a', 'b');
<ide> // AssertionError: 'a' != 'b'
<add>
<add>assert.fail();
<add>// AssertionError: Failed
<ide> ```
<ide>
<ide> ## assert.ifError(value)
<ide><path>lib/assert.js
<ide> const assert = module.exports = ok;
<ide> // display purposes.
<ide>
<ide> function fail(actual, expected, message, operator, stackStartFunction) {
<del> if (arguments.length === 1)
<add> if (arguments.length === 0) {
<add> message = 'Failed';
<add> }
<add> if (arguments.length === 1) {
<ide> message = actual;
<add> actual = undefined;
<add> }
<ide> if (arguments.length === 2)
<ide> operator = '!=';
<ide> const errors = lazyErrors();
<ide><path>test/parallel/test-assert-fail.js
<ide> assert.throws(
<ide> common.expectsError({
<ide> code: 'ERR_ASSERTION',
<ide> type: assert.AssertionError,
<del> message: 'undefined undefined undefined'
<add> message: 'Failed'
<ide> })
<ide> );
<ide> | 3 |
Javascript | Javascript | remove lookup table from timescale | 1c2a03225ed761e75709a9184c184a697e2ce3cf | <ide><path>src/scales/scale.time.js
<ide> import adapters from '../core/core.adapters';
<ide> import {isFinite, isNullOrUndef, mergeIf, valueOrDefault} from '../helpers/helpers.core';
<ide> import {toRadians} from '../helpers/helpers.math';
<ide> import Scale from '../core/core.scale';
<del>import {_arrayUnique, _filterBetween, _lookup, _lookupByKey} from '../helpers/helpers.collection';
<add>import {_arrayUnique, _filterBetween, _lookup} from '../helpers/helpers.collection';
<ide>
<ide> /**
<ide> * @typedef { import("../core/core.adapters").Unit } Unit
<ide> function parse(scale, input) {
<ide> return +value;
<ide> }
<ide>
<del>/**
<del> * Linearly interpolates the given source `value` using the table items `skey` values and
<del> * returns the associated `tkey` value. For example, interpolate(table, 'time', 42, 'pos')
<del> * returns the position for a timestamp equal to 42. If value is out of bounds, values at
<del> * index [0, 1] or [n - 1, n] are used for the interpolation.
<del> * @param {object} table
<del> * @param {string} skey
<del> * @param {number} sval
<del> * @param {string} tkey
<del> * @return {object}
<del> */
<del>function interpolate(table, skey, sval, tkey) {
<del> const {lo, hi} = _lookupByKey(table, skey, sval);
<del>
<del> // Note: the lookup table ALWAYS contains at least 2 items (min and max)
<del> const prev = table[lo];
<del> const next = table[hi];
<del>
<del> const span = next[skey] - prev[skey];
<del> const ratio = span ? (sval - prev[skey]) / span : 0;
<del> const offset = (next[tkey] - prev[tkey]) * ratio;
<del>
<del> return prev[tkey] + offset;
<del>}
<del>
<ide> /**
<ide> * Figures out what unit results in an appropriate number of auto-generated ticks
<ide> * @param {Unit} minUnit
<ide> function addTick(timestamps, ticks, time) {
<ide> ticks[timestamp] = true;
<ide> }
<ide>
<del>/**
<del> * Returns the start and end offsets from edges in the form of {start, end}
<del> * where each value is a relative width to the scale and ranges between 0 and 1.
<del> * They add extra margins on the both sides by scaling down the original scale.
<del> * Offsets are added when the `offset` option is true.
<del> * @param {object} table
<del> * @param {number[]} timestamps
<del> * @param {number} min
<del> * @param {number} max
<del> * @param {object} options
<del> * @return {object}
<del> */
<del>function computeOffsets(table, timestamps, min, max, options) {
<del> let start = 0;
<del> let end = 0;
<del> let first, last;
<del>
<del> if (options.offset && timestamps.length) {
<del> first = interpolate(table, 'time', timestamps[0], 'pos');
<del> if (timestamps.length === 1) {
<del> start = 1 - first;
<del> } else {
<del> start = (interpolate(table, 'time', timestamps[1], 'pos') - first) / 2;
<del> }
<del> last = interpolate(table, 'time', timestamps[timestamps.length - 1], 'pos');
<del> if (timestamps.length === 1) {
<del> end = last;
<del> } else {
<del> end = (last - interpolate(table, 'time', timestamps[timestamps.length - 2], 'pos')) / 2;
<del> }
<del> }
<del>
<del> return {start, end, factor: 1 / (start + 1 + end)};
<del>}
<del>
<ide> /**
<ide> * @param {TimeScale} scale
<ide> * @param {object[]} ticks
<ide> class TimeScale extends Scale {
<ide> this._majorUnit = undefined;
<ide> /** @type {object} */
<ide> this._offsets = {};
<del> /** @type {object[]} */
<del> this._table = [];
<ide> }
<ide>
<ide> init(options) {
<ide> class TimeScale extends Scale {
<ide> };
<ide> }
<ide>
<del> /**
<del> * @protected
<del> */
<del> getTimestampsForTable() {
<del> return [this.min, this.max];
<del> }
<del>
<ide> determineDataLimits() {
<ide> const me = this;
<ide> const options = me.options;
<ide> class TimeScale extends Scale {
<ide> min = isFinite(min) && !isNaN(min) ? min : +adapter.startOf(Date.now(), unit);
<ide> max = isFinite(max) && !isNaN(max) ? max : +adapter.endOf(Date.now(), unit) + 1;
<ide>
<del> // Make sure that max is strictly higher than min (required by the lookup table)
<add> // Make sure that max is strictly higher than min (required by the timeseries lookup table)
<ide> me.min = Math.min(min, max);
<ide> me.max = Math.max(min + 1, max);
<ide> }
<ide> class TimeScale extends Scale {
<ide> : determineUnitForFormatting(me, ticks.length, timeOpts.minUnit, me.min, me.max));
<ide> me._majorUnit = !tickOpts.major.enabled || me._unit === 'year' ? undefined
<ide> : determineMajorUnit(me._unit);
<del> me._table = me.buildLookupTable(me.getTimestampsForTable(), min, max);
<del> me._offsets = computeOffsets(me._table, timestamps, min, max, options);
<add> me.initOffsets(timestamps);
<ide>
<ide> if (options.reverse) {
<ide> ticks.reverse();
<ide> class TimeScale extends Scale {
<ide> return ticksFromTimestamps(me, ticks, me._majorUnit);
<ide> }
<ide>
<add> /**
<add> * Returns the start and end offsets from edges in the form of {start, end}
<add> * where each value is a relative width to the scale and ranges between 0 and 1.
<add> * They add extra margins on the both sides by scaling down the original scale.
<add> * Offsets are added when the `offset` option is true.
<add> * @param {number[]} timestamps
<add> * @return {object}
<add> * @protected
<add> */
<add> initOffsets(timestamps) {
<add> const me = this;
<add> let start = 0;
<add> let end = 0;
<add> let first, last;
<add>
<add> if (me.options.offset && timestamps.length) {
<add> first = me.getDecimalForValue(timestamps[0]);
<add> if (timestamps.length === 1) {
<add> start = 1 - first;
<add> } else {
<add> start = (me.getDecimalForValue(timestamps[1]) - first) / 2;
<add> }
<add> last = me.getDecimalForValue(timestamps[timestamps.length - 1]);
<add> if (timestamps.length === 1) {
<add> end = last;
<add> } else {
<add> end = (last - me.getDecimalForValue(timestamps[timestamps.length - 2])) / 2;
<add> }
<add> }
<add>
<add> me._offsets = {start, end, factor: 1 / (start + 1 + end)};
<add> }
<add>
<ide> /**
<ide> * Generates a maximum of `capacity` timestamps between min and max, rounded to the
<ide> * `minor` unit using the given scale time `options`.
<ide> class TimeScale extends Scale {
<ide> return Object.keys(ticks).map(x => +x);
<ide> }
<ide>
<del> /**
<del> * Returns an array of {time, pos} objects used to interpolate a specific `time` or position
<del> * (`pos`) on the scale, by searching entries before and after the requested value. `pos` is
<del> * a decimal between 0 and 1: 0 being the start of the scale (left or top) and 1 the other
<del> * extremity (left + width or top + height). Note that it would be more optimized to directly
<del> * store pre-computed pixels, but the scale dimensions are not guaranteed at the time we need
<del> * to create the lookup table. The table ALWAYS contains at least two items: min and max.
<del> *
<del> * @param {number[]} timestamps - timestamps sorted from lowest to highest.
<del> * @param {number} min
<del> * @param {number} max
<del> * @return {object[]}
<del> * @protected
<del> */
<del> buildLookupTable(timestamps, min, max) {
<del> return [
<del> {time: min, pos: 0},
<del> {time: max, pos: 1}
<del> ];
<del> }
<del>
<ide> /**
<ide> * @param {number} value
<ide> * @return {string}
<ide> class TimeScale extends Scale {
<ide> }
<ide> }
<ide>
<add> /**
<add> * @param {number} value - Milliseconds since epoch (1 January 1970 00:00:00 UTC)
<add> * @return {number}
<add> */
<add> getDecimalForValue(value) {
<add> const me = this;
<add> return (value - me.min) / (me.max - me.min);
<add> }
<add>
<ide> /**
<ide> * @param {number} value - Milliseconds since epoch (1 January 1970 00:00:00 UTC)
<ide> * @return {number}
<ide> */
<ide> getPixelForValue(value) {
<ide> const me = this;
<ide> const offsets = me._offsets;
<del> const pos = interpolate(me._table, 'time', value, 'pos');
<add> const pos = me.getDecimalForValue(value);
<ide> return me.getPixelForDecimal((offsets.start + pos) * offsets.factor);
<ide> }
<ide>
<ide> class TimeScale extends Scale {
<ide> const me = this;
<ide> const offsets = me._offsets;
<ide> const pos = me.getDecimalForPixel(pixel) / offsets.factor - offsets.end;
<del> return interpolate(me._table, 'pos', pos, 'time');
<add> return me.min + pos * (me.max - me.min);
<ide> }
<ide>
<ide> /**
<ide><path>src/scales/scale.timeseries.js
<ide> import TimeScale from './scale.time';
<del>import {_arrayUnique} from '../helpers/helpers.collection';
<add>import {_arrayUnique, _lookupByKey} from '../helpers/helpers.collection';
<add>
<add>/**
<add> * Linearly interpolates the given source `value` using the table items `skey` values and
<add> * returns the associated `tkey` value. For example, interpolate(table, 'time', 42, 'pos')
<add> * returns the position for a timestamp equal to 42. If value is out of bounds, values at
<add> * index [0, 1] or [n - 1, n] are used for the interpolation.
<add> * @param {object} table
<add> * @param {string} skey
<add> * @param {number} sval
<add> * @param {string} tkey
<add> * @return {object}
<add> */
<add>function interpolate(table, skey, sval, tkey) {
<add> const {lo, hi} = _lookupByKey(table, skey, sval);
<add>
<add> // Note: the lookup table ALWAYS contains at least 2 items (min and max)
<add> const prev = table[lo];
<add> const next = table[hi];
<add>
<add> const span = next[skey] - prev[skey];
<add> const ratio = span ? (sval - prev[skey]) / span : 0;
<add> const offset = (next[tkey] - prev[tkey]) * ratio;
<add>
<add> return prev[tkey] + offset;
<add>}
<ide>
<ide> /**
<ide> * @param {number} a
<ide> function sorter(a, b) {
<ide> class TimeSeriesScale extends TimeScale {
<ide>
<ide> /**
<del> * Returns all timestamps
<del> * @protected
<add> * @param {object} props
<ide> */
<del> getTimestampsForTable() {
<del> const me = this;
<del> let timestamps = me._cache.all || [];
<del>
<del> if (timestamps.length) {
<del> return timestamps;
<del> }
<add> constructor(props) {
<add> super(props);
<ide>
<del> const data = me.getDataTimestamps();
<del> const label = me.getLabelTimestamps();
<del> if (data.length && label.length) {
<del> // If combining labels and data (data might not contain all labels),
<del> // we need to recheck uniqueness and sort
<del> timestamps = _arrayUnique(data.concat(label).sort(sorter));
<del> } else {
<del> timestamps = data.length ? data : label;
<del> }
<del> timestamps = me._cache.all = timestamps;
<add> /** @type {object[]} */
<add> this._table = [];
<add> }
<ide>
<del> return timestamps;
<add> initOffsets(timestamps) {
<add> const me = this;
<add> me._table = me.buildLookupTable();
<add> super.initOffsets(timestamps);
<ide> }
<ide>
<ide> /**
<ide> class TimeSeriesScale extends TimeScale {
<ide> * store pre-computed pixels, but the scale dimensions are not guaranteed at the time we need
<ide> * to create the lookup table. The table ALWAYS contains at least two items: min and max.
<ide> *
<del> * @param {number[]} timestamps - timestamps sorted from lowest to highest.
<del> * @param {number} min
<del> * @param {number} max
<ide> * @return {object[]}
<ide> * @protected
<ide> */
<del> buildLookupTable(timestamps, min, max) {
<add> buildLookupTable() {
<add> const me = this;
<add> const {min, max} = me;
<add> const timestamps = me._getTimestampsForTable();
<ide> if (!timestamps.length) {
<ide> return [
<ide> {time: min, pos: 0},
<ide> class TimeSeriesScale extends TimeScale {
<ide> return table;
<ide> }
<ide>
<add> /**
<add> * Returns all timestamps
<add> * @private
<add> */
<add> _getTimestampsForTable() {
<add> const me = this;
<add> let timestamps = me._cache.all || [];
<add>
<add> if (timestamps.length) {
<add> return timestamps;
<add> }
<add>
<add> const data = me.getDataTimestamps();
<add> const label = me.getLabelTimestamps();
<add> if (data.length && label.length) {
<add> // If combining labels and data (data might not contain all labels),
<add> // we need to recheck uniqueness and sort
<add> timestamps = _arrayUnique(data.concat(label).sort(sorter));
<add> } else {
<add> timestamps = data.length ? data : label;
<add> }
<add> timestamps = me._cache.all = timestamps;
<add>
<add> return timestamps;
<add> }
<add>
<add> /**
<add> * @param {number} value - Milliseconds since epoch (1 January 1970 00:00:00 UTC)
<add> * @return {number}
<add> */
<add> getDecimalForValue(value) {
<add> return interpolate(this._table, 'time', value, 'pos');
<add> }
<add>
<ide> /**
<ide> * @protected
<ide> */
<ide> class TimeSeriesScale extends TimeScale {
<ide> // We could assume labels are in order and unique - but let's not
<ide> return (me._cache.labels = timestamps);
<ide> }
<add>
<add> /**
<add> * @param {number} pixel
<add> * @return {number}
<add> */
<add> getValueForPixel(pixel) {
<add> const me = this;
<add> const offsets = me._offsets;
<add> const pos = me.getDecimalForPixel(pixel) / offsets.factor - offsets.end;
<add> return interpolate(me._table, 'pos', pos, 'time');
<add> }
<ide> }
<ide>
<ide> TimeSeriesScale.id = 'timeseries'; | 2 |
Javascript | Javascript | avoid innertext for better newline behavior | b98f1adf1acc18837af498c86a617858548abe28 | <ide><path>src/browser/ReactDOMIDOperations.js
<ide> var DOMPropertyOperations = require('DOMPropertyOperations');
<ide> var ReactMount = require('ReactMount');
<ide> var ReactPerf = require('ReactPerf');
<ide>
<del>var getTextContentAccessor = require('getTextContentAccessor');
<ide> var invariant = require('invariant');
<ide>
<ide> /**
<ide> var INVALID_PROPERTY_ERRORS = {
<ide> style: '`style` must be set using `updateStylesByID()`.'
<ide> };
<ide>
<del>/**
<del> * The DOM property to use when setting text content.
<del> *
<del> * @type {string}
<del> * @private
<del> */
<del>var textContentAccessor = getTextContentAccessor();
<del>
<ide> var useWhitespaceWorkaround;
<ide>
<ide> /**
<ide> var ReactDOMIDOperations = {
<ide> 'updateTextContentByID',
<ide> function(id, content) {
<ide> var node = ReactMount.getNode(id);
<del> node[textContentAccessor] = content;
<add> DOMChildrenOperations.updateTextContent(node, content);
<ide> }
<ide> ),
<ide>
<ide><path>src/browser/dom/DOMChildrenOperations.js
<ide> function insertChildAt(parentNode, childNode, index) {
<ide> }
<ide> }
<ide>
<add>/**
<add> * Sets the text content of `node` to `text`.
<add> *
<add> * @param {DOMElement} node Node to change
<add> * @param {string} text New text content
<add> */
<add>var updateTextContent;
<add>if (textContentAccessor === 'textContent') {
<add> updateTextContent = function(node, text) {
<add> node.textContent = text;
<add> };
<add>} else {
<add> updateTextContent = function(node, text) {
<add> // In order to preserve newlines correctly, we can't use .innerText to set
<add> // the contents (see #1080), so we empty the element then append a text node
<add> while (node.firstChild) {
<add> node.removeChild(node.firstChild);
<add> }
<add> if (text) {
<add> var doc = node.ownerDocument || document;
<add> node.appendChild(doc.createTextNode(text));
<add> }
<add> };
<add>}
<add>
<ide> /**
<ide> * Operations for updating with DOM children.
<ide> */
<ide> var DOMChildrenOperations = {
<ide>
<ide> dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
<ide>
<add> updateTextContent: updateTextContent,
<add>
<ide> /**
<ide> * Updates a component's children by processing a series of updates. The
<ide> * update configurations are each expected to have a `parentNode` property.
<ide> var DOMChildrenOperations = {
<ide> );
<ide> break;
<ide> case ReactMultiChildUpdateTypes.TEXT_CONTENT:
<del> update.parentNode[textContentAccessor] = update.textContent;
<add> updateTextContent(
<add> update.parentNode,
<add> update.textContent
<add> );
<ide> break;
<ide> case ReactMultiChildUpdateTypes.REMOVE_NODE:
<ide> // Already removed by the for-loop above. | 2 |
Javascript | Javascript | use const instead of var in vue instance | 4ee51720a355351f13b678663643cb35c958b576 | <ide><path>resources/assets/js/app.js
<ide> require('./bootstrap');
<ide>
<ide> Vue.component('example', require('./components/Example.vue'));
<ide>
<del>var app = new Vue({
<add>const app = new Vue({
<ide> el: 'body'
<ide> }); | 1 |
Javascript | Javascript | add no-op comment to make it more clear | 0f57f0b5f195548a1ce2d40215ffb95fe9025e55 | <ide><path>lib/dependencies/HarmonyCompatibilityDependency.js
<ide> HarmonyCompatibilityDependency.Template = class HarmonyExportDependencyTemplate
<ide> * @param {DependencyTemplates} dependencyTemplates the dependency templates
<ide> * @returns {void}
<ide> */
<del> apply(dependency, source, runtimeTemplate, dependencyTemplates) {}
<add> apply(dependency, source, runtimeTemplate, dependencyTemplates) {
<add> // no-op
<add> }
<ide>
<ide> /**
<ide> * @param {Dependency} dependency the dependency for which the template should be applied | 1 |
PHP | PHP | fix remaining phpcs errors | a0fec85f6445a915db0859933da7ac652abe764b | <ide><path>src/Routing/RouteBuilder.php
<ide> public function plugin($name, $options = [], $callback = null) {
<ide> * @param callable $callback The callback to invoke that builds the plugin routes
<ide> * Only required when $params is defined.
<ide> * @return void
<add> * @throws \InvalidArgumentException when there is no callable parameter.
<ide> */
<ide> public function scope($path, $params, $callback) {
<ide> if ($callback === null) {
<ide><path>src/Routing/RouteCollection.php
<ide> class RouteCollection {
<ide> * @param \Cake\Routing\Route\Route $route The route object to add.
<ide> * @param array $options Addtional options for the route. Primarily for the
<ide> * `_name` option, which enables named routes.
<add> * @return void
<ide> */
<ide> public function add(Route $route, $options = []) {
<ide> $this->_routes[] = $route;
<ide><path>src/Routing/Router.php
<ide> public static function prefix($name, $callback) {
<ide> * Routes connected in the scoped collection will have the correct path segment
<ide> * prepended, and have a matching plugin routing key set.
<ide> *
<del> * @param string $path The path name to use for the prefix.
<del> * @param array|callable $options Either the options to use, or a callback.
<add> * @param string $name The plugin name to build routes for
<add> * @param array|callable $options Either the options to use, or a callback
<ide> * @param callable $callback The callback to invoke that builds the plugin routes.
<del> * Only required when $options is defined.
<add> * Only required when $options is defined
<ide> * @return void
<ide> */
<ide> public static function plugin($name, $options = [], $callback = null) {
<ide><path>src/View/Form/EntityContext.php
<ide> protected function _getValidator($parts) {
<ide> * Get the table instance from a property path
<ide> *
<ide> * @param array $parts Each one of the parts in a path for a field name
<del> * @param bool $rootFallback
<add> * @param bool $rootFallback Whether or not to fallback to the root entity.
<ide> * @return \Cake\ORM\Table|bool Table instance or false
<ide> */
<ide> protected function _getTable($parts, $rootFallback = true) {
<ide><path>tests/TestCase/Controller/Component/FlashComponentTest.php
<ide> */
<ide> namespace Cake\Test\TestCase\Controller\Component;
<ide>
<add>use Cake\Event\Event;
<ide> use Cake\Controller\ComponentRegistry;
<ide> use Cake\Controller\Component\FlashComponent;
<ide> use Cake\Controller\Controller;
<ide> use Cake\Core\Configure;
<ide> use Cake\Network\Request;
<del>use Cake\Event\Event;
<ide> use Cake\Network\Session;
<ide> use Cake\TestSuite\TestCase;
<ide>
<ide> /**
<ide> * FlashComponentTest class
<del> *
<ide> */
<ide> class FlashComponentTest extends TestCase {
<ide>
<ide><path>tests/TestCase/Network/SocketTest.php
<ide> */
<ide> namespace Cake\Test\TestCase\Network;
<ide>
<del>use Cake\Network\Socket;
<ide> use Cake\Network\Error\SocketException;
<add>use Cake\Network\Socket;
<ide> use Cake\TestSuite\TestCase;
<ide>
<ide> /**
<ide><path>tests/TestCase/ORM/QueryRegressionTest.php
<ide> public function testNullableTimeColumn() {
<ide> $this->assertNull($entity->created);
<ide> }
<ide>
<del>
<ide> /**
<ide> * Test for https://github.com/cakephp/cakephp/issues/3626
<ide> *
<ide><path>tests/TestCase/Routing/RouteBuilderTest.php
<ide>
<ide> use Cake\Routing\RouteBuilder;
<ide> use Cake\Routing\RouteCollection;
<del>use Cake\Routing\Route\Route;
<ide> use Cake\Routing\Router;
<add>use Cake\Routing\Route\Route;
<ide> use Cake\TestSuite\TestCase;
<ide>
<ide> /**
<ide><path>tests/TestCase/Routing/RouteCollectionTest.php
<ide> */
<ide> namespace Cake\Test\TestCase\Routing;
<ide>
<del>use Cake\Routing\Route\Route;
<del>use Cake\Routing\Router;
<ide> use Cake\Routing\RouteBuilder;
<ide> use Cake\Routing\RouteCollection;
<add>use Cake\Routing\Router;
<add>use Cake\Routing\Route\Route;
<ide> use Cake\TestSuite\TestCase;
<ide>
<ide> class RouteCollectionTest extends TestCase { | 9 |
PHP | PHP | add @link to shell docblocks | bb51b0f4974bba43bf1df1c1ebab399d204e2645 | <ide><path>lib/Cake/Console/Shell.php
<ide> class Shell extends Object {
<ide> * Contains tasks to load and instantiate
<ide> *
<ide> * @var array
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::$tasks
<ide> */
<ide> public $tasks = array();
<ide>
<ide> class Shell extends Object {
<ide> * Contains models to load and instantiate
<ide> *
<ide> * @var array
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::$uses
<ide> */
<ide> public $uses = array();
<ide>
<ide> class Shell extends Object {
<ide> * @param ConsoleOutput $stdout A ConsoleOutput object for stdout.
<ide> * @param ConsoleOutput $stderr A ConsoleOutput object for stderr.
<ide> * @param ConsoleInput $stdin A ConsoleInput object for stdin.
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell
<ide> */
<ide> public function __construct($stdout = null, $stderr = null, $stdin = null) {
<ide> if ($this->name == null) {
<ide> public function __construct($stdout = null, $stderr = null, $stdin = null) {
<ide> * allows configuration of tasks prior to shell execution
<ide> *
<ide> * @return void
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::initialize
<ide> */
<ide> public function initialize() {
<ide> $this->_loadModels();
<ide> public function initialize() {
<ide> * or otherwise modify the pre-command flow.
<ide> *
<ide> * @return void
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::startup
<ide> */
<ide> public function startup() {
<ide> $this->_welcome();
<ide> public function loadTasks() {
<ide> *
<ide> * @param string $task The task name to check.
<ide> * @return boolean Success
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::hasTask
<ide> */
<ide> public function hasTask($task) {
<ide> return isset($this->_taskMap[Inflector::camelize($task)]);
<ide> public function hasTask($task) {
<ide> *
<ide> * @param string $name The method name to check.
<ide> * @return boolean
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::hasMethod
<ide> */
<ide> public function hasMethod($name) {
<ide> try {
<ide> public function hasMethod($name) {
<ide> * `return $this->dispatchShell('schema', 'create', 'i18n', '--dry');`
<ide> *
<ide> * @return mixed The return of the other shell.
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::dispatchShell
<ide> */
<ide> public function dispatchShell() {
<ide> $args = func_get_args();
<ide> public function dispatchShell() {
<ide> * and the shell has a `main()` method, that will be called instead.
<ide> * @param array $argv Array of arguments to run the shell with. This array should be missing the shell name.
<ide> * @return void
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::runCommand
<ide> */
<ide> public function runCommand($command, $argv) {
<ide> $isTask = $this->hasTask($command);
<ide> protected function _displayHelp($command) {
<ide> * By overriding this method you can configure the ConsoleOptionParser before returning it.
<ide> *
<ide> * @return ConsoleOptionParser
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::getOptionParser
<ide> */
<ide> public function getOptionParser() {
<ide> $parser = new ConsoleOptionParser($this->name);
<ide> public function __get($name) {
<ide> * @param mixed $options Array or string of options.
<ide> * @param string $default Default input value.
<ide> * @return mixed Either the default value, or the user-provided input.
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::in
<ide> */
<ide> public function in($prompt, $options = null, $default = null) {
<ide> if (!$this->interactive) {
<ide> protected function _getInput($prompt, $options, $default) {
<ide> * @param mixed $options Array of options to use, or an integer to wrap the text to.
<ide> * @return string Wrapped / indented text
<ide> * @see String::wrap()
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::wrapText
<ide> */
<ide> public function wrapText($text, $options = array()) {
<ide> return String::wrap($text, $options);
<ide> public function wrapText($text, $options = array()) {
<ide> * @param integer $newlines Number of newlines to append
<ide> * @param integer $level The message's output level, see above.
<ide> * @return integer|boolean Returns the number of bytes returned from writing to stdout.
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::out
<ide> */
<ide> public function out($message = null, $newlines = 1, $level = Shell::NORMAL) {
<ide> $currentLevel = Shell::NORMAL;
<ide> public function out($message = null, $newlines = 1, $level = Shell::NORMAL) {
<ide> * @param mixed $message A string or a an array of strings to output
<ide> * @param integer $newlines Number of newlines to append
<ide> * @return void
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::err
<ide> */
<ide> public function err($message = null, $newlines = 1) {
<ide> $this->stderr->write($message, $newlines);
<ide> public function err($message = null, $newlines = 1) {
<ide> *
<ide> * @param integer $multiplier Number of times the linefeed sequence should be repeated
<ide> * @return string
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::nl
<ide> */
<ide> public function nl($multiplier = 1) {
<ide> return str_repeat(ConsoleOutput::LF, $multiplier);
<ide> public function nl($multiplier = 1) {
<ide> * @param integer $newlines Number of newlines to pre- and append
<ide> * @param integer $width Width of the line, defaults to 63
<ide> * @return void
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::hr
<ide> */
<ide> public function hr($newlines = 0, $width = 63) {
<ide> $this->out(null, $newlines);
<ide> public function hr($newlines = 0, $width = 63) {
<ide> * @param string $title Title of the error
<ide> * @param string $message An optional error message
<ide> * @return void
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::error
<ide> */
<ide> public function error($title, $message = null) {
<ide> $this->err(__d('cake_console', '<error>Error:</error> %s', $title));
<ide> public function error($title, $message = null) {
<ide> * Clear the console
<ide> *
<ide> * @return void
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::clear
<ide> */
<ide> public function clear() {
<ide> if (empty($this->params['noclear'])) {
<ide> public function clear() {
<ide> * @param string $path Where to put the file.
<ide> * @param string $contents Content to put in the file.
<ide> * @return boolean Success
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::createFile
<ide> */
<ide> public function createFile($path, $contents) {
<ide> $path = str_replace(DS . DS, DS, $path);
<ide> protected function _checkUnitTest() {
<ide> *
<ide> * @param string $file Absolute file path
<ide> * @return string short path
<add> * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::shortPath
<ide> */
<ide> public function shortPath($file) {
<ide> $shortPath = str_replace(ROOT, null, $file); | 1 |
Python | Python | fix merge conflict | dc92abc1101a6c445dd6dcc910ee3c7427f6fb50 | <ide><path>tests/keras/preprocessing/image_test.py
<ide> def test_image_data_generator(self, tmpdir):
<ide> vertical_flip=True)
<ide> generator.fit(images, augment=True)
<ide>
<add> for x, y in generator.flow(images, np.arange(images.shape[0]),
<add> shuffle=False, save_to_dir=str(tmpdir),
<add> batch_size=3):
<add> assert x.shape == images[:3].shape
<add> assert list(y) == [0, 1, 2]
<add> break
<add>
<add> # Test with `shuffle=True`
<ide> for x, y in generator.flow(images, np.arange(images.shape[0]),
<ide> shuffle=True, save_to_dir=str(tmpdir),
<ide> batch_size=3):
<ide> assert x.shape == images[:3].shape
<add> # Check that the sequence is shuffled.
<add> assert list(y) != [0, 1, 2]
<ide> break
<ide>
<ide> # Test `flow` behavior as Sequence
<ide> seq = generator.flow(images, np.arange(images.shape[0]),
<del> shuffle=True, save_to_dir=str(tmpdir),
<add> shuffle=False, save_to_dir=str(tmpdir),
<ide> batch_size=3)
<ide> assert len(seq) == images.shape[0] // 3 + 1
<ide> x, y = seq[0]
<ide> assert x.shape == images[:3].shape
<add> assert list(y) == [0, 1, 2]
<add>
<add> # Test with `shuffle=True`
<add> seq = generator.flow(images, np.arange(images.shape[0]),
<add> shuffle=True, save_to_dir=str(tmpdir),
<add> batch_size=3, seed=123)
<add> x, y = seq[0]
<add> # Check that the sequence is shuffled.
<add> assert list(y) != [0, 1, 2]
<add>
<add> # `on_epoch_end` should reshuffle the sequence.
<add> seq.on_epoch_end()
<add> x2, y2 = seq[0]
<add> assert list(y) != list(y2)
<ide>
<ide> def test_image_data_generator_invalid_data(self):
<ide> generator = image.ImageDataGenerator( | 1 |
Text | Text | fix minor issues in `updating.md` | 2ce6e8de53adc98dd3ae80fa7c74b38eb352bc3a | <ide><path>UPDATING.md
<ide> in `SubDagOperator`.
<ide>
<ide> #### `airflow.providers.http.operators.http.SimpleHttpOperator`
<ide>
<del>#### `airflow.providers.http.operators.http.SimpleHttpOperator`
<del>
<ide> The `do_xcom_push` flag (a switch to push the result of an operator to xcom or not) was appearing in different incarnations in different operators. It's function has been unified under a common name (`do_xcom_push`) on `BaseOperator`. This way it is also easy to globally disable pushing results to xcom.
<ide>
<ide> The following operators were affected:
<ide> If you want to install integration for Microsoft Azure, then instead of
<ide> pip install 'apache-airflow[azure_blob_storage,azure_data_lake,azure_cosmos,azure_container_instances]'
<ide> ```
<ide>
<del>you should execute `pip install 'apache-airflow[azure]'`
<add>you should run `pip install 'apache-airflow[microsoft.azure]'`
<ide>
<ide> If you want to install integration for Amazon Web Services, then instead of
<ide> `pip install 'apache-airflow[s3,emr]'`, you should execute `pip install 'apache-airflow[aws]'` | 1 |
PHP | PHP | implement array sessions on certain callbacks | 7b1b90e5ee8420758c5c880d5d6ec92092315b13 | <ide><path>src/Illuminate/Foundation/Application.php
<ide> public function shutdown($callback = null)
<ide> }
<ide> }
<ide>
<add> /**
<add> * Register a function for determining when to use array sessions.
<add> *
<add> * @param \Closure $callback
<add> * @return void
<add> */
<add> public function useArraySessions(Closure $callback)
<add> {
<add> $this->bind('session.reject', function() use ($callback)
<add> {
<add> return $callback;
<add> });
<add> }
<add>
<ide> /**
<ide> * Determine if the application has booted.
<ide> *
<ide> public function run(SymfonyRequest $request = null)
<ide> */
<ide> protected function getStackedClient()
<ide> {
<add> $sessionReject = $this->bound('session.reject') ? $this['session.reject'] : null;
<add>
<ide> $client = with(new \Stack\Builder)
<ide> ->push('Illuminate\Cookie\Guard', $this['encrypter'])
<ide> ->push('Illuminate\Cookie\Queue', $this['cookie'])
<del> ->push('Illuminate\Session\Middleware', $this['session']);
<add> ->push('Illuminate\Session\Middleware', $this['session'], $sessionReject);
<ide>
<ide> $this->mergeCustomMiddlewares($client);
<ide>
<ide><path>src/Illuminate/Session/Middleware.php
<ide> <?php namespace Illuminate\Session;
<ide>
<add>use Closure;
<ide> use Carbon\Carbon;
<ide> use Symfony\Component\HttpFoundation\Cookie;
<ide> use Symfony\Component\HttpFoundation\Request;
<ide> class Middleware implements HttpKernelInterface {
<ide> */
<ide> protected $manager;
<ide>
<add> /**
<add> * The callback to determine to use session arrays.
<add> *
<add> * @var \Closure|null
<add> */
<add> protected $reject;
<add>
<ide> /**
<ide> * Create a new session middleware.
<ide> *
<ide> * @param \Symfony\Component\HttpKernel\HttpKernelInterface $app
<ide> * @param \Illuminate\Session\SessionManager $manager
<add> * @param \Closure|null $reject
<ide> * @return void
<ide> */
<del> public function __construct(HttpKernelInterface $app, SessionManager $manager)
<add> public function __construct(HttpKernelInterface $app, SessionManager $manager, Closure $reject = null)
<ide> {
<ide> $this->app = $app;
<add> $this->reject = $reject;
<ide> $this->manager = $manager;
<ide> }
<ide>
<ide> public function __construct(HttpKernelInterface $app, SessionManager $manager)
<ide> */
<ide> public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
<ide> {
<add> $this->checkRequestForArraySessions($request);
<add>
<ide> // If a session driver has been configured, we will need to start the session here
<ide> // so that the data is ready for an application. Note that the Laravel sessions
<ide> // do not make use of PHP "native" sessions in any way since they are crappy.
<ide> public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
<ide> return $response;
<ide> }
<ide>
<add> /**
<add> * Check the request and reject callback for array sessions.
<add> *
<add> * @param \Symfony\Component\HttpFoundation\Request $request
<add> * @return void
<add> */
<add> public function checkRequestForArraySessions(Request $request)
<add> {
<add> if (is_null($this->reject)) return;
<add>
<add> if (call_user_func($this->reject, $request))
<add> {
<add> $this->manager->setDefaultDriver('array');
<add> }
<add> }
<add>
<ide> /**
<ide> * Start the session for the given request.
<ide> *
<ide><path>tests/Session/SessionMiddlewareTest.php
<ide> public function testSessionIsNotUsedWhenNoDriver()
<ide> $this->assertTrue($response === $middleResponse);
<ide> }
<ide>
<add>
<add> public function testCheckingForRequestUsingArraySessions()
<add> {
<add> $middleware = new Illuminate\Session\Middleware(
<add> m::mock('Symfony\Component\HttpKernel\HttpKernelInterface'),
<add> $manager = m::mock('Illuminate\Session\SessionManager'),
<add> function() { return true; }
<add> );
<add>
<add> $manager->shouldReceive('setDefaultDriver')->once()->with('array');
<add>
<add> $middleware->checkRequestForArraySessions(new Symfony\Component\HttpFoundation\Request);
<add> }
<add>
<ide> }
<ide>\ No newline at end of file | 3 |
Python | Python | unify return_code interface for task runner | 603c555e1f0f607edb3f171ca5d206f60056c656 | <ide><path>airflow/task/task_runner/base_task_runner.py
<ide> def start(self):
<ide> """Start running the task instance in a subprocess."""
<ide> raise NotImplementedError()
<ide>
<del> def return_code(self) -> Optional[int]:
<add> def return_code(self, timeout: int = 0) -> Optional[int]:
<ide> """
<ide> :return: The return code associated with running the task instance or
<ide> None if the task is not yet done.
<ide><path>airflow/task/task_runner/cgroup_task_runner.py
<ide> import datetime
<ide> import os
<ide> import uuid
<add>from typing import Optional
<ide>
<ide> import psutil
<ide> from cgroupspy import trees
<ide> def start(self):
<ide> self.log.debug("Starting task process with cgroups cpu,memory: %s", cgroup_name)
<ide> self.process = self.run_command(['cgexec', '-g', f'cpu,memory:{cgroup_name}'])
<ide>
<del> def return_code(self):
<add> def return_code(self, timeout: int = 0) -> Optional[int]:
<ide> return_code = self.process.poll()
<ide> # TODO(plypaul) Monitoring the control file in the cgroup fs is better than
<ide> # checking the return code here. The PR to use this is here: | 2 |
Text | Text | fix doc syntax | 0997cf71ccd711afe956d0d40e1a7053d698fff2 | <ide><path>docs/02-Scales.md
<ide> var chartInstance = new Chart(ctx, {
<ide> type: 'line',
<ide> data: data,
<ide> options: {
<del> xAxes: [{
<del> type: 'logarithmic',
<del> position: 'bottom',
<del> ticks: {
<del> min: 1,
<del> max: 1000
<del> }
<del> }]
<add> scales: {
<add> xAxes: [{
<add> type: 'logarithmic',
<add> position: 'bottom',
<add> ticks: {
<add> min: 1,
<add> max: 1000
<add> }
<add> }]
<add> }
<ide> }
<ide> })
<ide> ``` | 1 |
Go | Go | add testruncapaddsystime test case | a5e2fa2b2e30cf515d22dee532ae33d5ab695008 | <ide><path>integration-cli/docker_cli_run_test.go
<ide> func (s *DockerSuite) TestAppArmorTraceSelf(c *check.C) {
<ide> c.Fatal("ptrace of self failed.")
<ide> }
<ide> }
<add>
<add>func (s *DockerSuite) TestRunCapAddSYSTIME(c *check.C) {
<add> dockerCmd(c, "run", "--cap-drop=ALL", "--cap-add=SYS_TIME", "busybox", "sh", "-c", "grep ^CapEff /proc/self/status | sed 's/^CapEff:\t//' | grep ^0000000002000000$")
<add>} | 1 |
Ruby | Ruby | convert update report to use composition | 7cd31377a4969b96ed8da9d87f5a70f5a16aed61 | <ide><path>Library/Homebrew/cmd/update.rb
<ide> def update
<ide> ensure
<ide> link_tap_formula(tapped_formulae)
<ide> end
<del> report.merge!(master_updater.report)
<add> report.update(master_updater.report)
<ide>
<ide> # rename Taps directories
<ide> # this procedure will be removed in the future if it seems unnecessasry
<ide> def update
<ide> rescue
<ide> onoe "Failed to update tap: #{user.basename}/#{repo.basename.sub("homebrew-", "")}"
<ide> else
<del> report.merge!(updater.report) do |key, oldval, newval|
<add> report.update(updater.report) do |key, oldval, newval|
<ide> oldval.concat(newval)
<ide> end
<ide> end
<ide> def `(cmd)
<ide> end
<ide>
<ide>
<del>class Report < Hash
<add>class Report
<add> def initialize
<add> @hash = {}
<add> end
<add>
<add> def fetch(*args, &block)
<add> @hash.fetch(*args, &block)
<add> end
<add>
<add> def update(*args, &block)
<add> @hash.update(*args, &block)
<add> end
<add>
<add> def empty?
<add> @hash.empty?
<add> end
<ide>
<ide> def dump
<ide> # Key Legend: Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R)
<ide> def dump
<ide> dump_formula_report :M, "Updated Formulae"
<ide> dump_formula_report :D, "Deleted Formulae"
<ide> dump_formula_report :R, "Renamed Formulae"
<del># dump_new_commands
<del># dump_deleted_commands
<ide> end
<ide>
<ide> def tapped_formula_for key
<ide> def dump_formula_report key, title
<ide> puts_columns formula.uniq
<ide> end
<ide> end
<del>
<ide> end
<ide><path>Library/Homebrew/test/test_updater.rb
<ide> def perform_update(diff_output="")
<ide> @updater.in_repo_expect("git rev-parse -q --verify HEAD", "3456cdef")
<ide> @updater.in_repo_expect("git diff-tree -r --raw -M85% 1234abcd 3456cdef", diff_output)
<ide> @updater.pull!
<del> @report.merge!(@updater.report)
<add> @report.update(@updater.report)
<ide> end
<ide> end
<ide> | 2 |
Text | Text | add needs triage label to new issues | 73304ab47575df43b6cba9479179eaa67f667cb5 | <ide><path>.github/ISSUE_TEMPLATE/bug_report.md
<ide> name: "🐛 Bug Report"
<ide> about: Report a reproducible bug or regression in React Native.
<ide> title: ''
<del>labels: 'Bug'
<add>labels: 'Needs: Triage :mag:'
<ide>
<ide> ---
<ide>
<del><!--
<del> Please provide a clear and concise description of what the bug is.
<del> Include screenshots if needed.
<del> Please test using the latest React Native release to make sure your issue has not already been fixed: http://facebook.github.io/react-native/docs/upgrading.html
<del>-->
<add>Description:
<add>
<add> Please provide a clear and concise description of what the bug is. Include screenshots if needed.
<add> Please test using the latest React Native release to make sure your issue has not already been fixed: http://facebook.github.io/react-native/docs/upgrading.html
<add>
<ide>
<ide> React Native version:
<del><!--
<del> Run `react-native info` in your terminal and copy the results here.
<del>-->
<add>
<add> Run `react-native info` in your terminal and copy the results here.
<add>
<ide>
<ide> ## Steps To Reproduce
<ide>
<add> Provide a detailed list of steps that reproduce the issue.
<add> Issues without reproduction steps or code are likely to stall.
<add>
<ide> 1.
<ide> 2.
<ide>
<del><!--
<del> Issues without reproduction steps or code are likely to stall.
<del>-->
<del>
<del>Describe what you expected to happen:
<ide>
<add>## Expected Results
<ide>
<del>Snack, code example, screenshot, or link to a repository:
<add> Describe what you expected to happen.
<ide>
<del><!--
<del> Please provide a Snack (https://snack.expo.io/), a link to a repository on GitHub, or
<del> provide a minimal code example that reproduces the problem.
<del> You may provide a screenshot of the application if you think it is relevant to your bug report.
<del> Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve. --
<del>-->
<add>## Snack, code example, screenshot, or link to a repository:
<ide>
<add> Please provide a Snack (https://snack.expo.io/), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem.
<add> You may provide a screenshot of the application if you think it is relevant to your bug report.
<add> Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve
<ide><path>.github/ISSUE_TEMPLATE/question.md
<ide> ---
<ide> name: "🤔 Questions and Help"
<del>about: The issue tracker is not for questions. Please ask questions on https://stackoverflow.com/questions/tagged/react-native.
<add>about: Please ask questions at https://stackoverflow.com/questions/tagged/react-native.
<ide> title: 'Question: '
<ide> labels: 'Type: Question'
<ide> | 2 |
PHP | PHP | update doc block and fix phpcs error | 8d605f4d4aa563021f9fd95409c90144eca9f085 | <ide><path>src/ORM/Table.php
<ide> public function validateUnique($value, array $options, array $context = []) {
<ide> * the rules checker.
<ide> *
<ide> * @param \Cake\Datasource\EntityInterface $entity The entity to check for validity.
<add> * @param string $operation The operation being run. Either 'create', 'update' or 'delete'.
<ide> * @param \ArrayObject|array $options The options To be passed to the rules.
<ide> * @param string $operation Either 'create, 'update' or 'delete'.
<ide> * @return bool | 1 |
Javascript | Javascript | add bigint test for isdeepstrictequal | 935b1af9907cd166a1a8b40fb83fdef411110e91 | <ide><path>test/parallel/test-util-isDeepStrictEqual.js
<ide> assert.strictEqual(
<ide> notUtilIsDeepStrict(boxedString, Object('test'));
<ide> boxedSymbol.slow = true;
<ide> notUtilIsDeepStrict(boxedSymbol, {});
<add> utilIsDeepStrict(Object(BigInt(1)), Object(BigInt(1)));
<add> notUtilIsDeepStrict(Object(BigInt(1)), Object(BigInt(2)));
<ide> }
<ide>
<ide> // Minus zero | 1 |
Text | Text | fix small typo in validation docs | 5a4d622bb71482631d2b142163d6b9601162b289 | <ide><path>laravel/documentation/validation.md
<ide> <a name="the-basics"></a>
<ide> ## The Basics
<ide>
<del>Almost every interactive web application needs to validate data. For instance, a registration form probably requires the password to be confirmed. Maybe the e-mail address must be unique. Validating data can be a cumbersome process. Thankfully, it isn't in Laravel. The Validator class provides as awesome array of validation helpers to make validating your data a breeze. Let's walk through an example:
<add>Almost every interactive web application needs to validate data. For instance, a registration form probably requires the password to be confirmed. Maybe the e-mail address must be unique. Validating data can be a cumbersome process. Thankfully, it isn't in Laravel. The Validator class provides an awesome array of validation helpers to make validating your data a breeze. Let's walk through an example:
<ide>
<ide> #### Get an array of data you want to validate:
<ide> | 1 |
Javascript | Javascript | remove unused lines | 58bb7cea41a024f6c0fede4a32de579d7fb85727 | <ide><path>src/__tests__/storeStress-test.js
<ide> describe('StoreStress', () => {
<ide> const a = <A key="a" />;
<ide> const b = <B key="b" />;
<ide> const c = <C key="c" />;
<del> // const x = <X key="x" />;
<del> // const y = <Y key="y" />;
<ide> const z = <Z key="z" />;
<ide>
<ide> // prettier-ignore | 1 |
Javascript | Javascript | improve tests, implementation of weeksinweekyear | 264445c181983cbb5b14cfdc7a25c468080989ed | <ide><path>src/lib/units/week-year.js
<ide> export function getISOWeeksInYear() {
<ide> return weeksInYear(this.isoWeekday(THURSDAY).year(), 1, 4);
<ide> }
<ide>
<del>export function getWeeksInYear () {
<del> return getWeeksInGivenYear.call(this, this.year());
<del>}
<del>
<del>export function getWeeksInWeekYear () {
<del> return getWeeksInGivenYear.call(this, this.weekYear());
<add>export function getWeeksInYear() {
<add> let weekInfo = this.localeData()._week;
<add> return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
<ide> }
<ide>
<del>function getWeeksInGivenYear(year) {
<add>export function getWeeksInWeekYear() {
<ide> let weekInfo = this.localeData()._week;
<del> return weeksInYear(year, weekInfo.dow, weekInfo.doy);
<add> return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy);
<ide> }
<ide>
<ide> function getSetWeekYearHelper(input, week, weekday, dow, doy) {
<ide><path>src/test/moment/weeks_in_year.js
<del>import {module, test} from '../qunit';
<add>import { module, test } from '../qunit';
<ide> import moment from '../../moment';
<ide>
<ide> module('weeks in year');
<ide> test('isoWeeksInYear first day of ISO Year', function (assert) {
<ide> test('weeksInYear doy/dow = 1/4', function (assert) {
<ide> moment.locale('1/4', { week: { dow: 1, doy: 4 } });
<ide>
<del> assert.equal(moment([2004]).weeksInYear(), 53, '2004 has 53 weeks');
<del> assert.equal(moment([2005]).weeksInYear(), 52, '2005 has 52 weeks');
<del> assert.equal(moment([2006]).weeksInYear(), 52, '2006 has 52 weeks');
<del> assert.equal(moment([2007]).weeksInYear(), 52, '2007 has 52 weeks');
<del> assert.equal(moment([2008]).weeksInYear(), 52, '2008 has 52 weeks');
<del> assert.equal(moment([2009]).weeksInYear(), 53, '2009 has 53 weeks');
<del> assert.equal(moment([2010]).weeksInYear(), 52, '2010 has 52 weeks');
<del> assert.equal(moment([2011]).weeksInYear(), 52, '2011 has 52 weeks');
<del> assert.equal(moment([2012]).weeksInYear(), 52, '2012 has 52 weeks');
<del> assert.equal(moment([2013]).weeksInYear(), 52, '2013 has 52 weeks');
<del> assert.equal(moment([2014]).weeksInYear(), 52, '2014 has 52 weeks');
<del> assert.equal(moment([2015]).weeksInYear(), 53, '2015 has 53 weeks');
<del> assert.equal(moment([2016]).weeksInYear(), 52, '2016 has 52 weeks');
<del>});
<del>
<del>
<del>test('weeksInWeekYear doy/dow = 1/4', function (assert) {
<del> assert.equal(moment([2004]).weeksInWeekYear(), 52, '2004 has 52 weeks in week year');
<del> assert.equal(moment([2005]).weeksInWeekYear(), 53, '2005 has 53 weeks in week year');
<del> assert.equal(moment([2006]).weeksInWeekYear(), 52, '2006 has 53 weeks in week year');
<del> assert.equal(moment([2007]).weeksInWeekYear(), 52, '2007 has 52 weeks in week year');
<del> assert.equal(moment([2008]).weeksInWeekYear(), 52, '2008 has 52 weeks in week year');
<del> assert.equal(moment([2009]).weeksInWeekYear(), 52, '2009 has 52 weeks in week year');
<del> assert.equal(moment([2010]).weeksInWeekYear(), 52, '2010 has 53 weeks in week year');
<del> assert.equal(moment([2011]).weeksInWeekYear(), 53, '2011 has 53 weeks in week year');
<del> assert.equal(moment([2012]).weeksInWeekYear(), 52, '2012 has 52 weeks in week year');
<del> assert.equal(moment([2013]).weeksInWeekYear(), 52, '2013 has 52 weeks in week year');
<del> assert.equal(moment([2014]).weeksInWeekYear(), 52, '2014 has 52 weeks in week year');
<del> assert.equal(moment([2015]).weeksInWeekYear(), 52, '2015 has 52 weeks in week year');
<del> assert.equal(moment([2016]).weeksInWeekYear(), 53, '2016 has 53 weeks in week year');
<add> assert.equal(moment('2004-01-01').weeksInYear(), 53, '2004 has 53 weeks');
<add> assert.equal(moment('2005-01-01').weeksInYear(), 52, '2005 has 52 weeks');
<add> assert.equal(
<add> moment('2005-01-01').weeksInWeekYear(),
<add> 53,
<add> '2005-01-01 is weekYear 2014, which has 53 weeks'
<add> );
<add> assert.equal(moment('2006-01-01').weeksInYear(), 52, '2006 has 52 weeks');
<add> assert.equal(moment('2007-01-01').weeksInYear(), 52, '2007 has 52 weeks');
<add> assert.equal(moment('2008-01-01').weeksInYear(), 52, '2008 has 52 weeks');
<add> assert.equal(moment('2009-01-01').weeksInYear(), 53, '2009 has 53 weeks');
<add> assert.equal(moment('2010-01-01').weeksInYear(), 52, '2010 has 52 weeks');
<add> assert.equal(
<add> moment('2010-01-01').weeksInWeekYear(),
<add> 53,
<add> '2010-01-01 is weekYear 2009, which has 53 weeks'
<add> );
<add> assert.equal(moment('2011-01-01').weeksInYear(), 52, '2011 has 52 weeks');
<add> assert.equal(moment('2012-01-01').weeksInYear(), 52, '2012 has 52 weeks');
<add> assert.equal(moment('2013-01-01').weeksInYear(), 52, '2013 has 52 weeks');
<add> assert.equal(moment('2014-01-01').weeksInYear(), 52, '2014 has 52 weeks');
<add> assert.equal(moment('2015-01-01').weeksInYear(), 53, '2015 has 53 weeks');
<add> assert.equal(moment('2016-01-01').weeksInYear(), 52, '2016 has 52 weeks');
<add> assert.equal(
<add> moment('2016-01-01').weeksInWeekYear(),
<add> 53,
<add> '2016-01-01 is weekYear 2015, which has 53 weeks'
<add> );
<ide> });
<ide>
<ide> test('weeksInYear doy/dow = 6/12', function (assert) {
<ide> test('weeksInYear doy/dow = 6/12', function (assert) {
<ide> assert.equal(moment([2015]).weeksInYear(), 52, '2015 has 52 weeks');
<ide> });
<ide>
<del>
<ide> test('weeksInYear doy/dow = 1/7', function (assert) {
<ide> moment.locale('1/7', { week: { dow: 1, doy: 7 } });
<ide>
<ide> test('weeksInYear doy/dow = 1/7', function (assert) {
<ide> assert.equal(moment([2016]).weeksInYear(), 52, '2016 has 52 weeks');
<ide> });
<ide>
<del>test('weeksInWeekYear doy/dow = 1/7', function (assert) {
<del> assert.equal(moment([2004]).weeksInWeekYear(), 52, '2004 has 52 weeks in week year');
<del> assert.equal(moment([2005]).weeksInWeekYear(), 53, '2005 has 53 weeks in week year');
<del> assert.equal(moment([2006]).weeksInWeekYear(), 52, '2006 has 52 weeks in week year');
<del> assert.equal(moment([2007]).weeksInWeekYear(), 52, '2007 has 52 weeks in week year');
<del> assert.equal(moment([2008]).weeksInWeekYear(), 52, '2008 has 52 weeks in week year');
<del> assert.equal(moment([2009]).weeksInWeekYear(), 52, '2009 has 52 weeks in week year');
<del> assert.equal(moment([2010]).weeksInWeekYear(), 52, '2010 has 52 weeks in week year');
<del> assert.equal(moment([2011]).weeksInWeekYear(), 53, '2011 has 53 weeks in week year');
<del> assert.equal(moment([2012]).weeksInWeekYear(), 52, '2012 has 52 weeks in week year');
<del> assert.equal(moment([2013]).weeksInWeekYear(), 52, '2013 has 52 weeks in week year');
<del> assert.equal(moment([2014]).weeksInWeekYear(), 52, '2014 has 52 weeks in week year');
<del> assert.equal(moment([2015]).weeksInWeekYear(), 52, '2015 has 52 weeks in week year');
<del> assert.equal(moment([2016]).weeksInWeekYear(), 53, '2016 has 53 weeks in week year');
<del>});
<del>
<ide> test('weeksInYear doy/dow = 0/6', function (assert) {
<ide> moment.locale('0/6', { week: { dow: 0, doy: 6 } });
<ide> | 2 |
Text | Text | add missing comma | 8e7162ca91a704b637852e3a813519a7fcfdbf46 | <ide><path>docs/02-Line-Chart.md
<ide> var data = {
<ide> pointHoverBorderWidth: 2,
<ide>
<ide> // Tension - bezier curve tension of the line. Set to 0 to draw straight Wlines connecting points
<del> tension: 0.1
<add> tension: 0.1,
<ide>
<ide> // The actual data
<ide> data: [65, 59, 80, 81, 56, 55, 40],
<ide> new Chart(ctx, {
<ide> // and the Line chart defaults, but this particular instance will have the x axis not displaying.
<ide> ```
<ide>
<del>We can also change these defaults values for each Line type that is created, this object is available at `Chart.defaults.line`.
<ide>\ No newline at end of file
<add>We can also change these defaults values for each Line type that is created, this object is available at `Chart.defaults.line`. | 1 |
Javascript | Javascript | fix calendar bug related to dst and zones | bd280ada8465fe27858da70627d15d7130406e48 | <ide><path>moment.js
<ide> },
<ide>
<ide> calendar : function () {
<del> var diff = this.diff(moment().zone(this.zone()).startOf('day'), 'days', true),
<add> // We want to compare the start of today, vs this.
<add> // Getting start-of-today depends on whether we're zone'd or not.
<add> var sod = (this._isUTC ? moment().zone(this.zone()) : moment()).startOf('day'),
<add> diff = this.diff(sod, 'days', true),
<ide> format = diff < -6 ? 'sameElse' :
<del> diff < -1 ? 'lastWeek' :
<del> diff < 0 ? 'lastDay' :
<del> diff < 1 ? 'sameDay' :
<del> diff < 2 ? 'nextDay' :
<del> diff < 7 ? 'nextWeek' : 'sameElse';
<add> diff < -1 ? 'lastWeek' :
<add> diff < 0 ? 'lastDay' :
<add> diff < 1 ? 'sameDay' :
<add> diff < 2 ? 'nextDay' :
<add> diff < 7 ? 'nextWeek' : 'sameElse';
<ide> return this.format(this.lang().calendar(format, this));
<ide> },
<ide> | 1 |
Ruby | Ruby | escape issue search string | 0d4260187237c1f8e24f9c223076e84ca4ee442d | <ide><path>Library/Homebrew/utils.rb
<ide> def open url, headers={}, &block
<ide> end
<ide>
<ide> def each_issue_matching(query, &block)
<del> uri = ISSUES_URI + query
<add> uri = ISSUES_URI + uri_escape(query)
<ide> open(uri) { |f| Utils::JSON.load(f.read)['issues'].each(&block) }
<ide> end
<ide>
<add> def uri_escape(query)
<add> if URI.respond_to?(:encode_www_form_component)
<add> URI.encode_www_form_component(query)
<add> else
<add> require "erb"
<add> ERB::Util.url_encode(query)
<add> end
<add> end
<add>
<ide> def issues_for_formula name
<ide> # bit basic as depends on the issue at github having the exact name of the
<ide> # formula in it. Which for stuff like objective-caml is unlikely. So we | 1 |
Python | Python | update databricks api from 2.0 to 2.1 | 8ae878953b183b2689481f5e5806bc2ccca4c509 | <ide><path>airflow/providers/databricks/hooks/databricks.py
<ide> from airflow.exceptions import AirflowException
<ide> from airflow.hooks.base import BaseHook
<ide>
<add>RESTART_CLUSTER_ENDPOINT = ("POST", "api/2.1/clusters/restart")
<add>START_CLUSTER_ENDPOINT = ("POST", "api/2.1/clusters/start")
<add>TERMINATE_CLUSTER_ENDPOINT = ("POST", "api/2.1/clusters/delete")
<add>
<add>RUN_NOW_ENDPOINT = ('POST', 'api/2.1/jobs/run-now')
<add>SUBMIT_RUN_ENDPOINT = ('POST', 'api/2.1/jobs/runs/submit')
<add>GET_RUN_ENDPOINT = ('GET', 'api/2.1/jobs/runs/get')
<add>CANCEL_RUN_ENDPOINT = ('POST', 'api/2.1/jobs/runs/cancel')
<add>
<add>INSTALL_LIBS_ENDPOINT = ('POST', 'api/2.1/libraries/install')
<add>UNINSTALL_LIBS_ENDPOINT = ('POST', 'api/2.1/libraries/uninstall')
<add>
<add>USER_AGENT_HEADER = {'user-agent': f'airflow-{__version__}'}
<add>
<ide> # https://docs.microsoft.com/en-us/azure/databricks/dev-tools/api/latest/aad/service-prin-aad-token#--get-an-azure-active-directory-access-token
<ide> AZURE_TOKEN_SERVICE_URL = "https://login.microsoftonline.com/{}/oauth2/token"
<ide> # https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token
<ide> AZURE_MANAGEMENT_ENDPOINT = "https://management.core.windows.net/"
<ide> DEFAULT_DATABRICKS_SCOPE = "2ff814a6-3304-4ab8-85cb-cd0e6f879c1d"
<ide>
<del>RESTART_CLUSTER_ENDPOINT = ("POST", "api/2.0/clusters/restart")
<del>START_CLUSTER_ENDPOINT = ("POST", "api/2.0/clusters/start")
<del>TERMINATE_CLUSTER_ENDPOINT = ("POST", "api/2.0/clusters/delete")
<del>
<del>RUN_NOW_ENDPOINT = ('POST', 'api/2.0/jobs/run-now')
<del>SUBMIT_RUN_ENDPOINT = ('POST', 'api/2.0/jobs/runs/submit')
<del>GET_RUN_ENDPOINT = ('GET', 'api/2.0/jobs/runs/get')
<del>CANCEL_RUN_ENDPOINT = ('POST', 'api/2.0/jobs/runs/cancel')
<del>USER_AGENT_HEADER = {'user-agent': f'airflow-{__version__}'}
<del>
<del>INSTALL_LIBS_ENDPOINT = ('POST', 'api/2.0/libraries/install')
<del>UNINSTALL_LIBS_ENDPOINT = ('POST', 'api/2.0/libraries/uninstall')
<del>
<ide>
<ide> class RunState:
<ide> """Utility class for the run state concept of Databricks runs."""
<ide><path>tests/providers/databricks/hooks/test_databricks.py
<ide> def run_now_endpoint(host):
<ide> """
<ide> Utility function to generate the run now endpoint given the host.
<ide> """
<del> return f'https://{host}/api/2.0/jobs/run-now'
<add> return f'https://{host}/api/2.1/jobs/run-now'
<ide>
<ide>
<ide> def submit_run_endpoint(host):
<ide> """
<ide> Utility function to generate the submit run endpoint given the host.
<ide> """
<del> return f'https://{host}/api/2.0/jobs/runs/submit'
<add> return f'https://{host}/api/2.1/jobs/runs/submit'
<ide>
<ide>
<ide> def get_run_endpoint(host):
<ide> """
<ide> Utility function to generate the get run endpoint given the host.
<ide> """
<del> return f'https://{host}/api/2.0/jobs/runs/get'
<add> return f'https://{host}/api/2.1/jobs/runs/get'
<ide>
<ide>
<ide> def cancel_run_endpoint(host):
<ide> """
<ide> Utility function to generate the get run endpoint given the host.
<ide> """
<del> return f'https://{host}/api/2.0/jobs/runs/cancel'
<add> return f'https://{host}/api/2.1/jobs/runs/cancel'
<ide>
<ide>
<ide> def start_cluster_endpoint(host):
<ide> """
<ide> Utility function to generate the get run endpoint given the host.
<ide> """
<del> return f'https://{host}/api/2.0/clusters/start'
<add> return f'https://{host}/api/2.1/clusters/start'
<ide>
<ide>
<ide> def restart_cluster_endpoint(host):
<ide> """
<ide> Utility function to generate the get run endpoint given the host.
<ide> """
<del> return f'https://{host}/api/2.0/clusters/restart'
<add> return f'https://{host}/api/2.1/clusters/restart'
<ide>
<ide>
<ide> def terminate_cluster_endpoint(host):
<ide> """
<ide> Utility function to generate the get run endpoint given the host.
<ide> """
<del> return f'https://{host}/api/2.0/clusters/delete'
<add> return f'https://{host}/api/2.1/clusters/delete'
<ide>
<ide>
<ide> def install_endpoint(host):
<ide> """
<ide> Utility function to generate the install endpoint given the host.
<ide> """
<del> return f'https://{host}/api/2.0/libraries/install'
<add> return f'https://{host}/api/2.1/libraries/install'
<ide>
<ide>
<ide> def uninstall_endpoint(host):
<ide> """
<ide> Utility function to generate the uninstall endpoint given the host.
<ide> """
<del> return f'https://{host}/api/2.0/libraries/uninstall'
<add> return f'https://{host}/api/2.1/libraries/uninstall'
<ide>
<ide>
<ide> def create_valid_response_mock(content):
<ide> def test_do_api_call_waits_between_retries(self, mock_sleep):
<ide> def test_do_api_call_patch(self, mock_requests):
<ide> mock_requests.patch.return_value.json.return_value = {'cluster_name': 'new_name'}
<ide> data = {'cluster_name': 'new_name'}
<del> patched_cluster_name = self.hook._do_api_call(('PATCH', 'api/2.0/jobs/runs/submit'), data)
<add> patched_cluster_name = self.hook._do_api_call(('PATCH', 'api/2.1/jobs/runs/submit'), data)
<ide>
<ide> assert patched_cluster_name['cluster_name'] == 'new_name'
<ide> mock_requests.patch.assert_called_once_with( | 2 |
Python | Python | require numscons 0.11 or above | d00fe700a1a0c9a0948a268a0a2145d54b673c0b | <ide><path>numpy/distutils/command/scons.py
<ide> def select_packages(sconspkg, pkglist):
<ide> raise ValueError(msg)
<ide> return common
<ide>
<del>def check_numscons(minver=(0, 10, 2)):
<add>def check_numscons(minver):
<ide> """Check that we can use numscons.
<ide>
<ide> minver is a 3 integers tuple which defines the min version."""
<ide> def run(self):
<ide> # nothing to do, just leave it here.
<ide> return
<ide>
<del> check_numscons(minver=(0, 10, 2))
<add> check_numscons(minver=(0, 11, 0))
<ide>
<ide> # XXX: when a scons script is missing, scons only prints warnings, and
<ide> # does not return a failure (status is 0). We have to detect this from | 1 |
Python | Python | remove unwanted blank line | 362d1343124d0c45d934078d1a8ec118a2ae9ebe | <ide><path>numpy/core/_add_newdocs.py
<ide> def luf(lamdaexpr, *args, **kwargs):
<ide> The pickle protocol used to serialize the array.
<ide> The default is 2 (in order to maintain python 2 support).
<ide>
<del>
<ide> """))
<ide>
<ide> | 1 |
Python | Python | fix error message not formatted in einsum | 3bbd303e7e15577c5c4dd05b7e858d15bc04bc59 | <ide><path>numpy/core/einsumfunc.py
<ide> def einsum_path(*operands, **kwargs):
<ide> sh = operands[tnum].shape
<ide> if len(sh) != len(term):
<ide> raise ValueError("Einstein sum subscript %s does not contain the "
<del> "correct number of indices for operand %d.",
<del> input_subscripts[tnum], tnum)
<add> "correct number of indices for operand %d."
<add> % (input_subscripts[tnum], tnum))
<ide> for cnum, char in enumerate(term):
<ide> dim = sh[cnum]
<ide> if char in dimension_dict.keys():
<ide> if dimension_dict[char] != dim:
<ide> raise ValueError("Size of label '%s' for operand %d does "
<del> "not match previous terms.", char, tnum)
<add> "not match previous terms."
<add> % (char, tnum))
<ide> else:
<ide> dimension_dict[char] = dim
<ide> | 1 |
Go | Go | manage image inspect data in backend | 8fb71ce20894c0c7fbd9ee6058bf2c0e82d6a77c | <ide><path>api/server/router/image/image_routes.go
<ide> import (
<ide> "github.com/docker/docker/api/types/versions"
<ide> "github.com/docker/docker/errdefs"
<ide> "github.com/docker/docker/image"
<del> "github.com/docker/docker/layer"
<ide> "github.com/docker/docker/pkg/ioutils"
<ide> "github.com/docker/docker/pkg/streamformatter"
<ide> specs "github.com/opencontainers/image-spec/specs-go/v1"
<ide> func (ir *imageRouter) deleteImages(ctx context.Context, w http.ResponseWriter,
<ide> }
<ide>
<ide> func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
<del> img, err := ir.backend.GetImage(ctx, vars["name"], opts.GetImageOpts{})
<add> img, err := ir.backend.GetImage(ctx, vars["name"], opts.GetImageOpts{Details: true})
<ide> if err != nil {
<ide> return err
<ide> }
<ide> func (ir *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, er
<ide> }
<ide> }
<ide>
<del> var size int64
<del> var layerMetadata map[string]string
<del> if layerID := img.RootFS.ChainID(); layerID != "" {
<del> l, err := ir.layerStore.Get(layerID)
<del> if err != nil {
<del> return nil, err
<del> }
<del> defer layer.ReleaseAndLog(ir.layerStore, l)
<del> size = l.Size()
<del> layerMetadata, err = l.Metadata()
<del> if err != nil {
<del> return nil, err
<del> }
<del> }
<del>
<ide> comment := img.Comment
<ide> if len(comment) == 0 && len(img.History) > 0 {
<ide> comment = img.History[len(img.History)-1].Comment
<ide> }
<ide>
<del> lastUpdated, err := ir.imageStore.GetLastUpdated(img.ID())
<del> if err != nil {
<del> return nil, err
<del> }
<del>
<ide> return &types.ImageInspect{
<ide> ID: img.ID().String(),
<ide> RepoTags: repoTags,
<ide> func (ir *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, er
<ide> Variant: img.Variant,
<ide> Os: img.OperatingSystem(),
<ide> OsVersion: img.OSVersion,
<del> Size: size,
<del> VirtualSize: size, // TODO: field unused, deprecate
<add> Size: img.Details.Size,
<add> VirtualSize: img.Details.Size, // TODO: field unused, deprecate
<ide> GraphDriver: types.GraphDriverData{
<del> Name: ir.layerStore.DriverName(),
<del> Data: layerMetadata,
<add> Name: img.Details.Driver,
<add> Data: img.Details.Metadata,
<ide> },
<ide> RootFS: rootFSToAPIType(img.RootFS),
<ide> Metadata: types.ImageMetadata{
<del> LastTagTime: lastUpdated,
<add> LastTagTime: img.Details.LastUpdated,
<ide> },
<ide> }, nil
<ide> }
<ide><path>api/types/image/opts.go
<ide> import specs "github.com/opencontainers/image-spec/specs-go/v1"
<ide> // GetImageOpts holds parameters to inspect an image.
<ide> type GetImageOpts struct {
<ide> Platform *specs.Platform
<add> Details bool
<ide> }
<ide><path>daemon/images/image.go
<ide> import (
<ide> imagetypes "github.com/docker/docker/api/types/image"
<ide> "github.com/docker/docker/errdefs"
<ide> "github.com/docker/docker/image"
<add> "github.com/docker/docker/layer"
<ide> "github.com/opencontainers/go-digest"
<ide> specs "github.com/opencontainers/image-spec/specs-go/v1"
<ide> "github.com/pkg/errors"
<ide> func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.I
<ide> }
<ide>
<ide> // GetImage returns an image corresponding to the image referred to by refOrID.
<del>func (i *ImageService) GetImage(ctx context.Context, refOrID string, options imagetypes.GetImageOpts) (retImg *image.Image, retErr error) {
<add>func (i *ImageService) GetImage(ctx context.Context, refOrID string, options imagetypes.GetImageOpts) (*image.Image, error) {
<add> img, err := i.getImage(ctx, refOrID, options)
<add> if err != nil {
<add> return nil, err
<add> }
<add> if options.Details {
<add> var size int64
<add> var layerMetadata map[string]string
<add> layerID := img.RootFS.ChainID()
<add> if layerID != "" {
<add> l, err := i.layerStore.Get(layerID)
<add> if err != nil {
<add> return nil, err
<add> }
<add> defer layer.ReleaseAndLog(i.layerStore, l)
<add> size = l.Size()
<add> layerMetadata, err = l.Metadata()
<add> if err != nil {
<add> return nil, err
<add> }
<add> }
<add>
<add> lastUpdated, err := i.imageStore.GetLastUpdated(img.ID())
<add> if err != nil {
<add> return nil, err
<add> }
<add> img.Details = &image.Details{
<add> Size: size,
<add> Metadata: layerMetadata,
<add> Driver: i.layerStore.DriverName(),
<add> LastUpdated: lastUpdated,
<add> }
<add> }
<add> return img, nil
<add>}
<add>
<add>func (i *ImageService) getImage(ctx context.Context, refOrID string, options imagetypes.GetImageOpts) (retImg *image.Image, retErr error) {
<ide> defer func() {
<ide> if retErr != nil || retImg == nil || options.Platform == nil {
<ide> return
<ide><path>image/image.go
<ide> type Image struct {
<ide> // computedID is the ID computed from the hash of the image config.
<ide> // Not to be confused with the legacy V1 ID in V1Image.
<ide> computedID ID
<add>
<add> // Details holds additional details about image
<add> Details *Details `json:"-"`
<add>}
<add>
<add>// Details provides additional image data
<add>type Details struct {
<add> Size int64
<add> Metadata map[string]string
<add> Driver string
<add> LastUpdated time.Time
<ide> }
<ide>
<ide> // RawJSON returns the immutable JSON associated with the image. | 4 |
Javascript | Javascript | drop reference to timer callback on cleartimeout | 5a4c40beea345d91a9b7520d7374336db928abe2 | <ide><path>src/node.js
<ide> global.setInterval = function (callback, repeat) {
<ide> global.clearTimeout = function (timer) {
<ide> if (!Timer) Timer = process.binding("timer").Timer;
<ide> if (timer instanceof Timer) {
<add> timer.callback = null;
<ide> timer.stop();
<ide> }
<ide> }; | 1 |
Ruby | Ruby | add check for indefinite article | f78a63984bbe9eb9fbf2c6929cb527f8211951a3 | <ide><path>Library/Homebrew/cmd/audit.rb
<ide> def audit_desc
<ide> if desc =~ /([Cc]ommand ?line)/
<ide> problem "Description should use \"command-line\" instead of \"#{$1}\""
<ide> end
<add>
<add> if desc =~ %r[^([Aa]n?)\s]
<add> problem "Please remove the indefinite article \"#{$1}\" from the beginning of the description"
<add> end
<ide> end
<ide>
<ide> def audit_homepage | 1 |
Go | Go | add chownopts support to tarwithoptions | 8a34c67a7eca7b8193f1c02fb6641abd719dce01 | <ide><path>pkg/archive/archive.go
<ide> type tarAppender struct {
<ide> // for hardlink mapping
<ide> SeenFiles map[uint64]string
<ide> IDMappings *idtools.IDMappings
<add> ChownOpts *idtools.IDPair
<ide>
<ide> // For packing and unpacking whiteout files in the
<ide> // non standard format. The whiteout files defined
<ide> type tarAppender struct {
<ide> WhiteoutConverter tarWhiteoutConverter
<ide> }
<ide>
<del>func newTarAppender(idMapping *idtools.IDMappings, writer io.Writer) *tarAppender {
<add>func newTarAppender(idMapping *idtools.IDMappings, writer io.Writer, chownOpts *idtools.IDPair) *tarAppender {
<ide> return &tarAppender{
<ide> SeenFiles: make(map[uint64]string),
<ide> TarWriter: tar.NewWriter(writer),
<ide> Buffer: pools.BufioWriter32KPool.Get(nil),
<ide> IDMappings: idMapping,
<add> ChownOpts: chownOpts,
<ide> }
<ide> }
<ide>
<ide> func (ta *tarAppender) addTarFile(path, name string) error {
<ide> }
<ide> }
<ide>
<add> // explicitly override with ChownOpts
<add> if ta.ChownOpts != nil {
<add> hdr.Uid = ta.ChownOpts.UID
<add> hdr.Gid = ta.ChownOpts.GID
<add> }
<add>
<ide> if ta.WhiteoutConverter != nil {
<ide> wo, err := ta.WhiteoutConverter.ConvertWrite(hdr, path, fi)
<ide> if err != nil {
<ide> func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
<ide> ta := newTarAppender(
<ide> idtools.NewIDMappingsFromMaps(options.UIDMaps, options.GIDMaps),
<ide> compressWriter,
<add> options.ChownOpts,
<ide> )
<ide> ta.WhiteoutConverter = getWhiteoutConverter(options.WhiteoutFormat)
<ide>
<ide><path>pkg/archive/archive_test.go
<ide> import (
<ide> "testing"
<ide> "time"
<ide>
<add> "github.com/docker/docker/pkg/idtools"
<ide> "github.com/stretchr/testify/assert"
<ide> "github.com/stretchr/testify/require"
<ide> )
<ide> func TestTarUntar(t *testing.T) {
<ide> }
<ide> }
<ide>
<add>func TestTarWithOptionsChownOptsAlwaysOverridesIdPair(t *testing.T) {
<add> origin, err := ioutil.TempDir("", "docker-test-tar-chown-opt")
<add> require.NoError(t, err)
<add>
<add> defer os.RemoveAll(origin)
<add> filePath := filepath.Join(origin, "1")
<add> err = ioutil.WriteFile(filePath, []byte("hello world"), 0700)
<add> require.NoError(t, err)
<add>
<add> idMaps := []idtools.IDMap{
<add> 0: {
<add> ContainerID: 0,
<add> HostID: 0,
<add> Size: 65536,
<add> },
<add> 1: {
<add> ContainerID: 0,
<add> HostID: 100000,
<add> Size: 65536,
<add> },
<add> }
<add>
<add> cases := []struct {
<add> opts *TarOptions
<add> expectedUID int
<add> expectedGID int
<add> }{
<add> {&TarOptions{ChownOpts: &idtools.IDPair{UID: 1337, GID: 42}}, 1337, 42},
<add> {&TarOptions{ChownOpts: &idtools.IDPair{UID: 100001, GID: 100001}, UIDMaps: idMaps, GIDMaps: idMaps}, 100001, 100001},
<add> {&TarOptions{ChownOpts: &idtools.IDPair{UID: 0, GID: 0}, NoLchown: false}, 0, 0},
<add> {&TarOptions{ChownOpts: &idtools.IDPair{UID: 1, GID: 1}, NoLchown: true}, 1, 1},
<add> {&TarOptions{ChownOpts: &idtools.IDPair{UID: 1000, GID: 1000}, NoLchown: true}, 1000, 1000},
<add> }
<add> for _, testCase := range cases {
<add> reader, err := TarWithOptions(filePath, testCase.opts)
<add> require.NoError(t, err)
<add> tr := tar.NewReader(reader)
<add> defer reader.Close()
<add> for {
<add> hdr, err := tr.Next()
<add> if err == io.EOF {
<add> // end of tar archive
<add> break
<add> }
<add> require.NoError(t, err)
<add> assert.Equal(t, hdr.Uid, testCase.expectedUID, "Uid equals expected value")
<add> assert.Equal(t, hdr.Gid, testCase.expectedGID, "Gid equals expected value")
<add> }
<add> }
<add>}
<add>
<ide> func TestTarWithOptions(t *testing.T) {
<ide> // TODO Windows: Figure out how to fix this test.
<ide> if runtime.GOOS == "windows" {
<ide><path>pkg/archive/changes.go
<ide> func ChangesSize(newDir string, changes []Change) int64 {
<ide> func ExportChanges(dir string, changes []Change, uidMaps, gidMaps []idtools.IDMap) (io.ReadCloser, error) {
<ide> reader, writer := io.Pipe()
<ide> go func() {
<del> ta := newTarAppender(idtools.NewIDMappingsFromMaps(uidMaps, gidMaps), writer)
<add> ta := newTarAppender(idtools.NewIDMappingsFromMaps(uidMaps, gidMaps), writer, nil)
<ide>
<ide> // this buffer is needed for the duration of this piped stream
<ide> defer pools.BufioWriter32KPool.Put(ta.Buffer) | 3 |
Javascript | Javascript | fix lint and bug | 08c535d6786c59201aedcc6d723ec18618893dd8 | <ide><path>lib/webpack.js
<ide> webpack.WebpackOptionsValidationError = WebpackOptionsValidationError;
<ide>
<ide> function exportPlugins(obj, mappings) {
<ide> Object.keys(mappings).forEach(name => {
<del> Object.defineProperty(exports, name, {
<add> Object.defineProperty(obj, name, {
<ide> configurable: false,
<ide> enumerable: true,
<ide> get: mappings[name]
<ide> });
<del> })
<add> });
<ide> }
<ide>
<ide> exportPlugins(exports, { | 1 |
Javascript | Javascript | replace function(...) with arrow funcs | 1a99a4848c4bc5b493b6401c1d8a4a6332040709 | <ide><path>src/config.js
<ide> export default class Config {
<ide> return fn(...Array.from(args || []))
<ide> }
<ide> const result = callback()
<del> return new Promise(function (resolve, reject) {
<add> return new Promise((resolve, reject) => {
<ide> return result.then(endTransaction(resolve)).catch(endTransaction(reject))
<ide> })
<ide> } catch (error) {
<ide> export default class Config {
<ide> const destinationPath = path.join(this.configDirPath, relativePath)
<ide> return queue.push({sourcePath, destinationPath})
<ide> }
<del> return fs.traverseTree(templateConfigDirPath, onConfigDirFile, path => true, function () {})
<add> return fs.traverseTree(templateConfigDirPath, onConfigDirFile, path => true, () => {})
<ide> }
<ide>
<ide> loadUserConfig () {
<ide> Config.addSchemaEnforcers({
<ide> let possibleValues = schema.enum
<ide>
<ide> if (Array.isArray(possibleValues)) {
<del> possibleValues = possibleValues.map(function (value) {
<add> possibleValues = possibleValues.map(value => {
<ide> if (value.hasOwnProperty('value')) { return value.value } else { return value }
<ide> })
<ide> }
<ide> Config.addSchemaEnforcers({
<ide>
<ide> let isPlainObject = value => _.isObject(value) && !_.isArray(value) && !_.isFunction(value) && !_.isString(value) && !(value instanceof Color)
<ide>
<del>let sortObject = function (value) {
<add>let sortObject = value => {
<ide> if (!isPlainObject(value)) { return value }
<ide> const result = {}
<ide> for (let key of Array.from(Object.keys(value).sort())) {
<ide> let sortObject = function (value) {
<ide> return result
<ide> }
<ide>
<del>var withoutEmptyObjects = function (object) {
<add>const withoutEmptyObjects = (object) => {
<ide> let resultObject
<ide> if (isPlainObject(object)) {
<ide> for (let key in object) { | 1 |
Javascript | Javascript | run path.exists paths through _makelong | a661830569f424ac929a075bacaa94d70e732924 | <ide><path>lib/path.js
<ide> exports.extname = function(path) {
<ide>
<ide>
<ide> exports.exists = function(path, callback) {
<del> process.binding('fs').stat(path, function(err, stats) {
<add> process.binding('fs').stat(_makeLong(path), function(err, stats) {
<ide> if (callback) callback(err ? false : true);
<ide> });
<ide> };
<ide>
<ide>
<ide> exports.existsSync = function(path) {
<ide> try {
<del> process.binding('fs').stat(path);
<add> process.binding('fs').stat(_makeLong(path));
<ide> return true;
<ide> } catch (e) {
<ide> return false;
<ide> }
<ide> };
<ide>
<ide>
<del>exports._makeLong = isWindows ?
<add>var _makeLong = exports._makeLong = isWindows ?
<ide> function(path) {
<ide> var resolvedPath = exports.resolve(path);
<ide> | 1 |
Ruby | Ruby | remove useless conditionals/local var | a60334fdc5d4f612bd2dd70e38d1e57481cd5910 | <ide><path>activerecord/lib/active_record/associations.rb
<ide> def association_join
<ide> ]
<ide> when :has_many, :has_one
<ide> if reflection.options[:through]
<del> through_conditions = through_reflection.options[:conditions] ? "AND #{interpolate_sql(sanitize_sql(through_reflection.options[:conditions]))}" : ''
<del>
<ide> jt_foreign_key = jt_as_extra = jt_source_extra = jt_sti_extra = nil
<ide> first_key = second_key = as_extra = nil
<ide>
<ide> def association_join
<ide> as_extra]
<ide> ]
<ide>
<del> elsif reflection.options[:as] && [:has_many, :has_one].include?(reflection.macro)
<add> elsif reflection.options[:as]
<ide> "%s.%s = %s.%s AND %s.%s = %s" % [
<ide> connection.quote_table_name(aliased_table_name),
<ide> "#{reflection.options[:as]}_id",
<ide> def association_join
<ide> connection.quote_table_name(parent.aliased_table_name),
<ide> options[:foreign_key] || reflection.primary_key_name
<ide> ]
<del> else
<del> ""
<ide> end
<ide> @join << %(AND %s) % [
<ide> klass.send(:type_condition, aliased_table_name)] unless klass.descends_from_active_record? | 1 |
Javascript | Javascript | remove unused code from core controller | 46fc96bf4d97989096aa1024be3d0ee2c9a6a789 | <ide><path>src/core/core.controller.js
<ide> module.exports = function(Chart) {
<ide> this.ensureScalesHaveIDs();
<ide> this.buildOrUpdateControllers();
<ide> this.buildScales();
<del> this.buildSurroundingItems();
<ide> this.updateLayout();
<ide> this.resetElements();
<ide> this.initToolTip();
<ide> module.exports = function(Chart) {
<ide> Chart.scaleService.addScalesToLayout(this);
<ide> },
<ide>
<del> buildSurroundingItems: function() {
<del> /*if (this.options.title) {
<del> this.titleBlock = new Chart.Title({
<del> ctx: this.chart.ctx,
<del> options: this.options.title,
<del> chart: this
<del> });
<del>
<del> Chart.layoutService.addBox(this, this.titleBlock);
<del> }*/
<del> },
<del>
<ide> updateLayout: function() {
<ide> Chart.layoutService.update(this, this.chart.width, this.chart.height);
<ide> }, | 1 |
Javascript | Javascript | fix typo in comments | ee7b7f693559afa05ea42279f856b4fc2186f527 | <ide><path>lib/internal/process.js
<ide> function setup_cpuUsage() {
<ide>
<ide> // The 3 entries filled in by the original process.hrtime contains
<ide> // the upper/lower 32 bits of the second part of the value,
<del>// and the renamining nanoseconds of the value.
<add>// and the remaining nanoseconds of the value.
<ide> function setup_hrtime() {
<ide> const _hrtime = process.hrtime;
<ide> const hrValues = new Uint32Array(3); | 1 |
Javascript | Javascript | use mathematical correct confidence interval | 6192b39d2d3646926c12416f1cbd1d7a670cd6a8 | <ide><path>test/BenchmarkTestCases.benchmark.js
<ide> describe("BenchmarkTestCases", function() {
<ide> try {
<ide> fs.mkdirSync(baselinePath);
<ide> } catch(e) {}
<del> git(baselinePath).raw(["--git-dir", path.join(rootPath, ".git"), "reset", "--hard", baselineRevision], err => {
<add> const gitIndex = path.resolve(rootPath, ".git/index");
<add> const index = fs.readFileSync(gitIndex);
<add> git(rootPath).raw(["rev-list", "-n", "1", "HEAD"], (err, prevHead) => {
<ide> if(err) return callback(err);
<del> doLoadWebpack();
<add> git(baselinePath).raw(["--git-dir", path.join(rootPath, ".git"), "reset", "--hard", baselineRevision], err => {
<add> if(err) return callback(err);
<add> git(rootPath).raw(["reset", "--soft", prevHead.split("\n")[0]], err => {
<add> if(err) return callback(err);
<add> fs.writeFileSync(gitIndex, index);
<add> doLoadWebpack();
<add> });
<add> });
<ide> });
<ide> }
<ide>
<ide> describe("BenchmarkTestCases", function() {
<ide> });
<ide> }
<ide>
<add> function tDistribution(n) {
<add> // two-sided, 90%
<add> // https://en.wikipedia.org/wiki/Student%27s_t-distribution
<add> if(n <= 30) {
<add> // 1 2 ...
<add> const data = [6.314, 2.920, 2.353, 2.132, 2.015, 1.943, 1.895, 1.860, 1.833, 1.812, 1.796, 1.782, 1.771, 1.761, 1.753, 1.746, 1.740, 1.734, 1.729, 1.725, 1.721, 1.717, 1.714, 1.711, 1.708, 1.706, 1.703, 1.701, 1.699, 1.697];
<add> return data[n - 1];
<add> } else if(n <= 120) {
<add> // 40 50 60 70 80 90 100 110 120
<add> const data = [1.684, 1.676, 1.671, 1.667, 1.664, 1.662, 1.660, 1.659, 1.658]
<add> return data[Math.floor(n / 10) - 4];
<add> } else {
<add> return 1.645;
<add> }
<add> }
<add>
<ide> function runBenchmark(webpack, config, callback) {
<ide> // warmup
<ide> const warmupCompiler = webpack(config, (err, stats) => {
<ide> describe("BenchmarkTestCases", function() {
<ide> const compiler = webpack(config, (err, stats) => {
<ide> compiler.purgeInputFileSystem();
<ide> if(err) {
<del> deferred.reject(err);
<add> callback(err);
<ide> return;
<ide> }
<ide> if(stats.hasErrors()) {
<del> deferred.reject(new Error(stats.toJson().errors.join("\n\n")));
<add> callback(new Error(stats.toJson().errors.join("\n\n")));
<ide> return;
<ide> }
<ide> deferred.resolve();
<ide> describe("BenchmarkTestCases", function() {
<ide> defer: true,
<ide> initCount: 1,
<ide> onComplete: function() {
<add> const stats = bench.stats;
<add> const n = stats.sample.length;
<add> const nSqrt = Math.sqrt(n);
<add> const z = tDistribution(n - 1);
<add> stats.minConfidence = stats.mean - z * stats.deviation / nSqrt;
<add> stats.maxConfidence = stats.mean + z * stats.deviation / nSqrt;
<add> stats.text = `${Math.round(stats.mean * 1000)}ms ± ${Math.round(stats.deviation * 1000)}ms [${Math.round(stats.minConfidence * 1000)}ms; ${Math.round(stats.maxConfidence * 1000)}ms]`;
<ide> callback(null, bench.stats);
<ide> },
<ide> onError: callback
<ide> describe("BenchmarkTestCases", function() {
<ide> if(!config.output.path) config.output.path = outputDirectory;
<ide> runBenchmark(baseline.webpack, config, (err, stats) => {
<ide> if(err) return done(err);
<del> console.log(` ${baseline.name} ${Math.round(stats.mean * 1000)}ms ± ${Math.round(stats.deviation * 1000)}ms`);
<add> console.log(` ${baseline.name} ${stats.text}`);
<ide> if(baseline.name === "HEAD")
<ide> headStats = stats;
<ide> else
<ide> describe("BenchmarkTestCases", function() {
<ide>
<ide> if(baseline.name !== "HEAD") {
<ide> it(`HEAD should not be slower than ${baseline.name} (${baseline.rev})`, function() {
<del> if(baselineStats.mean + baselineStats.deviation < headStats.mean - headStats.deviation) {
<del> throw new Error(`HEAD (${baselineStats.mean} ± ${baselineStats.deviation}) is slower than ${baseline.name} (${headStats.mean} ± ${headStats.deviation})`);
<del> } else if(baselineStats.mean - baselineStats.deviation > headStats.mean + headStats.deviation) {
<del> console.log(`======> HEAD is ${Math.round(baselineStats.mean / headStats.mean * 100 - 100)}% faster than ${baseline.name}!`);
<add> if(baselineStats.maxConfidence < headStats.minConfidence) {
<add> throw new Error(`HEAD (${headStats.text}) is slower than ${baseline.name} (${baselineStats.text}) (90% confidence)`);
<add> } else if(baselineStats.minConfidence > headStats.maxConfidence) {
<add> console.log(`======> HEAD is ${Math.round(baselineStats.mean / headStats.mean * 100 - 100)}% faster than ${baseline.name} (90% confidence)!`);
<ide> }
<ide> });
<ide> } | 1 |
Text | Text | add variants to release notes | eb0402d512a1fb4e65a4d8d3dab3684e9f136b34 | <ide><path>guides/source/4_1_release_notes.md
<ide> Ruby on Rails 4.1 Release Notes
<ide>
<ide> Highlights in Rails 4.1:
<ide>
<add>* Variants
<ide> * Action View extracted from Action Pack
<ide>
<ide> These release notes cover only the major changes. To know about various bug
<ide> guide.
<ide> Major Features
<ide> --------------
<ide>
<add>* Variants
<add>
<add> We often want to render different html/json/xml templates for phones,
<add> tablets, and desktop browsers. Variants make it easy.
<add>
<add> The request variant is a specialization of the request format, like :tablet,
<add> :phone, or :desktop.
<add>
<add> You can set the variant in a before_action:
<add>
<add> ```ruby
<add> request.variant = :tablet if request.user_agent =~ /iPad/
<add> ```
<add>
<add> Respond to variants in the action just like you respond to formats:
<add>
<add> ```ruby
<add> respond_to do |format|
<add> format.html do |html|
<add> html.tablet # renders app/views/projects/show.html+tablet.erb
<add> html.phone { extra_setup; render ... }
<add> end
<add> end
<add> ```
<add>
<add> Provide separate templates for each format and variant:
<add>
<add> ```
<add> app/views/projects/show.html.erb
<add> app/views/projects/show.html+tablet.erb
<add> app/views/projects/show.html+phone.erb
<add> ```
<ide>
<ide> Documentation
<ide> ------------- | 1 |
Ruby | Ruby | remove unused methods | 18630c70322e34f0a629c5461768a4ff1693867e | <ide><path>Library/Homebrew/extend/ARGV.rb
<ide> module HomebrewArgvExtension
<del> def formula_install_option_names
<del> %w[
<del> --debug
<del> --env=
<del> --ignore-dependencies
<del> --cc=
<del> --build-from-source
<del> --devel
<del> --HEAD
<del> --keep-tmp
<del> --interactive
<del> --git
<del> --sandbox
<del> --no-sandbox
<del> --build-bottle
<del> --force-bottle
<del> --bottle-arch=
<del> --include-test
<del> --verbose
<del> --force
<del> --display-times
<del> -i
<del> -v
<del> -d
<del> -g
<del> -s
<del> -f
<del> ].freeze
<del> end
<del>
<ide> def named
<ide> # TODO: use @instance variable to ||= cache when moving to CLI::Parser
<ide> self - options_only
<ide> def kegs
<ide> end
<ide> end
<ide>
<del> def include?(arg)
<del> !index(arg).nil?
<del> end
<del>
<del> def next
<del> at(@n + 1) || raise(UsageError)
<del> end
<del>
<ide> def value(name)
<ide> arg_prefix = "--#{name}="
<ide> flag_with_value = find { |arg| arg.start_with?(arg_prefix) }
<ide> flag_with_value&.delete_prefix(arg_prefix)
<ide> end
<ide>
<del> # Returns an array of values that were given as a comma-separated list.
<del> # @see value
<del> def values(name)
<del> return unless val = value(name)
<del>
<del> val.split(",")
<del> end
<del>
<ide> def force?
<ide> flag? "--force"
<ide> end
<ide> def interactive?
<ide> flag? "--interactive"
<ide> end
<ide>
<del> def one?
<del> flag? "--1"
<del> end
<del>
<del> def dry_run?
<del> include?("--dry-run") || switch?("n")
<del> end
<del>
<ide> def keep_tmp?
<ide> include? "--keep-tmp"
<ide> end
<ide> def homebrew_developer?
<ide> !ENV["HOMEBREW_DEVELOPER"].nil?
<ide> end
<ide>
<del> def sandbox?
<del> include?("--sandbox") || !ENV["HOMEBREW_SANDBOX"].nil?
<del> end
<del>
<ide> def no_sandbox?
<ide> include?("--no-sandbox") || !ENV["HOMEBREW_NO_SANDBOX"].nil?
<ide> end
<ide> def ignore_deps?
<ide> include? "--ignore-dependencies"
<ide> end
<ide>
<del> def only_deps?
<del> include? "--only-dependencies"
<del> end
<del>
<del> def json
<del> value "json"
<del> end
<del>
<del> def build_head?
<del> include? "--HEAD"
<del> end
<del>
<del> def build_devel?
<del> include? "--devel"
<del> end
<del>
<ide> def build_stable?
<del> !(build_head? || build_devel?)
<add> !(include?("--HEAD") || include?("--devel"))
<ide> end
<ide>
<ide> def build_universal?
<ide> def fetch_head?
<ide> include? "--fetch-HEAD"
<ide> end
<ide>
<del> # e.g. `foo -ns -i --bar` has three switches: `n`, `s` and `i`
<del> def switch?(char)
<del> return false if char.length > 1
<del>
<del> options_only.any? { |arg| arg.scan("-").size == 1 && arg.include?(char) }
<del> end
<del>
<ide> def cc
<ide> value "cc"
<ide> end
<ide> def collect_build_flags
<ide>
<ide> private
<ide>
<add> # e.g. `foo -ns -i --bar` has three switches: `n`, `s` and `i`
<add> def switch?(char)
<add> return false if char.length > 1
<add>
<add> options_only.any? { |arg| arg.scan("-").size == 1 && arg.include?(char) }
<add> end
<add>
<ide> def spec(default = :stable)
<ide> if include?("--HEAD")
<ide> :head
<ide><path>Library/Homebrew/test/ARGV_spec.rb
<ide>
<ide> it "returns true if the given string is a switch" do
<ide> %w[n s i].each do |s|
<del> expect(subject.switch?(s)).to be true
<add> expect(subject.send("switch?", s)).to be true
<ide> end
<ide> end
<ide>
<ide> it "returns false if the given string is not a switch" do
<ide> %w[b ns bar --bar -n a bad arg].each do |s|
<del> expect(subject.switch?(s)).to be false
<add> expect(subject.send("switch?", s)).to be false
<ide> end
<ide> end
<ide> end
<ide> expect(subject.value("baz")).to be nil
<ide> end
<ide> end
<del>
<del> describe "#values" do
<del> let(:argv) { ["--foo=", "--bar=a", "--baz=b,c"] }
<del>
<del> it "returns the value for a given argument" do
<del> expect(subject.values("foo")).to eq []
<del> expect(subject.values("bar")).to eq ["a"]
<del> expect(subject.values("baz")).to eq ["b", "c"]
<del> end
<del>
<del> it "returns nil if there is no matching argument" do
<del> expect(subject.values("qux")).to be nil
<del> end
<del> end
<ide> end | 2 |
Javascript | Javascript | convert var to let/const | 3c977dea6b96f6a9bb39f09886848da870748441 | <ide><path>packages/react/index.js
<ide>
<ide> 'use strict';
<ide>
<del>var React = require('./src/React');
<add>const React = require('./src/React');
<ide>
<ide> // TODO: decide on the top-level export form.
<ide> // This is hacky but makes it work with both Rollup and Jest.
<ide><path>packages/react/src/React.js
<ide> import {
<ide> } from './ReactElementValidator';
<ide> import ReactDebugCurrentFrame from './ReactDebugCurrentFrame';
<ide>
<del>var React = {
<add>const React = {
<ide> Children: {
<ide> map,
<ide> forEach,
<ide><path>packages/react/src/ReactBaseClasses.js
<ide> Component.prototype.forceUpdate = function(callback) {
<ide> * modern base class. Instead, we define a getter that warns if it's accessed.
<ide> */
<ide> if (__DEV__) {
<del> var deprecatedAPIs = {
<add> const deprecatedAPIs = {
<ide> isMounted: [
<ide> 'isMounted',
<ide> 'Instead, make sure to clean up subscriptions and pending requests in ' +
<ide> if (__DEV__) {
<ide> 'https://github.com/facebook/react/issues/3236).',
<ide> ],
<ide> };
<del> var defineDeprecationWarning = function(methodName, info) {
<add> const defineDeprecationWarning = function(methodName, info) {
<ide> Object.defineProperty(Component.prototype, methodName, {
<ide> get: function() {
<ide> lowPriorityWarning(
<ide> if (__DEV__) {
<ide> },
<ide> });
<ide> };
<del> for (var fnName in deprecatedAPIs) {
<add> for (const fnName in deprecatedAPIs) {
<ide> if (deprecatedAPIs.hasOwnProperty(fnName)) {
<ide> defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
<ide> }
<ide> function PureComponent(props, context, updater) {
<ide>
<ide> function ComponentDummy() {}
<ide> ComponentDummy.prototype = Component.prototype;
<del>var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
<add>const pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
<ide> pureComponentPrototype.constructor = PureComponent;
<ide> // Avoid an extra prototype jump for these methods.
<ide> Object.assign(pureComponentPrototype, Component.prototype);
<ide> function AsyncComponent(props, context, updater) {
<ide> this.updater = updater || ReactNoopUpdateQueue;
<ide> }
<ide>
<del>var asyncComponentPrototype = (AsyncComponent.prototype = new ComponentDummy());
<add>const asyncComponentPrototype = (AsyncComponent.prototype = new ComponentDummy());
<ide> asyncComponentPrototype.constructor = AsyncComponent;
<ide> // Avoid an extra prototype jump for these methods.
<ide> Object.assign(asyncComponentPrototype, Component.prototype);
<ide><path>packages/react/src/ReactChildren.js
<ide> import {
<ide> import {isValidElement, cloneAndReplaceKey} from './ReactElement';
<ide> import ReactDebugCurrentFrame from './ReactDebugCurrentFrame';
<ide>
<del>var SEPARATOR = '.';
<del>var SUBSEPARATOR = ':';
<add>const SEPARATOR = '.';
<add>const SUBSEPARATOR = ':';
<ide>
<ide> /**
<ide> * Escape and wrap key so it is safe to use as a reactid
<ide> var SUBSEPARATOR = ':';
<ide> * @return {string} the escaped key.
<ide> */
<ide> function escape(key) {
<del> var escapeRegex = /[=:]/g;
<del> var escaperLookup = {
<add> const escapeRegex = /[=:]/g;
<add> const escaperLookup = {
<ide> '=': '=0',
<ide> ':': '=2',
<ide> };
<del> var escapedString = ('' + key).replace(escapeRegex, function(match) {
<add> const escapedString = ('' + key).replace(escapeRegex, function(match) {
<ide> return escaperLookup[match];
<ide> });
<ide>
<ide> function escape(key) {
<ide> * pattern.
<ide> */
<ide>
<del>var didWarnAboutMaps = false;
<add>let didWarnAboutMaps = false;
<ide>
<del>var userProvidedKeyEscapeRegex = /\/+/g;
<add>const userProvidedKeyEscapeRegex = /\/+/g;
<ide> function escapeUserProvidedKey(text) {
<ide> return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
<ide> }
<ide>
<del>var POOL_SIZE = 10;
<del>var traverseContextPool = [];
<add>const POOL_SIZE = 10;
<add>const traverseContextPool = [];
<ide> function getPooledTraverseContext(
<ide> mapResult,
<ide> keyPrefix,
<ide> mapFunction,
<ide> mapContext,
<ide> ) {
<ide> if (traverseContextPool.length) {
<del> var traverseContext = traverseContextPool.pop();
<add> const traverseContext = traverseContextPool.pop();
<ide> traverseContext.result = mapResult;
<ide> traverseContext.keyPrefix = keyPrefix;
<ide> traverseContext.func = mapFunction;
<ide> function traverseAllChildrenImpl(
<ide> callback,
<ide> traverseContext,
<ide> ) {
<del> var type = typeof children;
<add> const type = typeof children;
<ide>
<ide> if (type === 'undefined' || type === 'boolean') {
<ide> // All of the above are perceived as null.
<ide> function traverseAllChildrenImpl(
<ide> return 1;
<ide> }
<ide>
<del> var child;
<del> var nextName;
<del> var subtreeCount = 0; // Count of children found in the current subtree.
<del> var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
<add> let child;
<add> let nextName;
<add> let subtreeCount = 0; // Count of children found in the current subtree.
<add> const nextNamePrefix =
<add> nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
<ide>
<ide> if (Array.isArray(children)) {
<del> for (var i = 0; i < children.length; i++) {
<add> for (let i = 0; i < children.length; i++) {
<ide> child = children[i];
<ide> nextName = nextNamePrefix + getComponentKey(child, i);
<ide> subtreeCount += traverseAllChildrenImpl(
<ide> function traverseAllChildrenImpl(
<ide> );
<ide> }
<ide> } else {
<del> var iteratorFn = getIteratorFn(children);
<add> const iteratorFn = getIteratorFn(children);
<ide> if (typeof iteratorFn === 'function') {
<ide> if (__DEV__) {
<ide> // Warn about using Maps as children
<ide> function traverseAllChildrenImpl(
<ide> }
<ide> }
<ide>
<del> var iterator = iteratorFn.call(children);
<del> var step;
<del> var ii = 0;
<add> const iterator = iteratorFn.call(children);
<add> let step;
<add> let ii = 0;
<ide> while (!(step = iterator.next()).done) {
<ide> child = step.value;
<ide> nextName = nextNamePrefix + getComponentKey(child, ii++);
<ide> function traverseAllChildrenImpl(
<ide> );
<ide> }
<ide> } else if (type === 'object') {
<del> var addendum = '';
<add> let addendum = '';
<ide> if (__DEV__) {
<ide> addendum =
<ide> ' If you meant to render a collection of children, use an array ' +
<ide> 'instead.' +
<ide> ReactDebugCurrentFrame.getStackAddendum();
<ide> }
<del> var childrenString = '' + children;
<add> const childrenString = '' + children;
<ide> invariant(
<ide> false,
<ide> 'Objects are not valid as a React child (found: %s).%s',
<ide> function getComponentKey(component, index) {
<ide> }
<ide>
<ide> function forEachSingleChild(bookKeeping, child, name) {
<del> var {func, context} = bookKeeping;
<add> const {func, context} = bookKeeping;
<ide> func.call(context, child, bookKeeping.count++);
<ide> }
<ide>
<ide> function forEachChildren(children, forEachFunc, forEachContext) {
<ide> if (children == null) {
<ide> return children;
<ide> }
<del> var traverseContext = getPooledTraverseContext(
<add> const traverseContext = getPooledTraverseContext(
<ide> null,
<ide> null,
<ide> forEachFunc,
<ide> function forEachChildren(children, forEachFunc, forEachContext) {
<ide> }
<ide>
<ide> function mapSingleChildIntoContext(bookKeeping, child, childKey) {
<del> var {result, keyPrefix, func, context} = bookKeeping;
<add> const {result, keyPrefix, func, context} = bookKeeping;
<ide>
<del> var mappedChild = func.call(context, child, bookKeeping.count++);
<add> let mappedChild = func.call(context, child, bookKeeping.count++);
<ide> if (Array.isArray(mappedChild)) {
<ide> mapIntoWithKeyPrefixInternal(
<ide> mappedChild,
<ide> function mapSingleChildIntoContext(bookKeeping, child, childKey) {
<ide> }
<ide>
<ide> function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
<del> var escapedPrefix = '';
<add> let escapedPrefix = '';
<ide> if (prefix != null) {
<ide> escapedPrefix = escapeUserProvidedKey(prefix) + '/';
<ide> }
<del> var traverseContext = getPooledTraverseContext(
<add> const traverseContext = getPooledTraverseContext(
<ide> array,
<ide> escapedPrefix,
<ide> func,
<ide> function mapChildren(children, func, context) {
<ide> if (children == null) {
<ide> return children;
<ide> }
<del> var result = [];
<add> const result = [];
<ide> mapIntoWithKeyPrefixInternal(children, result, null, func, context);
<ide> return result;
<ide> }
<ide> function countChildren(children, context) {
<ide> * See https://reactjs.org/docs/react-api.html#react.children.toarray
<ide> */
<ide> function toArray(children) {
<del> var result = [];
<add> const result = [];
<ide> mapIntoWithKeyPrefixInternal(
<ide> children,
<ide> result,
<ide><path>packages/react/src/ReactCurrentOwner.js
<ide> import type {Fiber} from 'react-reconciler/src/ReactFiber';
<ide> * The current owner is the component who should own any components that are
<ide> * currently being constructed.
<ide> */
<del>var ReactCurrentOwner = {
<add>const ReactCurrentOwner = {
<ide> /**
<ide> * @internal
<ide> * @type {ReactComponent}
<ide><path>packages/react/src/ReactElement.js
<ide> import {REACT_ELEMENT_TYPE} from 'shared/ReactSymbols';
<ide>
<ide> import ReactCurrentOwner from './ReactCurrentOwner';
<ide>
<del>var hasOwnProperty = Object.prototype.hasOwnProperty;
<add>const hasOwnProperty = Object.prototype.hasOwnProperty;
<ide>
<del>var RESERVED_PROPS = {
<add>const RESERVED_PROPS = {
<ide> key: true,
<ide> ref: true,
<ide> __self: true,
<ide> __source: true,
<ide> };
<ide>
<del>var specialPropKeyWarningShown, specialPropRefWarningShown;
<add>let specialPropKeyWarningShown, specialPropRefWarningShown;
<ide>
<ide> function hasValidRef(config) {
<ide> if (__DEV__) {
<ide> if (hasOwnProperty.call(config, 'ref')) {
<del> var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
<add> const getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
<ide> if (getter && getter.isReactWarning) {
<ide> return false;
<ide> }
<ide> function hasValidRef(config) {
<ide> function hasValidKey(config) {
<ide> if (__DEV__) {
<ide> if (hasOwnProperty.call(config, 'key')) {
<del> var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
<add> const getter = Object.getOwnPropertyDescriptor(config, 'key').get;
<ide> if (getter && getter.isReactWarning) {
<ide> return false;
<ide> }
<ide> function hasValidKey(config) {
<ide> }
<ide>
<ide> function defineKeyPropWarningGetter(props, displayName) {
<del> var warnAboutAccessingKey = function() {
<add> const warnAboutAccessingKey = function() {
<ide> if (!specialPropKeyWarningShown) {
<ide> specialPropKeyWarningShown = true;
<ide> warning(
<ide> function defineKeyPropWarningGetter(props, displayName) {
<ide> }
<ide>
<ide> function defineRefPropWarningGetter(props, displayName) {
<del> var warnAboutAccessingRef = function() {
<add> const warnAboutAccessingRef = function() {
<ide> if (!specialPropRefWarningShown) {
<ide> specialPropRefWarningShown = true;
<ide> warning(
<ide> function defineRefPropWarningGetter(props, displayName) {
<ide> * @param {*} props
<ide> * @internal
<ide> */
<del>var ReactElement = function(type, key, ref, self, source, owner, props) {
<del> var element = {
<add>const ReactElement = function(type, key, ref, self, source, owner, props) {
<add> const element = {
<ide> // This tag allow us to uniquely identify this as a React Element
<ide> $$typeof: REACT_ELEMENT_TYPE,
<ide>
<ide> var ReactElement = function(type, key, ref, self, source, owner, props) {
<ide> * See https://reactjs.org/docs/react-api.html#createelement
<ide> */
<ide> export function createElement(type, config, children) {
<del> var propName;
<add> let propName;
<ide>
<ide> // Reserved names are extracted
<del> var props = {};
<add> const props = {};
<ide>
<del> var key = null;
<del> var ref = null;
<del> var self = null;
<del> var source = null;
<add> let key = null;
<add> let ref = null;
<add> let self = null;
<add> let source = null;
<ide>
<ide> if (config != null) {
<ide> if (hasValidRef(config)) {
<ide> export function createElement(type, config, children) {
<ide>
<ide> // Children can be more than one argument, and those are transferred onto
<ide> // the newly allocated props object.
<del> var childrenLength = arguments.length - 2;
<add> const childrenLength = arguments.length - 2;
<ide> if (childrenLength === 1) {
<ide> props.children = children;
<ide> } else if (childrenLength > 1) {
<del> var childArray = Array(childrenLength);
<del> for (var i = 0; i < childrenLength; i++) {
<add> const childArray = Array(childrenLength);
<add> for (let i = 0; i < childrenLength; i++) {
<ide> childArray[i] = arguments[i + 2];
<ide> }
<ide> if (__DEV__) {
<ide> export function createElement(type, config, children) {
<ide>
<ide> // Resolve default props
<ide> if (type && type.defaultProps) {
<del> var defaultProps = type.defaultProps;
<add> const defaultProps = type.defaultProps;
<ide> for (propName in defaultProps) {
<ide> if (props[propName] === undefined) {
<ide> props[propName] = defaultProps[propName];
<ide> export function createElement(type, config, children) {
<ide> typeof props.$$typeof === 'undefined' ||
<ide> props.$$typeof !== REACT_ELEMENT_TYPE
<ide> ) {
<del> var displayName =
<add> const displayName =
<ide> typeof type === 'function'
<ide> ? type.displayName || type.name || 'Unknown'
<ide> : type;
<ide> export function createElement(type, config, children) {
<ide> * See https://reactjs.org/docs/react-api.html#createfactory
<ide> */
<ide> export function createFactory(type) {
<del> var factory = createElement.bind(null, type);
<add> const factory = createElement.bind(null, type);
<ide> // Expose the type on the factory and the prototype so that it can be
<ide> // easily accessed on elements. E.g. `<Foo />.type === Foo`.
<ide> // This should not be named `constructor` since this may not be the function
<ide> export function createFactory(type) {
<ide> }
<ide>
<ide> export function cloneAndReplaceKey(oldElement, newKey) {
<del> var newElement = ReactElement(
<add> const newElement = ReactElement(
<ide> oldElement.type,
<ide> newKey,
<ide> oldElement.ref,
<ide> export function cloneAndReplaceKey(oldElement, newKey) {
<ide> * See https://reactjs.org/docs/react-api.html#cloneelement
<ide> */
<ide> export function cloneElement(element, config, children) {
<del> var propName;
<add> let propName;
<ide>
<ide> // Original props are copied
<del> var props = Object.assign({}, element.props);
<add> const props = Object.assign({}, element.props);
<ide>
<ide> // Reserved names are extracted
<del> var key = element.key;
<del> var ref = element.ref;
<add> let key = element.key;
<add> let ref = element.ref;
<ide> // Self is preserved since the owner is preserved.
<del> var self = element._self;
<add> const self = element._self;
<ide> // Source is preserved since cloneElement is unlikely to be targeted by a
<ide> // transpiler, and the original source is probably a better indicator of the
<ide> // true owner.
<del> var source = element._source;
<add> const source = element._source;
<ide>
<ide> // Owner will be preserved, unless ref is overridden
<del> var owner = element._owner;
<add> let owner = element._owner;
<ide>
<ide> if (config != null) {
<ide> if (hasValidRef(config)) {
<ide> export function cloneElement(element, config, children) {
<ide> }
<ide>
<ide> // Remaining properties override existing props
<del> var defaultProps;
<add> let defaultProps;
<ide> if (element.type && element.type.defaultProps) {
<ide> defaultProps = element.type.defaultProps;
<ide> }
<ide> export function cloneElement(element, config, children) {
<ide>
<ide> // Children can be more than one argument, and those are transferred onto
<ide> // the newly allocated props object.
<del> var childrenLength = arguments.length - 2;
<add> const childrenLength = arguments.length - 2;
<ide> if (childrenLength === 1) {
<ide> props.children = children;
<ide> } else if (childrenLength > 1) {
<del> var childArray = Array(childrenLength);
<del> for (var i = 0; i < childrenLength; i++) {
<add> const childArray = Array(childrenLength);
<add> for (let i = 0; i < childrenLength; i++) {
<ide> childArray[i] = arguments[i + 2];
<ide> }
<ide> props.children = childArray;
<ide><path>packages/react/src/ReactElementValidator.js
<ide> if (__DEV__) {
<ide> };
<ide>
<ide> var getStackAddendum = function(): string {
<del> var stack = '';
<add> let stack = '';
<ide> if (currentlyValidatingElement) {
<del> var name = getDisplayName(currentlyValidatingElement);
<del> var owner = currentlyValidatingElement._owner;
<add> const name = getDisplayName(currentlyValidatingElement);
<add> const owner = currentlyValidatingElement._owner;
<ide> stack += describeComponentFrame(
<ide> name,
<ide> currentlyValidatingElement._source,
<ide> if (__DEV__) {
<ide>
<ide> function getDeclarationErrorAddendum() {
<ide> if (ReactCurrentOwner.current) {
<del> var name = getComponentName(ReactCurrentOwner.current);
<add> const name = getComponentName(ReactCurrentOwner.current);
<ide> if (name) {
<ide> return '\n\nCheck the render method of `' + name + '`.';
<ide> }
<ide> function getSourceInfoErrorAddendum(elementProps) {
<ide> elementProps !== undefined &&
<ide> elementProps.__source !== undefined
<ide> ) {
<del> var source = elementProps.__source;
<del> var fileName = source.fileName.replace(/^.*[\\\/]/, '');
<del> var lineNumber = source.lineNumber;
<add> const source = elementProps.__source;
<add> const fileName = source.fileName.replace(/^.*[\\\/]/, '');
<add> const lineNumber = source.lineNumber;
<ide> return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
<ide> }
<ide> return '';
<ide> function getSourceInfoErrorAddendum(elementProps) {
<ide> * object keys are not valid. This allows us to keep track of children between
<ide> * updates.
<ide> */
<del>var ownerHasKeyUseWarning = {};
<add>const ownerHasKeyUseWarning = {};
<ide>
<ide> function getCurrentComponentErrorInfo(parentType) {
<del> var info = getDeclarationErrorAddendum();
<add> let info = getDeclarationErrorAddendum();
<ide>
<ide> if (!info) {
<del> var parentName =
<add> const parentName =
<ide> typeof parentType === 'string'
<ide> ? parentType
<ide> : parentType.displayName || parentType.name;
<ide> function validateExplicitKey(element, parentType) {
<ide> }
<ide> element._store.validated = true;
<ide>
<del> var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
<add> const currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
<ide> if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
<ide> return;
<ide> }
<ide> function validateExplicitKey(element, parentType) {
<ide> // Usually the current owner is the offender, but if it accepts children as a
<ide> // property, it may be the creator of the child that's responsible for
<ide> // assigning it a key.
<del> var childOwner = '';
<add> let childOwner = '';
<ide> if (
<ide> element &&
<ide> element._owner &&
<ide> function validateChildKeys(node, parentType) {
<ide> return;
<ide> }
<ide> if (Array.isArray(node)) {
<del> for (var i = 0; i < node.length; i++) {
<del> var child = node[i];
<add> for (let i = 0; i < node.length; i++) {
<add> const child = node[i];
<ide> if (isValidElement(child)) {
<ide> validateExplicitKey(child, parentType);
<ide> }
<ide> function validateChildKeys(node, parentType) {
<ide> node._store.validated = true;
<ide> }
<ide> } else if (node) {
<del> var iteratorFn = getIteratorFn(node);
<add> const iteratorFn = getIteratorFn(node);
<ide> if (typeof iteratorFn === 'function') {
<ide> // Entry iterators used to provide implicit keys,
<ide> // but now we print a separate warning for them later.
<ide> if (iteratorFn !== node.entries) {
<del> var iterator = iteratorFn.call(node);
<del> var step;
<add> const iterator = iteratorFn.call(node);
<add> let step;
<ide> while (!(step = iterator.next()).done) {
<ide> if (isValidElement(step.value)) {
<ide> validateExplicitKey(step.value, parentType);
<ide> function validateChildKeys(node, parentType) {
<ide> * @param {ReactElement} element
<ide> */
<ide> function validatePropTypes(element) {
<del> var componentClass = element.type;
<add> const componentClass = element.type;
<ide> if (typeof componentClass !== 'function') {
<ide> return;
<ide> }
<del> var name = componentClass.displayName || componentClass.name;
<del> var propTypes = componentClass.propTypes;
<add> const name = componentClass.displayName || componentClass.name;
<add> const propTypes = componentClass.propTypes;
<ide> if (propTypes) {
<ide> currentlyValidatingElement = element;
<ide> checkPropTypes(propTypes, element.props, 'prop', name, getStackAddendum);
<ide> function validateFragmentProps(fragment) {
<ide> }
<ide>
<ide> export function createElementWithValidation(type, props, children) {
<del> var validType =
<add> const validType =
<ide> typeof type === 'string' ||
<ide> typeof type === 'function' ||
<ide> typeof type === 'symbol' ||
<ide> typeof type === 'number';
<ide> // We warn in this case but don't throw. We expect the element creation to
<ide> // succeed and there will likely be errors in render.
<ide> if (!validType) {
<del> var info = '';
<add> let info = '';
<ide> if (
<ide> type === undefined ||
<ide> (typeof type === 'object' &&
<ide> export function createElementWithValidation(type, props, children) {
<ide> "it's defined in, or you might have mixed up default and named imports.";
<ide> }
<ide>
<del> var sourceInfo = getSourceInfoErrorAddendum(props);
<add> const sourceInfo = getSourceInfoErrorAddendum(props);
<ide> if (sourceInfo) {
<ide> info += sourceInfo;
<ide> } else {
<ide> export function createElementWithValidation(type, props, children) {
<ide> );
<ide> }
<ide>
<del> var element = createElement.apply(this, arguments);
<add> const element = createElement.apply(this, arguments);
<ide>
<ide> // The result can be nullish if a mock or a custom function is used.
<ide> // TODO: Drop this when these are no longer allowed as the type argument.
<ide> export function createElementWithValidation(type, props, children) {
<ide> // (Rendering will throw with a helpful message and as soon as the type is
<ide> // fixed, the key warnings will appear.)
<ide> if (validType) {
<del> for (var i = 2; i < arguments.length; i++) {
<add> for (let i = 2; i < arguments.length; i++) {
<ide> validateChildKeys(arguments[i], type);
<ide> }
<ide> }
<ide> export function createElementWithValidation(type, props, children) {
<ide> }
<ide>
<ide> export function createFactoryWithValidation(type) {
<del> var validatedFactory = createElementWithValidation.bind(null, type);
<add> const validatedFactory = createElementWithValidation.bind(null, type);
<ide> // Legacy hook TODO: Warn if this is accessed
<ide> validatedFactory.type = type;
<ide>
<ide> export function createFactoryWithValidation(type) {
<ide> }
<ide>
<ide> export function cloneElementWithValidation(element, props, children) {
<del> var newElement = cloneElement.apply(this, arguments);
<del> for (var i = 2; i < arguments.length; i++) {
<add> const newElement = cloneElement.apply(this, arguments);
<add> for (let i = 2; i < arguments.length; i++) {
<ide> validateChildKeys(arguments[i], newElement.type);
<ide> }
<ide> validatePropTypes(newElement);
<ide><path>packages/react/src/ReactNoopUpdateQueue.js
<ide>
<ide> import warning from 'fbjs/lib/warning';
<ide>
<del>var didWarnStateUpdateForUnmountedComponent = {};
<add>const didWarnStateUpdateForUnmountedComponent = {};
<ide>
<ide> function warnNoop(publicInstance, callerName) {
<ide> if (__DEV__) {
<del> var constructor = publicInstance.constructor;
<add> const constructor = publicInstance.constructor;
<ide> const componentName =
<ide> (constructor && (constructor.displayName || constructor.name)) ||
<ide> 'ReactClass';
<ide> function warnNoop(publicInstance, callerName) {
<ide> /**
<ide> * This is the abstract API for an update queue.
<ide> */
<del>var ReactNoopUpdateQueue = {
<add>const ReactNoopUpdateQueue = {
<ide> /**
<ide> * Checks whether or not this composite component is mounted.
<ide> * @param {ReactClass} publicInstance The instance we want to test.
<ide><path>packages/react/src/__tests__/ReactAsyncClassComponent-test.internal.js
<ide>
<ide> 'use strict';
<ide>
<del>var React;
<del>var ReactFeatureFlags;
<del>var ReactTestRenderer;
<add>let React;
<add>let ReactFeatureFlags;
<add>let ReactTestRenderer;
<ide>
<ide> describe('ReactAsyncClassComponent', () => {
<ide> describe('debugRenderPhaseSideEffects', () => {
<ide><path>packages/react/src/__tests__/ReactChildren-test.js
<ide> 'use strict';
<ide>
<ide> describe('ReactChildren', () => {
<del> var React;
<del> var ReactTestUtils;
<add> let React;
<add> let ReactTestUtils;
<ide>
<ide> function normalizeCodeLocInfo(str) {
<ide> return str && str.replace(/at .+?:\d+/g, 'at **');
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should support identity for simple', () => {
<del> var context = {};
<del> var callback = jasmine.createSpy().and.callFake(function(kid, index) {
<add> const context = {};
<add> const callback = jasmine.createSpy().and.callFake(function(kid, index) {
<ide> expect(this).toBe(context);
<ide> return kid;
<ide> });
<ide>
<del> var simpleKid = <span key="simple" />;
<add> const simpleKid = <span key="simple" />;
<ide>
<ide> // First pass children into a component to fully simulate what happens when
<ide> // using structures that arrive from transforms.
<ide>
<del> var instance = <div>{simpleKid}</div>;
<add> const instance = <div>{simpleKid}</div>;
<ide> React.Children.forEach(instance.props.children, callback, context);
<ide> expect(callback).toHaveBeenCalledWith(simpleKid, 0);
<ide> callback.calls.reset();
<del> var mappedChildren = React.Children.map(
<add> const mappedChildren = React.Children.map(
<ide> instance.props.children,
<ide> callback,
<ide> context,
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should treat single arrayless child as being in array', () => {
<del> var context = {};
<del> var callback = jasmine.createSpy().and.callFake(function(kid, index) {
<add> const context = {};
<add> const callback = jasmine.createSpy().and.callFake(function(kid, index) {
<ide> expect(this).toBe(context);
<ide> return kid;
<ide> });
<ide>
<del> var simpleKid = <span />;
<del> var instance = <div>{simpleKid}</div>;
<add> const simpleKid = <span />;
<add> const instance = <div>{simpleKid}</div>;
<ide> React.Children.forEach(instance.props.children, callback, context);
<ide> expect(callback).toHaveBeenCalledWith(simpleKid, 0);
<ide> callback.calls.reset();
<del> var mappedChildren = React.Children.map(
<add> const mappedChildren = React.Children.map(
<ide> instance.props.children,
<ide> callback,
<ide> context,
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should treat single child in array as expected', () => {
<del> var context = {};
<del> var callback = jasmine.createSpy().and.callFake(function(kid, index) {
<add> const context = {};
<add> const callback = jasmine.createSpy().and.callFake(function(kid, index) {
<ide> expect(this).toBe(context);
<ide> return kid;
<ide> });
<ide>
<del> var simpleKid = <span key="simple" />;
<del> var instance = <div>{[simpleKid]}</div>;
<add> const simpleKid = <span key="simple" />;
<add> const instance = <div>{[simpleKid]}</div>;
<ide> React.Children.forEach(instance.props.children, callback, context);
<ide> expect(callback).toHaveBeenCalledWith(simpleKid, 0);
<ide> callback.calls.reset();
<del> var mappedChildren = React.Children.map(
<add> const mappedChildren = React.Children.map(
<ide> instance.props.children,
<ide> callback,
<ide> context,
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should be called for each child', () => {
<del> var zero = <div key="keyZero" />;
<del> var one = null;
<del> var two = <div key="keyTwo" />;
<del> var three = null;
<del> var four = <div key="keyFour" />;
<del> var context = {};
<del>
<del> var callback = jasmine.createSpy().and.callFake(function(kid) {
<add> const zero = <div key="keyZero" />;
<add> const one = null;
<add> const two = <div key="keyTwo" />;
<add> const three = null;
<add> const four = <div key="keyFour" />;
<add> const context = {};
<add>
<add> const callback = jasmine.createSpy().and.callFake(function(kid) {
<ide> expect(this).toBe(context);
<ide> return kid;
<ide> });
<ide>
<del> var instance = (
<add> const instance = (
<ide> <div>
<ide> {zero}
<ide> {one}
<ide> describe('ReactChildren', () => {
<ide> React.Children.forEach(instance.props.children, callback, context);
<ide> assertCalls();
<ide>
<del> var mappedChildren = React.Children.map(
<add> const mappedChildren = React.Children.map(
<ide> instance.props.children,
<ide> callback,
<ide> context,
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should traverse children of different kinds', () => {
<del> var div = <div key="divNode" />;
<del> var span = <span key="spanNode" />;
<del> var a = <a key="aNode" />;
<add> const div = <div key="divNode" />;
<add> const span = <span key="spanNode" />;
<add> const a = <a key="aNode" />;
<ide>
<del> var context = {};
<del> var callback = jasmine.createSpy().and.callFake(function(kid) {
<add> const context = {};
<add> const callback = jasmine.createSpy().and.callFake(function(kid) {
<ide> expect(this).toBe(context);
<ide> return kid;
<ide> });
<ide>
<del> var instance = (
<add> const instance = (
<ide> <div>
<ide> {div}
<ide> {[[span]]}
<ide> describe('ReactChildren', () => {
<ide> React.Children.forEach(instance.props.children, callback, context);
<ide> assertCalls();
<ide>
<del> var mappedChildren = React.Children.map(
<add> const mappedChildren = React.Children.map(
<ide> instance.props.children,
<ide> callback,
<ide> context,
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should be called for each child in nested structure', () => {
<del> var zero = <div key="keyZero" />;
<del> var one = null;
<del> var two = <div key="keyTwo" />;
<del> var three = null;
<del> var four = <div key="keyFour" />;
<del> var five = <div key="keyFive" />;
<del>
<del> var context = {};
<del> var callback = jasmine.createSpy().and.callFake(function(kid) {
<add> const zero = <div key="keyZero" />;
<add> const one = null;
<add> const two = <div key="keyTwo" />;
<add> const three = null;
<add> const four = <div key="keyFour" />;
<add> const five = <div key="keyFive" />;
<add>
<add> const context = {};
<add> const callback = jasmine.createSpy().and.callFake(function(kid) {
<ide> return kid;
<ide> });
<ide>
<del> var instance = <div>{[[zero, one, two], [three, four], five]}</div>;
<add> const instance = <div>{[[zero, one, two], [three, four], five]}</div>;
<ide>
<ide> function assertCalls() {
<ide> expect(callback.calls.count()).toBe(6);
<ide> describe('ReactChildren', () => {
<ide> React.Children.forEach(instance.props.children, callback, context);
<ide> assertCalls();
<ide>
<del> var mappedChildren = React.Children.map(
<add> const mappedChildren = React.Children.map(
<ide> instance.props.children,
<ide> callback,
<ide> context,
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should retain key across two mappings', () => {
<del> var zeroForceKey = <div key="keyZero" />;
<del> var oneForceKey = <div key="keyOne" />;
<del> var context = {};
<del> var callback = jasmine.createSpy().and.callFake(function(kid) {
<add> const zeroForceKey = <div key="keyZero" />;
<add> const oneForceKey = <div key="keyOne" />;
<add> const context = {};
<add> const callback = jasmine.createSpy().and.callFake(function(kid) {
<ide> expect(this).toBe(context);
<ide> return kid;
<ide> });
<ide>
<del> var forcedKeys = (
<add> const forcedKeys = (
<ide> <div>
<ide> {zeroForceKey}
<ide> {oneForceKey}
<ide> describe('ReactChildren', () => {
<ide> React.Children.forEach(forcedKeys.props.children, callback, context);
<ide> assertCalls();
<ide>
<del> var mappedChildren = React.Children.map(
<add> const mappedChildren = React.Children.map(
<ide> forcedKeys.props.children,
<ide> callback,
<ide> context,
<ide> describe('ReactChildren', () => {
<ide>
<ide> it('should be called for each child in an iterable without keys', () => {
<ide> spyOnDev(console, 'error');
<del> var threeDivIterable = {
<add> const threeDivIterable = {
<ide> '@@iterator': function() {
<del> var i = 0;
<add> let i = 0;
<ide> return {
<ide> next: function() {
<ide> if (i++ < 3) {
<ide> describe('ReactChildren', () => {
<ide> },
<ide> };
<ide>
<del> var context = {};
<del> var callback = jasmine.createSpy().and.callFake(function(kid) {
<add> const context = {};
<add> const callback = jasmine.createSpy().and.callFake(function(kid) {
<ide> expect(this).toBe(context);
<ide> return kid;
<ide> });
<ide>
<del> var instance = <div>{threeDivIterable}</div>;
<add> const instance = <div>{threeDivIterable}</div>;
<ide>
<ide> function assertCalls() {
<ide> expect(callback.calls.count()).toBe(3);
<ide> describe('ReactChildren', () => {
<ide> console.error.calls.reset();
<ide> }
<ide>
<del> var mappedChildren = React.Children.map(
<add> const mappedChildren = React.Children.map(
<ide> instance.props.children,
<ide> callback,
<ide> context,
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should be called for each child in an iterable with keys', () => {
<del> var threeDivIterable = {
<add> const threeDivIterable = {
<ide> '@@iterator': function() {
<del> var i = 0;
<add> let i = 0;
<ide> return {
<ide> next: function() {
<ide> if (i++ < 3) {
<ide> describe('ReactChildren', () => {
<ide> },
<ide> };
<ide>
<del> var context = {};
<del> var callback = jasmine.createSpy().and.callFake(function(kid) {
<add> const context = {};
<add> const callback = jasmine.createSpy().and.callFake(function(kid) {
<ide> expect(this).toBe(context);
<ide> return kid;
<ide> });
<ide>
<del> var instance = <div>{threeDivIterable}</div>;
<add> const instance = <div>{threeDivIterable}</div>;
<ide>
<ide> function assertCalls() {
<ide> expect(callback.calls.count()).toBe(3);
<ide> describe('ReactChildren', () => {
<ide> React.Children.forEach(instance.props.children, callback, context);
<ide> assertCalls();
<ide>
<del> var mappedChildren = React.Children.map(
<add> const mappedChildren = React.Children.map(
<ide> instance.props.children,
<ide> callback,
<ide> context,
<ide> describe('ReactChildren', () => {
<ide> /*eslint-enable no-extend-native */
<ide>
<ide> try {
<del> var instance = (
<add> const instance = (
<ide> <div>
<ide> {5}
<ide> {12}
<ide> {13}
<ide> </div>
<ide> );
<ide>
<del> var context = {};
<del> var callback = jasmine.createSpy().and.callFake(function(kid) {
<add> const context = {};
<add> const callback = jasmine.createSpy().and.callFake(function(kid) {
<ide> expect(this).toBe(context);
<ide> return kid;
<ide> });
<ide>
<del> var assertCalls = function() {
<add> const assertCalls = function() {
<ide> expect(callback.calls.count()).toBe(3);
<ide> expect(callback).toHaveBeenCalledWith(5, 0);
<ide> expect(callback).toHaveBeenCalledWith(12, 1);
<ide> describe('ReactChildren', () => {
<ide> React.Children.forEach(instance.props.children, callback, context);
<ide> assertCalls();
<ide>
<del> var mappedChildren = React.Children.map(
<add> const mappedChildren = React.Children.map(
<ide> instance.props.children,
<ide> callback,
<ide> context,
<ide> describe('ReactChildren', () => {
<ide> Number.prototype.key = 'rocks';
<ide> /*eslint-enable no-extend-native */
<ide>
<del> var instance = (
<add> const instance = (
<ide> <div>
<ide> {'a'}
<ide> {13}
<ide> </div>
<ide> );
<ide>
<del> var context = {};
<del> var callback = jasmine.createSpy().and.callFake(function(kid) {
<add> const context = {};
<add> const callback = jasmine.createSpy().and.callFake(function(kid) {
<ide> expect(this).toBe(context);
<ide> return kid;
<ide> });
<ide> describe('ReactChildren', () => {
<ide> React.Children.forEach(instance.props.children, callback, context);
<ide> assertCalls();
<ide>
<del> var mappedChildren = React.Children.map(
<add> const mappedChildren = React.Children.map(
<ide> instance.props.children,
<ide> callback,
<ide> context,
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should pass key to returned component', () => {
<del> var mapFn = function(kid, index) {
<add> const mapFn = function(kid, index) {
<ide> return <div>{kid}</div>;
<ide> };
<ide>
<del> var simpleKid = <span key="simple" />;
<add> const simpleKid = <span key="simple" />;
<ide>
<del> var instance = <div>{simpleKid}</div>;
<del> var mappedChildren = React.Children.map(instance.props.children, mapFn);
<add> const instance = <div>{simpleKid}</div>;
<add> const mappedChildren = React.Children.map(instance.props.children, mapFn);
<ide>
<ide> expect(React.Children.count(mappedChildren)).toBe(1);
<ide> expect(mappedChildren[0]).not.toBe(simpleKid);
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should invoke callback with the right context', () => {
<del> var lastContext;
<del> var callback = function(kid, index) {
<add> let lastContext;
<add> const callback = function(kid, index) {
<ide> lastContext = this;
<ide> return this;
<ide> };
<ide>
<ide> // TODO: Use an object to test, after non-object fragments has fully landed.
<del> var scopeTester = 'scope tester';
<add> const scopeTester = 'scope tester';
<ide>
<del> var simpleKid = <span key="simple" />;
<del> var instance = <div>{simpleKid}</div>;
<add> const simpleKid = <span key="simple" />;
<add> const instance = <div>{simpleKid}</div>;
<ide> React.Children.forEach(instance.props.children, callback, scopeTester);
<ide> expect(lastContext).toBe(scopeTester);
<ide>
<del> var mappedChildren = React.Children.map(
<add> const mappedChildren = React.Children.map(
<ide> instance.props.children,
<ide> callback,
<ide> scopeTester,
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should be called for each child', () => {
<del> var zero = <div key="keyZero" />;
<del> var one = null;
<del> var two = <div key="keyTwo" />;
<del> var three = null;
<del> var four = <div key="keyFour" />;
<add> const zero = <div key="keyZero" />;
<add> const one = null;
<add> const two = <div key="keyTwo" />;
<add> const three = null;
<add> const four = <div key="keyFour" />;
<ide>
<del> var mapped = [
<add> const mapped = [
<ide> <div key="giraffe" />, // Key should be joined to obj key
<ide> null, // Key should be added even if we don't supply it!
<ide> <div />, // Key should be added even if not supplied!
<ide> <span />, // Map from null to something.
<ide> <div key="keyFour" />,
<ide> ];
<del> var callback = jasmine.createSpy().and.callFake(function(kid, index) {
<add> const callback = jasmine.createSpy().and.callFake(function(kid, index) {
<ide> return mapped[index];
<ide> });
<ide>
<del> var instance = (
<add> const instance = (
<ide> <div>
<ide> {zero}
<ide> {one}
<ide> describe('ReactChildren', () => {
<ide> expect(callback).toHaveBeenCalledWith(four, 4);
<ide> callback.calls.reset();
<ide>
<del> var mappedChildren = React.Children.map(instance.props.children, callback);
<add> const mappedChildren = React.Children.map(
<add> instance.props.children,
<add> callback,
<add> );
<ide> expect(callback.calls.count()).toBe(5);
<ide> expect(React.Children.count(mappedChildren)).toBe(4);
<ide> // Keys default to indices.
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should be called for each child in nested structure', () => {
<del> var zero = <div key="keyZero" />;
<del> var one = null;
<del> var two = <div key="keyTwo" />;
<del> var three = null;
<del> var four = <div key="keyFour" />;
<del> var five = <div key="keyFive" />;
<del>
<del> var zeroMapped = <div key="giraffe" />; // Key should be overridden
<del> var twoMapped = <div />; // Key should be added even if not supplied!
<del> var fourMapped = <div key="keyFour" />;
<del> var fiveMapped = <div />;
<del>
<del> var callback = jasmine.createSpy().and.callFake(function(kid) {
<add> const zero = <div key="keyZero" />;
<add> const one = null;
<add> const two = <div key="keyTwo" />;
<add> const three = null;
<add> const four = <div key="keyFour" />;
<add> const five = <div key="keyFive" />;
<add>
<add> const zeroMapped = <div key="giraffe" />; // Key should be overridden
<add> const twoMapped = <div />; // Key should be added even if not supplied!
<add> const fourMapped = <div key="keyFour" />;
<add> const fiveMapped = <div />;
<add>
<add> const callback = jasmine.createSpy().and.callFake(function(kid) {
<ide> switch (kid) {
<ide> case zero:
<ide> return zeroMapped;
<ide> describe('ReactChildren', () => {
<ide> }
<ide> });
<ide>
<del> var frag = [[zero, one, two], [three, four], five];
<del> var instance = <div>{[frag]}</div>;
<add> const frag = [[zero, one, two], [three, four], five];
<add> const instance = <div>{[frag]}</div>;
<ide>
<ide> React.Children.forEach(instance.props.children, callback);
<ide> expect(callback.calls.count()).toBe(6);
<ide> describe('ReactChildren', () => {
<ide> expect(callback).toHaveBeenCalledWith(five, 5);
<ide> callback.calls.reset();
<ide>
<del> var mappedChildren = React.Children.map(instance.props.children, callback);
<add> const mappedChildren = React.Children.map(
<add> instance.props.children,
<add> callback,
<add> );
<ide> expect(callback.calls.count()).toBe(6);
<ide> expect(callback).toHaveBeenCalledWith(zero, 0);
<ide> expect(callback).toHaveBeenCalledWith(one, 1);
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should retain key across two mappings', () => {
<del> var zeroForceKey = <div key="keyZero" />;
<del> var oneForceKey = <div key="keyOne" />;
<add> const zeroForceKey = <div key="keyZero" />;
<add> const oneForceKey = <div key="keyOne" />;
<ide>
<ide> // Key should be joined to object key
<del> var zeroForceKeyMapped = <div key="giraffe" />;
<add> const zeroForceKeyMapped = <div key="giraffe" />;
<ide> // Key should be added even if we don't supply it!
<del> var oneForceKeyMapped = <div />;
<add> const oneForceKeyMapped = <div />;
<ide>
<del> var mapFn = function(kid, index) {
<add> const mapFn = function(kid, index) {
<ide> return index === 0 ? zeroForceKeyMapped : oneForceKeyMapped;
<ide> };
<ide>
<del> var forcedKeys = (
<add> const forcedKeys = (
<ide> <div>
<ide> {zeroForceKey}
<ide> {oneForceKey}
<ide> </div>
<ide> );
<ide>
<del> var expectedForcedKeys = ['giraffe/.$keyZero', '.$keyOne'];
<del> var mappedChildrenForcedKeys = React.Children.map(
<add> const expectedForcedKeys = ['giraffe/.$keyZero', '.$keyOne'];
<add> const mappedChildrenForcedKeys = React.Children.map(
<ide> forcedKeys.props.children,
<ide> mapFn,
<ide> );
<del> var mappedForcedKeys = mappedChildrenForcedKeys.map(c => c.key);
<add> const mappedForcedKeys = mappedChildrenForcedKeys.map(c => c.key);
<ide> expect(mappedForcedKeys).toEqual(expectedForcedKeys);
<ide>
<del> var expectedRemappedForcedKeys = [
<add> const expectedRemappedForcedKeys = [
<ide> 'giraffe/.$giraffe/.$keyZero',
<ide> '.$.$keyOne',
<ide> ];
<del> var remappedChildrenForcedKeys = React.Children.map(
<add> const remappedChildrenForcedKeys = React.Children.map(
<ide> mappedChildrenForcedKeys,
<ide> mapFn,
<ide> );
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should not throw if key provided is a dupe with array key', () => {
<del> var zero = <div />;
<del> var one = <div key="0" />;
<add> const zero = <div />;
<add> const one = <div key="0" />;
<ide>
<del> var mapFn = function() {
<add> const mapFn = function() {
<ide> return null;
<ide> };
<ide>
<del> var instance = (
<add> const instance = (
<ide> <div>
<ide> {zero}
<ide> {one}
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should use the same key for a cloned element', () => {
<del> var instance = (
<add> const instance = (
<ide> <div>
<ide> <div />
<ide> </div>
<ide> );
<ide>
<del> var mapped = React.Children.map(
<add> const mapped = React.Children.map(
<ide> instance.props.children,
<ide> element => element,
<ide> );
<ide>
<del> var mappedWithClone = React.Children.map(instance.props.children, element =>
<del> React.cloneElement(element),
<add> const mappedWithClone = React.Children.map(
<add> instance.props.children,
<add> element => React.cloneElement(element),
<ide> );
<ide>
<ide> expect(mapped[0].key).toBe(mappedWithClone[0].key);
<ide> });
<ide>
<ide> it('should use the same key for a cloned element with key', () => {
<del> var instance = (
<add> const instance = (
<ide> <div>
<ide> <div key="unique" />
<ide> </div>
<ide> );
<ide>
<del> var mapped = React.Children.map(
<add> const mapped = React.Children.map(
<ide> instance.props.children,
<ide> element => element,
<ide> );
<ide>
<del> var mappedWithClone = React.Children.map(instance.props.children, element =>
<del> React.cloneElement(element, {key: 'unique'}),
<add> const mappedWithClone = React.Children.map(
<add> instance.props.children,
<add> element => React.cloneElement(element, {key: 'unique'}),
<ide> );
<ide>
<ide> expect(mapped[0].key).toBe(mappedWithClone[0].key);
<ide> });
<ide>
<ide> it('should return 0 for null children', () => {
<del> var numberOfChildren = React.Children.count(null);
<add> const numberOfChildren = React.Children.count(null);
<ide> expect(numberOfChildren).toBe(0);
<ide> });
<ide>
<ide> it('should return 0 for undefined children', () => {
<del> var numberOfChildren = React.Children.count(undefined);
<add> const numberOfChildren = React.Children.count(undefined);
<ide> expect(numberOfChildren).toBe(0);
<ide> });
<ide>
<ide> it('should return 1 for single child', () => {
<del> var simpleKid = <span key="simple" />;
<del> var instance = <div>{simpleKid}</div>;
<del> var numberOfChildren = React.Children.count(instance.props.children);
<add> const simpleKid = <span key="simple" />;
<add> const instance = <div>{simpleKid}</div>;
<add> const numberOfChildren = React.Children.count(instance.props.children);
<ide> expect(numberOfChildren).toBe(1);
<ide> });
<ide>
<ide> it('should count the number of children in flat structure', () => {
<del> var zero = <div key="keyZero" />;
<del> var one = null;
<del> var two = <div key="keyTwo" />;
<del> var three = null;
<del> var four = <div key="keyFour" />;
<add> const zero = <div key="keyZero" />;
<add> const one = null;
<add> const two = <div key="keyTwo" />;
<add> const three = null;
<add> const four = <div key="keyFour" />;
<ide>
<del> var instance = (
<add> const instance = (
<ide> <div>
<ide> {zero}
<ide> {one}
<ide> describe('ReactChildren', () => {
<ide> {four}
<ide> </div>
<ide> );
<del> var numberOfChildren = React.Children.count(instance.props.children);
<add> const numberOfChildren = React.Children.count(instance.props.children);
<ide> expect(numberOfChildren).toBe(5);
<ide> });
<ide>
<ide> it('should count the number of children in nested structure', () => {
<del> var zero = <div key="keyZero" />;
<del> var one = null;
<del> var two = <div key="keyTwo" />;
<del> var three = null;
<del> var four = <div key="keyFour" />;
<del> var five = <div key="keyFive" />;
<del>
<del> var instance = <div>{[[[zero, one, two], [three, four], five], null]}</div>;
<del> var numberOfChildren = React.Children.count(instance.props.children);
<add> const zero = <div key="keyZero" />;
<add> const one = null;
<add> const two = <div key="keyTwo" />;
<add> const three = null;
<add> const four = <div key="keyFour" />;
<add> const five = <div key="keyFive" />;
<add>
<add> const instance = (
<add> <div>{[[[zero, one, two], [three, four], five], null]}</div>
<add> );
<add> const numberOfChildren = React.Children.count(instance.props.children);
<ide> expect(numberOfChildren).toBe(7);
<ide> });
<ide>
<ide> describe('ReactChildren', () => {
<ide> React.Children.toArray([<div />])[0].key,
<ide> );
<ide>
<del> var flattened = React.Children.toArray([
<add> const flattened = React.Children.toArray([
<ide> [<div key="apple" />, <div key="banana" />, <div key="camel" />],
<ide> [<div key="banana" />, <div key="camel" />, <div key="deli" />],
<ide> ]);
<ide> describe('ReactChildren', () => {
<ide> expect(flattened[3].key).toContain('banana');
<ide> expect(flattened[1].key).not.toBe(flattened[3].key);
<ide>
<del> var reversed = React.Children.toArray([
<add> const reversed = React.Children.toArray([
<ide> [<div key="camel" />, <div key="banana" />, <div key="apple" />],
<ide> [<div key="deli" />, <div key="camel" />, <div key="banana" />],
<ide> ]);
<ide> describe('ReactChildren', () => {
<ide> });
<ide>
<ide> it('should escape keys', () => {
<del> var zero = <div key="1" />;
<del> var one = <div key="1=::=2" />;
<del> var instance = (
<add> const zero = <div key="1" />;
<add> const one = <div key="1=::=2" />;
<add> const instance = (
<ide> <div>
<ide> {zero}
<ide> {one}
<ide> </div>
<ide> );
<del> var mappedChildren = React.Children.map(
<add> const mappedChildren = React.Children.map(
<ide> instance.props.children,
<ide> kid => kid,
<ide> );
<ide><path>packages/react/src/__tests__/ReactClassEquivalence-test.js
<ide>
<ide> 'use strict';
<ide>
<del>var spawnSync = require('child_process').spawnSync;
<add>const spawnSync = require('child_process').spawnSync;
<ide>
<ide> describe('ReactClassEquivalence', () => {
<ide> it('tests the same thing for es6 classes and CoffeeScript', () => {
<del> var result1 = runJest('ReactCoffeeScriptClass-test.coffee');
<del> var result2 = runJest('ReactES6Class-test.js');
<add> const result1 = runJest('ReactCoffeeScriptClass-test.coffee');
<add> const result2 = runJest('ReactES6Class-test.js');
<ide> compareResults(result1, result2);
<ide> });
<ide>
<ide> it('tests the same thing for es6 classes and TypeScript', () => {
<del> var result1 = runJest('ReactTypeScriptClass-test.ts');
<del> var result2 = runJest('ReactES6Class-test.js');
<add> const result1 = runJest('ReactTypeScriptClass-test.ts');
<add> const result2 = runJest('ReactES6Class-test.js');
<ide> compareResults(result1, result2);
<ide> });
<ide> });
<ide>
<ide> function runJest(testFile) {
<del> var cwd = process.cwd();
<del> var extension = process.platform === 'win32' ? '.cmd' : '';
<del> var result = spawnSync('yarn' + extension, ['test', testFile], {
<add> const cwd = process.cwd();
<add> const extension = process.platform === 'win32' ? '.cmd' : '';
<add> const result = spawnSync('yarn' + extension, ['test', testFile], {
<ide> cwd,
<ide> env: Object.assign({}, process.env, {
<ide> REACT_CLASS_EQUIVALENCE_TEST: 'true',
<ide> function runJest(testFile) {
<ide> }
<ide>
<ide> function compareResults(a, b) {
<del> var regexp = /EQUIVALENCE.*$/gm;
<del> var aSpecs = (a.match(regexp) || []).sort().join('\n');
<del> var bSpecs = (b.match(regexp) || []).sort().join('\n');
<add> const regexp = /EQUIVALENCE.*$/gm;
<add> const aSpecs = (a.match(regexp) || []).sort().join('\n');
<add> const bSpecs = (b.match(regexp) || []).sort().join('\n');
<ide>
<ide> if (aSpecs.length === 0 && bSpecs.length === 0) {
<ide> throw new Error('No spec results found in the output');
<ide><path>packages/react/src/__tests__/ReactContextValidator-test.js
<ide>
<ide> 'use strict';
<ide>
<del>var PropTypes;
<del>var React;
<del>var ReactDOM;
<del>var ReactTestUtils;
<add>let PropTypes;
<add>let React;
<add>let ReactDOM;
<add>let ReactTestUtils;
<ide>
<ide> describe('ReactContextValidator', () => {
<ide> function normalizeCodeLocInfo(str) {
<ide> describe('ReactContextValidator', () => {
<ide> bar: PropTypes.number,
<ide> };
<ide>
<del> var instance = ReactTestUtils.renderIntoDocument(
<add> const instance = ReactTestUtils.renderIntoDocument(
<ide> <ComponentInFooBarContext />,
<ide> );
<ide> expect(instance.refs.child.context).toEqual({foo: 'abc'});
<ide> });
<ide>
<ide> it('should pass next context to lifecycles', () => {
<del> var actualComponentWillReceiveProps;
<del> var actualShouldComponentUpdate;
<del> var actualComponentWillUpdate;
<add> let actualComponentWillReceiveProps;
<add> let actualShouldComponentUpdate;
<add> let actualComponentWillUpdate;
<ide>
<ide> class Parent extends React.Component {
<ide> getChildContext() {
<ide> describe('ReactContextValidator', () => {
<ide> foo: PropTypes.string,
<ide> };
<ide>
<del> var container = document.createElement('div');
<add> const container = document.createElement('div');
<ide> ReactDOM.render(<Parent foo="abc" />, container);
<ide> ReactDOM.render(<Parent foo="def" />, container);
<ide> expect(actualComponentWillReceiveProps).toEqual({foo: 'def'});
<ide> describe('ReactContextValidator', () => {
<ide> });
<ide>
<ide> it('should not pass previous context to lifecycles', () => {
<del> var actualComponentDidUpdate;
<add> let actualComponentDidUpdate;
<ide>
<ide> class Parent extends React.Component {
<ide> getChildContext() {
<ide> describe('ReactContextValidator', () => {
<ide> foo: PropTypes.string,
<ide> };
<ide>
<del> var container = document.createElement('div');
<add> const container = document.createElement('div');
<ide> ReactDOM.render(<Parent foo="abc" />, container);
<ide> ReactDOM.render(<Parent foo="def" />, container);
<ide> expect(actualComponentDidUpdate).toHaveLength(2);
<ide> describe('ReactContextValidator', () => {
<ide> }
<ide> }
<ide>
<del> var childContext;
<add> let childContext;
<ide> class ChildContextConsumer extends React.Component {
<ide> render() {
<ide> childContext = this.context;
<ide><path>packages/react/src/__tests__/ReactES6Class-test.js
<ide>
<ide> 'use strict';
<ide>
<del>var PropTypes;
<del>var React;
<del>var ReactDOM;
<add>let PropTypes;
<add>let React;
<add>let ReactDOM;
<ide>
<ide> describe('ReactES6Class', () => {
<del> var container;
<del> var freeze = function(expectation) {
<add> let container;
<add> const freeze = function(expectation) {
<ide> Object.freeze(expectation);
<ide> return expectation;
<ide> };
<del> var Inner;
<del> var attachedListener = null;
<del> var renderedName = null;
<add> let Inner;
<add> let attachedListener = null;
<add> let renderedName = null;
<ide>
<ide> beforeEach(() => {
<ide> PropTypes = require('prop-types');
<ide> describe('ReactES6Class', () => {
<ide> });
<ide>
<ide> function test(element, expectedTag, expectedClassName) {
<del> var instance = ReactDOM.render(element, container);
<add> const instance = ReactDOM.render(element, container);
<ide> expect(container.firstChild).not.toBeNull();
<ide> expect(container.firstChild.tagName).toBe(expectedTag);
<ide> expect(container.firstChild.className).toBe(expectedClassName);
<ide> describe('ReactES6Class', () => {
<ide> return <span className={this.state.bar} />;
<ide> }
<ide> }
<del> var instance = test(<Foo initialValue="foo" />, 'DIV', 'foo');
<add> const instance = test(<Foo initialValue="foo" />, 'DIV', 'foo');
<ide> instance.changeState();
<ide> test(<Foo />, 'SPAN', 'bar');
<ide> });
<ide> describe('ReactES6Class', () => {
<ide> this.state = {tag: context.tag, className: this.context.className};
<ide> }
<ide> render() {
<del> var Tag = this.state.tag;
<add> const Tag = this.state.tag;
<ide> return <Tag className={this.state.className} />;
<ide> }
<ide> }
<ide> describe('ReactES6Class', () => {
<ide> });
<ide>
<ide> it('renders only once when setting state in componentWillMount', () => {
<del> var renderCount = 0;
<add> let renderCount = 0;
<ide> class Foo extends React.Component {
<ide> constructor(props) {
<ide> super(props);
<ide> describe('ReactES6Class', () => {
<ide> });
<ide>
<ide> it('will call all the normal life cycle methods', () => {
<del> var lifeCycles = [];
<add> let lifeCycles = [];
<ide> class Foo extends React.Component {
<ide> constructor() {
<ide> super();
<ide> describe('ReactES6Class', () => {
<ide>
<ide> it('warns when classic properties are defined on the instance, but does not invoke them.', () => {
<ide> spyOnDev(console, 'error');
<del> var getDefaultPropsWasCalled = false;
<del> var getInitialStateWasCalled = false;
<add> let getDefaultPropsWasCalled = false;
<add> let getInitialStateWasCalled = false;
<ide> class Foo extends React.Component {
<ide> constructor() {
<ide> super();
<ide> describe('ReactES6Class', () => {
<ide>
<ide> it('should throw AND warn when trying to access classic APIs', () => {
<ide> spyOnDev(console, 'warn');
<del> var instance = test(<Inner name="foo" />, 'DIV', 'foo');
<add> const instance = test(<Inner name="foo" />, 'DIV', 'foo');
<ide> expect(() => instance.replaceState({})).toThrow();
<ide> expect(() => instance.isMounted()).toThrow();
<ide> if (__DEV__) {
<ide> describe('ReactES6Class', () => {
<ide> return <Inner name="foo" ref="inner" />;
<ide> }
<ide> }
<del> var instance = test(<Foo />, 'DIV', 'foo');
<add> const instance = test(<Foo />, 'DIV', 'foo');
<ide> expect(instance.refs.inner.getName()).toBe('foo');
<ide> });
<ide>
<ide> it('supports drilling through to the DOM using findDOMNode', () => {
<del> var instance = test(<Inner name="foo" />, 'DIV', 'foo');
<del> var node = ReactDOM.findDOMNode(instance);
<add> const instance = test(<Inner name="foo" />, 'DIV', 'foo');
<add> const node = ReactDOM.findDOMNode(instance);
<ide> expect(node).toBe(container.firstChild);
<ide> });
<ide> });
<ide><path>packages/react/src/__tests__/ReactElement-test.js
<ide>
<ide> 'use strict';
<ide>
<del>var React;
<del>var ReactDOM;
<del>var ReactTestUtils;
<add>let React;
<add>let ReactDOM;
<add>let ReactTestUtils;
<ide>
<ide> describe('ReactElement', () => {
<del> var ComponentClass;
<del> var originalSymbol;
<add> let ComponentClass;
<add> let originalSymbol;
<ide>
<ide> beforeEach(() => {
<ide> jest.resetModules();
<ide> describe('ReactElement', () => {
<ide> });
<ide>
<ide> it('returns a complete element according to spec', () => {
<del> var element = React.createFactory(ComponentClass)();
<add> const element = React.createFactory(ComponentClass)();
<ide> expect(element.type).toBe(ComponentClass);
<ide> expect(element.key).toBe(null);
<ide> expect(element.ref).toBe(null);
<ide> describe('ReactElement', () => {
<ide>
<ide> it('should warn when `key` is being accessed on composite element', () => {
<ide> spyOnDev(console, 'error');
<del> var container = document.createElement('div');
<add> const container = document.createElement('div');
<ide> class Child extends React.Component {
<ide> render() {
<ide> return <div> {this.props.key} </div>;
<ide> describe('ReactElement', () => {
<ide>
<ide> it('should warn when `key` is being accessed on a host element', () => {
<ide> spyOnDev(console, 'error');
<del> var element = <div key="3" />;
<add> const element = <div key="3" />;
<ide> if (__DEV__) {
<ide> expect(console.error.calls.count()).toBe(0);
<ide> }
<ide> describe('ReactElement', () => {
<ide>
<ide> it('should warn when `ref` is being accessed', () => {
<ide> spyOnDev(console, 'error');
<del> var container = document.createElement('div');
<add> const container = document.createElement('div');
<ide> class Child extends React.Component {
<ide> render() {
<ide> return <div> {this.props.ref} </div>;
<ide> describe('ReactElement', () => {
<ide> });
<ide>
<ide> it('allows a string to be passed as the type', () => {
<del> var element = React.createFactory('div')();
<add> const element = React.createFactory('div')();
<ide> expect(element.type).toBe('div');
<ide> expect(element.key).toBe(null);
<ide> expect(element.ref).toBe(null);
<ide> describe('ReactElement', () => {
<ide> });
<ide>
<ide> it('returns an immutable element', () => {
<del> var element = React.createFactory(ComponentClass)();
<add> const element = React.createFactory(ComponentClass)();
<ide> if (__DEV__) {
<ide> expect(() => (element.type = 'div')).toThrow();
<ide> } else {
<ide> describe('ReactElement', () => {
<ide> });
<ide>
<ide> it('does not reuse the original config object', () => {
<del> var config = {foo: 1};
<del> var element = React.createFactory(ComponentClass)(config);
<add> const config = {foo: 1};
<add> const element = React.createFactory(ComponentClass)(config);
<ide> expect(element.props.foo).toBe(1);
<ide> config.foo = 2;
<ide> expect(element.props.foo).toBe(1);
<ide> });
<ide>
<ide> it('does not fail if config has no prototype', () => {
<del> var config = Object.create(null, {foo: {value: 1, enumerable: true}});
<del> var element = React.createFactory(ComponentClass)(config);
<add> const config = Object.create(null, {foo: {value: 1, enumerable: true}});
<add> const element = React.createFactory(ComponentClass)(config);
<ide> expect(element.props.foo).toBe(1);
<ide> });
<ide>
<ide> it('extracts key and ref from the config', () => {
<del> var element = React.createFactory(ComponentClass)({
<add> const element = React.createFactory(ComponentClass)({
<ide> key: '12',
<ide> ref: '34',
<ide> foo: '56',
<ide> describe('ReactElement', () => {
<ide> });
<ide>
<ide> it('extracts null key and ref', () => {
<del> var element = React.createFactory(ComponentClass)({
<add> const element = React.createFactory(ComponentClass)({
<ide> key: null,
<ide> ref: null,
<ide> foo: '12',
<ide> describe('ReactElement', () => {
<ide> });
<ide>
<ide> it('ignores undefined key and ref', () => {
<del> var props = {
<add> const props = {
<ide> foo: '56',
<ide> key: undefined,
<ide> ref: undefined,
<ide> };
<del> var element = React.createFactory(ComponentClass)(props);
<add> const element = React.createFactory(ComponentClass)(props);
<ide> expect(element.type).toBe(ComponentClass);
<ide> expect(element.key).toBe(null);
<ide> expect(element.ref).toBe(null);
<ide> describe('ReactElement', () => {
<ide> });
<ide>
<ide> it('ignores key and ref warning getters', () => {
<del> var elementA = React.createElement('div');
<del> var elementB = React.createElement('div', elementA.props);
<add> const elementA = React.createElement('div');
<add> const elementB = React.createElement('div', elementA.props);
<ide> expect(elementB.key).toBe(null);
<ide> expect(elementB.ref).toBe(null);
<ide> });
<ide>
<ide> it('coerces the key to a string', () => {
<del> var element = React.createFactory(ComponentClass)({
<add> const element = React.createFactory(ComponentClass)({
<ide> key: 12,
<ide> foo: '56',
<ide> });
<ide> describe('ReactElement', () => {
<ide> });
<ide>
<ide> it('preserves the owner on the element', () => {
<del> var Component = React.createFactory(ComponentClass);
<del> var element;
<add> const Component = React.createFactory(ComponentClass);
<add> let element;
<ide>
<ide> class Wrapper extends React.Component {
<ide> render() {
<ide> describe('ReactElement', () => {
<ide> }
<ide> }
<ide>
<del> var instance = ReactTestUtils.renderIntoDocument(
<add> const instance = ReactTestUtils.renderIntoDocument(
<ide> React.createElement(Wrapper),
<ide> );
<ide> expect(element._owner.stateNode).toBe(instance);
<ide> });
<ide>
<ide> it('merges an additional argument onto the children prop', () => {
<del> var a = 1;
<del> var element = React.createFactory(ComponentClass)(
<add> const a = 1;
<add> const element = React.createFactory(ComponentClass)(
<ide> {
<ide> children: 'text',
<ide> },
<ide> describe('ReactElement', () => {
<ide> });
<ide>
<ide> it('does not override children if no rest args are provided', () => {
<del> var element = React.createFactory(ComponentClass)({
<add> const element = React.createFactory(ComponentClass)({
<ide> children: 'text',
<ide> });
<ide> expect(element.props.children).toBe('text');
<ide> });
<ide>
<ide> it('overrides children if null is provided as an argument', () => {
<del> var element = React.createFactory(ComponentClass)(
<add> const element = React.createFactory(ComponentClass)(
<ide> {
<ide> children: 'text',
<ide> },
<ide> describe('ReactElement', () => {
<ide> });
<ide>
<ide> it('merges rest arguments onto the children prop in an array', () => {
<del> var a = 1;
<del> var b = 2;
<del> var c = 3;
<del> var element = React.createFactory(ComponentClass)(null, a, b, c);
<add> const a = 1;
<add> const b = 2;
<add> const c = 3;
<add> const element = React.createFactory(ComponentClass)(null, a, b, c);
<ide> expect(element.props.children).toEqual([1, 2, 3]);
<ide> });
<ide>
<ide> describe('ReactElement', () => {
<ide> }
<ide> StaticMethodComponentClass.someStaticMethod = () => 'someReturnValue';
<ide>
<del> var element = React.createElement(StaticMethodComponentClass);
<add> const element = React.createElement(StaticMethodComponentClass);
<ide> expect(element.type.someStaticMethod()).toBe('someReturnValue');
<ide> });
<ide>
<ide> describe('ReactElement', () => {
<ide> expect(React.isValidElement(Component)).toEqual(false);
<ide> expect(React.isValidElement({type: 'div', props: {}})).toEqual(false);
<ide>
<del> var jsonElement = JSON.stringify(React.createElement('div'));
<add> const jsonElement = JSON.stringify(React.createElement('div'));
<ide> expect(React.isValidElement(JSON.parse(jsonElement))).toBe(true);
<ide> });
<ide>
<ide> // NOTE: We're explicitly not using JSX here. This is intended to test
<ide> // classic JS without JSX.
<ide> it('is indistinguishable from a plain object', () => {
<del> var element = React.createElement('div', {className: 'foo'});
<del> var object = {};
<add> const element = React.createElement('div', {className: 'foo'});
<add> const object = {};
<ide> expect(element.constructor).toBe(object.constructor);
<ide> });
<ide>
<ide> describe('ReactElement', () => {
<ide> }
<ide> Component.defaultProps = {fruit: 'persimmon'};
<ide>
<del> var container = document.createElement('div');
<del> var instance = ReactDOM.render(
<add> const container = document.createElement('div');
<add> const instance = ReactDOM.render(
<ide> React.createElement(Component, {fruit: 'mango'}),
<ide> container,
<ide> );
<ide> describe('ReactElement', () => {
<ide> }
<ide> Component.defaultProps = {prop: 'testKey'};
<ide>
<del> var instance = ReactTestUtils.renderIntoDocument(
<add> const instance = ReactTestUtils.renderIntoDocument(
<ide> React.createElement(Component),
<ide> );
<ide> expect(instance.props.prop).toBe('testKey');
<ide>
<del> var inst2 = ReactTestUtils.renderIntoDocument(
<add> const inst2 = ReactTestUtils.renderIntoDocument(
<ide> React.createElement(Component, {prop: null}),
<ide> );
<ide> expect(inst2.props.prop).toBe(null);
<ide> describe('ReactElement', () => {
<ide> it('throws when changing a prop (in dev) after element creation', () => {
<ide> class Outer extends React.Component {
<ide> render() {
<del> var el = <div className="moo" />;
<add> const el = <div className="moo" />;
<ide>
<ide> if (__DEV__) {
<ide> expect(function() {
<ide> describe('ReactElement', () => {
<ide> return el;
<ide> }
<ide> }
<del> var outer = ReactTestUtils.renderIntoDocument(<Outer color="orange" />);
<add> const outer = ReactTestUtils.renderIntoDocument(<Outer color="orange" />);
<ide> if (__DEV__) {
<ide> expect(ReactDOM.findDOMNode(outer).className).toBe('moo');
<ide> } else {
<ide> describe('ReactElement', () => {
<ide> });
<ide>
<ide> it('throws when adding a prop (in dev) after element creation', () => {
<del> var container = document.createElement('div');
<add> const container = document.createElement('div');
<ide> class Outer extends React.Component {
<ide> render() {
<del> var el = <div>{this.props.sound}</div>;
<add> const el = <div>{this.props.sound}</div>;
<ide>
<ide> if (__DEV__) {
<ide> expect(function() {
<ide> describe('ReactElement', () => {
<ide> }
<ide> }
<ide> Outer.defaultProps = {sound: 'meow'};
<del> var outer = ReactDOM.render(<Outer />, container);
<add> const outer = ReactDOM.render(<Outer />, container);
<ide> expect(ReactDOM.findDOMNode(outer).textContent).toBe('meow');
<ide> if (__DEV__) {
<ide> expect(ReactDOM.findDOMNode(outer).className).toBe('');
<ide> describe('ReactElement', () => {
<ide> return <div />;
<ide> }
<ide> }
<del> var test = ReactTestUtils.renderIntoDocument(<Test value={+undefined} />);
<add> const test = ReactTestUtils.renderIntoDocument(<Test value={+undefined} />);
<ide> expect(test.props.value).toBeNaN();
<ide> });
<ide>
<ide> describe('ReactElement', () => {
<ide> // Rudimentary polyfill
<ide> // Once all jest engines support Symbols natively we can swap this to test
<ide> // WITH native Symbols by default.
<del> var REACT_ELEMENT_TYPE = function() {}; // fake Symbol
<del> var OTHER_SYMBOL = function() {}; // another fake Symbol
<add> const REACT_ELEMENT_TYPE = function() {}; // fake Symbol
<add> const OTHER_SYMBOL = function() {}; // another fake Symbol
<ide> global.Symbol = function(name) {
<ide> return OTHER_SYMBOL;
<ide> };
<ide> describe('ReactElement', () => {
<ide> expect(React.isValidElement(Component)).toEqual(false);
<ide> expect(React.isValidElement({type: 'div', props: {}})).toEqual(false);
<ide>
<del> var jsonElement = JSON.stringify(React.createElement('div'));
<add> const jsonElement = JSON.stringify(React.createElement('div'));
<ide> expect(React.isValidElement(JSON.parse(jsonElement))).toBe(false);
<ide> });
<ide> });
<ide><path>packages/react/src/__tests__/ReactElementClone-test.js
<ide>
<ide> 'use strict';
<ide>
<del>var PropTypes;
<del>var React;
<del>var ReactDOM;
<del>var ReactTestUtils;
<add>let PropTypes;
<add>let React;
<add>let ReactDOM;
<add>let ReactTestUtils;
<ide>
<ide> describe('ReactElementClone', () => {
<del> var ComponentClass;
<add> let ComponentClass;
<ide>
<ide> beforeEach(() => {
<ide> PropTypes = require('prop-types');
<ide> describe('ReactElementClone', () => {
<ide> );
<ide> }
<ide> }
<del> var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
<add> const component = ReactTestUtils.renderIntoDocument(<Grandparent />);
<ide> expect(ReactDOM.findDOMNode(component).childNodes[0].className).toBe('xyz');
<ide> });
<ide>
<ide> describe('ReactElementClone', () => {
<ide> );
<ide> }
<ide> }
<del> var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
<add> const component = ReactTestUtils.renderIntoDocument(<Grandparent />);
<ide> expect(ReactDOM.findDOMNode(component).childNodes[0].className).toBe('xyz');
<ide> });
<ide>
<ide> it('does not fail if config has no prototype', () => {
<del> var config = Object.create(null, {foo: {value: 1, enumerable: true}});
<add> const config = Object.create(null, {foo: {value: 1, enumerable: true}});
<ide> React.cloneElement(<div />, config);
<ide> });
<ide>
<ide> describe('ReactElementClone', () => {
<ide> }
<ide> }
<ide>
<del> var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
<add> const component = ReactTestUtils.renderIntoDocument(<Grandparent />);
<ide> expect(component.refs.yolo.tagName).toBe('DIV');
<ide> });
<ide>
<ide> describe('ReactElementClone', () => {
<ide> return null;
<ide> }
<ide> }
<del> var clone = React.cloneElement(<Component />, {key: 'xyz'});
<add> const clone = React.cloneElement(<Component />, {key: 'xyz'});
<ide> expect(clone.key).toBe('xyz');
<ide> });
<ide>
<ide> describe('ReactElementClone', () => {
<ide> }
<ide> }
<ide>
<del> var clone = React.cloneElement(
<add> const clone = React.cloneElement(
<ide> <Component>xyz</Component>,
<ide> {children: <Component />},
<ide> <div />,
<ide> describe('ReactElementClone', () => {
<ide> });
<ide>
<ide> it('should override children if undefined is provided as an argument', () => {
<del> var element = React.createElement(
<add> const element = React.createElement(
<ide> ComponentClass,
<ide> {
<ide> children: 'text',
<ide> describe('ReactElementClone', () => {
<ide> );
<ide> expect(element.props.children).toBe(undefined);
<ide>
<del> var element2 = React.cloneElement(
<add> const element2 = React.cloneElement(
<ide> React.createElement(ComponentClass, {
<ide> children: 'text',
<ide> }),
<ide> describe('ReactElementClone', () => {
<ide> it('should support keys and refs', () => {
<ide> class Parent extends React.Component {
<ide> render() {
<del> var clone = React.cloneElement(this.props.children, {
<add> const clone = React.cloneElement(this.props.children, {
<ide> key: 'xyz',
<ide> ref: 'xyz',
<ide> });
<ide> describe('ReactElementClone', () => {
<ide> }
<ide> }
<ide>
<del> var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
<add> const component = ReactTestUtils.renderIntoDocument(<Grandparent />);
<ide> expect(component.refs.parent.refs.xyz.tagName).toBe('SPAN');
<ide> });
<ide>
<ide> it('should steal the ref if a new ref is specified', () => {
<ide> class Parent extends React.Component {
<ide> render() {
<del> var clone = React.cloneElement(this.props.children, {ref: 'xyz'});
<add> const clone = React.cloneElement(this.props.children, {ref: 'xyz'});
<ide> return <div>{clone}</div>;
<ide> }
<ide> }
<ide> describe('ReactElementClone', () => {
<ide> }
<ide> }
<ide>
<del> var component = ReactTestUtils.renderIntoDocument(<Grandparent />);
<add> const component = ReactTestUtils.renderIntoDocument(<Grandparent />);
<ide> expect(component.refs.child).toBeUndefined();
<ide> expect(component.refs.parent.refs.xyz.tagName).toBe('SPAN');
<ide> });
<ide> describe('ReactElementClone', () => {
<ide> }
<ide> Component.defaultProps = {prop: 'testKey'};
<ide>
<del> var instance = React.createElement(Component);
<del> var clonedInstance = React.cloneElement(instance, {prop: undefined});
<add> const instance = React.createElement(Component);
<add> const clonedInstance = React.cloneElement(instance, {prop: undefined});
<ide> expect(clonedInstance.props.prop).toBe('testKey');
<del> var clonedInstance2 = React.cloneElement(instance, {prop: null});
<add> const clonedInstance2 = React.cloneElement(instance, {prop: null});
<ide> expect(clonedInstance2.props.prop).toBe(null);
<ide>
<del> var instance2 = React.createElement(Component, {prop: 'newTestKey'});
<del> var cloneInstance3 = React.cloneElement(instance2, {prop: undefined});
<add> const instance2 = React.createElement(Component, {prop: 'newTestKey'});
<add> const cloneInstance3 = React.cloneElement(instance2, {prop: undefined});
<ide> expect(cloneInstance3.props.prop).toBe('testKey');
<del> var cloneInstance4 = React.cloneElement(instance2, {});
<add> const cloneInstance4 = React.cloneElement(instance2, {});
<ide> expect(cloneInstance4.props.prop).toBe('newTestKey');
<ide> });
<ide>
<ide> describe('ReactElementClone', () => {
<ide> });
<ide>
<ide> it('should ignore key and ref warning getters', () => {
<del> var elementA = React.createElement('div');
<del> var elementB = React.cloneElement(elementA, elementA.props);
<add> const elementA = React.createElement('div');
<add> const elementB = React.cloneElement(elementA, elementA.props);
<ide> expect(elementB.key).toBe(null);
<ide> expect(elementB.ref).toBe(null);
<ide> });
<ide>
<ide> it('should ignore undefined key and ref', () => {
<del> var element = React.createFactory(ComponentClass)({
<add> const element = React.createFactory(ComponentClass)({
<ide> key: '12',
<ide> ref: '34',
<ide> foo: '56',
<ide> });
<del> var props = {
<add> const props = {
<ide> key: undefined,
<ide> ref: undefined,
<ide> foo: 'ef',
<ide> };
<del> var clone = React.cloneElement(element, props);
<add> const clone = React.cloneElement(element, props);
<ide> expect(clone.type).toBe(ComponentClass);
<ide> expect(clone.key).toBe('12');
<ide> expect(clone.ref).toBe('34');
<ide> describe('ReactElementClone', () => {
<ide> });
<ide>
<ide> it('should extract null key and ref', () => {
<del> var element = React.createFactory(ComponentClass)({
<add> const element = React.createFactory(ComponentClass)({
<ide> key: '12',
<ide> ref: '34',
<ide> foo: '56',
<ide> });
<del> var props = {
<add> const props = {
<ide> key: null,
<ide> ref: null,
<ide> foo: 'ef',
<ide> };
<del> var clone = React.cloneElement(element, props);
<add> const clone = React.cloneElement(element, props);
<ide> expect(clone.type).toBe(ComponentClass);
<ide> expect(clone.key).toBe('null');
<ide> expect(clone.ref).toBe(null);
<ide><path>packages/react/src/__tests__/ReactElementValidator-test.js
<ide> // NOTE: We're explicitly not using JSX in this file. This is intended to test
<ide> // classic JS without JSX.
<ide>
<del>var PropTypes;
<del>var React;
<del>var ReactDOM;
<del>var ReactTestUtils;
<add>let PropTypes;
<add>let React;
<add>let ReactDOM;
<add>let ReactTestUtils;
<ide>
<ide> describe('ReactElementValidator', () => {
<ide> function normalizeCodeLocInfo(str) {
<ide> return str && str.replace(/at .+?:\d+/g, 'at **');
<ide> }
<ide>
<del> var ComponentClass;
<add> let ComponentClass;
<ide>
<ide> beforeEach(() => {
<ide> jest.resetModules();
<ide> describe('ReactElementValidator', () => {
<ide>
<ide> it('warns for keys for arrays of elements in rest args', () => {
<ide> spyOnDev(console, 'error');
<del> var Component = React.createFactory(ComponentClass);
<add> const Component = React.createFactory(ComponentClass);
<ide>
<ide> Component(null, [Component(), Component()]);
<ide>
<ide> describe('ReactElementValidator', () => {
<ide>
<ide> it('warns for keys for arrays of elements with owner info', () => {
<ide> spyOnDev(console, 'error');
<del> var Component = React.createFactory(ComponentClass);
<add> const Component = React.createFactory(ComponentClass);
<ide>
<ide> class InnerClass extends React.Component {
<ide> render() {
<ide> return Component(null, this.props.childSet);
<ide> }
<ide> }
<ide>
<del> var InnerComponent = React.createFactory(InnerClass);
<add> const InnerComponent = React.createFactory(InnerClass);
<ide>
<ide> class ComponentWrapper extends React.Component {
<ide> render() {
<ide> describe('ReactElementValidator', () => {
<ide> }
<ide> Object.defineProperty(Anonymous, 'name', {value: undefined});
<ide>
<del> var divs = [<div />, <div />];
<add> const divs = [<div />, <div />];
<ide> ReactTestUtils.renderIntoDocument(<Anonymous>{divs}</Anonymous>);
<ide>
<ide> if (__DEV__) {
<ide> describe('ReactElementValidator', () => {
<ide> it('warns for keys for arrays of elements with no owner info', () => {
<ide> spyOnDev(console, 'error');
<ide>
<del> var divs = [<div />, <div />];
<add> const divs = [<div />, <div />];
<ide> ReactTestUtils.renderIntoDocument(<div>{divs}</div>);
<ide>
<ide> if (__DEV__) {
<ide> describe('ReactElementValidator', () => {
<ide>
<ide> it('warns for keys for iterables of elements in rest args', () => {
<ide> spyOnDev(console, 'error');
<del> var Component = React.createFactory(ComponentClass);
<add> const Component = React.createFactory(ComponentClass);
<ide>
<del> var iterable = {
<add> const iterable = {
<ide> '@@iterator': function() {
<del> var i = 0;
<add> let i = 0;
<ide> return {
<ide> next: function() {
<del> var done = ++i > 2;
<add> const done = ++i > 2;
<ide> return {value: done ? undefined : Component(), done: done};
<ide> },
<ide> };
<ide> describe('ReactElementValidator', () => {
<ide> });
<ide>
<ide> it('does not warns for arrays of elements with keys', () => {
<del> var Component = React.createFactory(ComponentClass);
<add> const Component = React.createFactory(ComponentClass);
<ide>
<ide> Component(null, [Component({key: '#1'}), Component({key: '#2'})]);
<ide> });
<ide>
<ide> it('does not warns for iterable elements with keys', () => {
<del> var Component = React.createFactory(ComponentClass);
<add> const Component = React.createFactory(ComponentClass);
<ide>
<del> var iterable = {
<add> const iterable = {
<ide> '@@iterator': function() {
<del> var i = 0;
<add> let i = 0;
<ide> return {
<ide> next: function() {
<del> var done = ++i > 2;
<add> const done = ++i > 2;
<ide> return {
<ide> value: done ? undefined : Component({key: '#' + i}),
<ide> done: done,
<ide> describe('ReactElementValidator', () => {
<ide> });
<ide>
<ide> it('does not warn when the element is directly in rest args', () => {
<del> var Component = React.createFactory(ComponentClass);
<add> const Component = React.createFactory(ComponentClass);
<ide>
<ide> Component(null, Component(), Component());
<ide> });
<ide>
<ide> it('does not warn when the array contains a non-element', () => {
<del> var Component = React.createFactory(ComponentClass);
<add> const Component = React.createFactory(ComponentClass);
<ide>
<ide> Component(null, [{}, {}]);
<ide> });
<ide> describe('ReactElementValidator', () => {
<ide> function TestComponent() {
<ide> return <div />;
<ide> }
<del> var TestFactory = React.createFactory(TestComponent);
<add> const TestFactory = React.createFactory(TestComponent);
<ide> expect(TestFactory.type).toBe(TestComponent);
<ide> if (__DEV__) {
<ide> expect(console.warn.calls.count()).toBe(1);
<ide> describe('ReactElementValidator', () => {
<ide> }
<ide> }
<ide>
<del> var node = document.createElement('div');
<add> const node = document.createElement('div');
<ide> // This shouldn't cause a stack overflow or any other problems (#3883)
<ide> ReactTestUtils.renderIntoDocument(<DOMContainer>{node}</DOMContainer>);
<ide> });
<ide> describe('ReactElementValidator', () => {
<ide> // We don't suggest this since it silences all sorts of warnings, but we
<ide> // shouldn't blow up either.
<ide>
<del> var child = {
<add> const child = {
<ide> $$typeof: <div />.$$typeof,
<ide> type: 'span',
<ide> key: null,
<ide> describe('ReactElementValidator', () => {
<ide>
<ide> it('does not blow up on key warning with undefined type', () => {
<ide> spyOnDev(console, 'error');
<del> var Foo = undefined;
<add> const Foo = undefined;
<ide> void <Foo>{[<div />]}</Foo>;
<ide> if (__DEV__) {
<ide> expect(console.error.calls.count()).toBe(1);
<ide><path>packages/react/src/__tests__/ReactJSXElement-test.js
<ide>
<ide> 'use strict';
<ide>
<del>var React;
<del>var ReactDOM;
<del>var ReactTestUtils;
<add>let React;
<add>let ReactDOM;
<add>let ReactTestUtils;
<ide>
<ide> describe('ReactJSXElement', () => {
<del> var Component;
<add> let Component;
<ide>
<ide> beforeEach(() => {
<ide> jest.resetModules();
<ide> describe('ReactJSXElement', () => {
<ide> });
<ide>
<ide> it('returns a complete element according to spec', () => {
<del> var element = <Component />;
<add> const element = <Component />;
<ide> expect(element.type).toBe(Component);
<ide> expect(element.key).toBe(null);
<ide> expect(element.ref).toBe(null);
<del> var expectation = {};
<add> const expectation = {};
<ide> Object.freeze(expectation);
<ide> expect(element.props).toEqual(expectation);
<ide> });
<ide>
<ide> it('allows a lower-case to be passed as the string type', () => {
<del> var element = <div />;
<add> const element = <div />;
<ide> expect(element.type).toBe('div');
<ide> expect(element.key).toBe(null);
<ide> expect(element.ref).toBe(null);
<del> var expectation = {};
<add> const expectation = {};
<ide> Object.freeze(expectation);
<ide> expect(element.props).toEqual(expectation);
<ide> });
<ide>
<ide> it('allows a string to be passed as the type', () => {
<del> var TagName = 'div';
<del> var element = <TagName />;
<add> const TagName = 'div';
<add> const element = <TagName />;
<ide> expect(element.type).toBe('div');
<ide> expect(element.key).toBe(null);
<ide> expect(element.ref).toBe(null);
<del> var expectation = {};
<add> const expectation = {};
<ide> Object.freeze(expectation);
<ide> expect(element.props).toEqual(expectation);
<ide> });
<ide>
<ide> it('returns an immutable element', () => {
<del> var element = <Component />;
<add> const element = <Component />;
<ide> if (__DEV__) {
<ide> expect(() => (element.type = 'div')).toThrow();
<ide> } else {
<ide> describe('ReactJSXElement', () => {
<ide> });
<ide>
<ide> it('does not reuse the object that is spread into props', () => {
<del> var config = {foo: 1};
<del> var element = <Component {...config} />;
<add> const config = {foo: 1};
<add> const element = <Component {...config} />;
<ide> expect(element.props.foo).toBe(1);
<ide> config.foo = 2;
<ide> expect(element.props.foo).toBe(1);
<ide> });
<ide>
<ide> it('extracts key and ref from the rest of the props', () => {
<del> var element = <Component key="12" ref="34" foo="56" />;
<add> const element = <Component key="12" ref="34" foo="56" />;
<ide> expect(element.type).toBe(Component);
<ide> expect(element.key).toBe('12');
<ide> expect(element.ref).toBe('34');
<del> var expectation = {foo: '56'};
<add> const expectation = {foo: '56'};
<ide> Object.freeze(expectation);
<ide> expect(element.props).toEqual(expectation);
<ide> });
<ide>
<ide> it('coerces the key to a string', () => {
<del> var element = <Component key={12} foo="56" />;
<add> const element = <Component key={12} foo="56" />;
<ide> expect(element.type).toBe(Component);
<ide> expect(element.key).toBe('12');
<ide> expect(element.ref).toBe(null);
<del> var expectation = {foo: '56'};
<add> const expectation = {foo: '56'};
<ide> Object.freeze(expectation);
<ide> expect(element.props).toEqual(expectation);
<ide> });
<ide>
<ide> it('merges JSX children onto the children prop', () => {
<del> var a = 1;
<del> var element = <Component children="text">{a}</Component>;
<add> const a = 1;
<add> const element = <Component children="text">{a}</Component>;
<ide> expect(element.props.children).toBe(a);
<ide> });
<ide>
<ide> it('does not override children if no JSX children are provided', () => {
<del> var element = <Component children="text" />;
<add> const element = <Component children="text" />;
<ide> expect(element.props.children).toBe('text');
<ide> });
<ide>
<ide> it('overrides children if null is provided as a JSX child', () => {
<del> var element = <Component children="text">{null}</Component>;
<add> const element = <Component children="text">{null}</Component>;
<ide> expect(element.props.children).toBe(null);
<ide> });
<ide>
<ide> it('overrides children if undefined is provided as an argument', () => {
<del> var element = <Component children="text">{undefined}</Component>;
<add> const element = <Component children="text">{undefined}</Component>;
<ide> expect(element.props.children).toBe(undefined);
<ide>
<del> var element2 = React.cloneElement(
<add> const element2 = React.cloneElement(
<ide> <Component children="text" />,
<ide> {},
<ide> undefined,
<ide> describe('ReactJSXElement', () => {
<ide> });
<ide>
<ide> it('merges JSX children onto the children prop in an array', () => {
<del> var a = 1;
<del> var b = 2;
<del> var c = 3;
<del> var element = (
<add> const a = 1;
<add> const b = 2;
<add> const c = 3;
<add> const element = (
<ide> <Component>
<ide> {a}
<ide> {b}
<ide> describe('ReactJSXElement', () => {
<ide> }
<ide> }
<ide>
<del> var element = <StaticMethodComponent />;
<add> const element = <StaticMethodComponent />;
<ide> expect(element.type.someStaticMethod()).toBe('someReturnValue');
<ide> });
<ide>
<ide> describe('ReactJSXElement', () => {
<ide> });
<ide>
<ide> it('is indistinguishable from a plain object', () => {
<del> var element = <div className="foo" />;
<del> var object = {};
<add> const element = <div className="foo" />;
<add> const object = {};
<ide> expect(element.constructor).toBe(object.constructor);
<ide> });
<ide>
<ide> it('should use default prop value when removing a prop', () => {
<ide> Component.defaultProps = {fruit: 'persimmon'};
<ide>
<del> var container = document.createElement('div');
<del> var instance = ReactDOM.render(<Component fruit="mango" />, container);
<add> const container = document.createElement('div');
<add> const instance = ReactDOM.render(<Component fruit="mango" />, container);
<ide> expect(instance.props.fruit).toBe('mango');
<ide>
<ide> ReactDOM.render(<Component />, container);
<ide> describe('ReactJSXElement', () => {
<ide> }
<ide> NormalizingComponent.defaultProps = {prop: 'testKey'};
<ide>
<del> var instance = ReactTestUtils.renderIntoDocument(<NormalizingComponent />);
<add> const instance = ReactTestUtils.renderIntoDocument(
<add> <NormalizingComponent />,
<add> );
<ide> expect(instance.props.prop).toBe('testKey');
<ide>
<del> var inst2 = ReactTestUtils.renderIntoDocument(
<add> const inst2 = ReactTestUtils.renderIntoDocument(
<ide> <NormalizingComponent prop={null} />,
<ide> );
<ide> expect(inst2.props.prop).toBe(null);
<ide><path>packages/react/src/__tests__/ReactJSXElementValidator-test.js
<ide>
<ide> // TODO: All these warnings should become static errors using Flow instead
<ide> // of dynamic errors when using JSX with Flow.
<del>var React;
<del>var ReactDOM;
<del>var ReactTestUtils;
<del>var PropTypes;
<add>let React;
<add>let ReactDOM;
<add>let ReactTestUtils;
<add>let PropTypes;
<ide>
<ide> describe('ReactJSXElementValidator', () => {
<ide> function normalizeCodeLocInfo(str) {
<ide> return str && str.replace(/at .+?:\d+/g, 'at **');
<ide> }
<ide>
<del> var Component;
<del> var RequiredPropComponent;
<add> let Component;
<add> let RequiredPropComponent;
<ide>
<ide> beforeEach(() => {
<ide> jest.resetModules();
<ide> describe('ReactJSXElementValidator', () => {
<ide> it('warns for keys for iterables of elements in rest args', () => {
<ide> spyOnDev(console, 'error');
<ide>
<del> var iterable = {
<add> const iterable = {
<ide> '@@iterator': function() {
<del> var i = 0;
<add> let i = 0;
<ide> return {
<ide> next: function() {
<del> var done = ++i > 2;
<add> const done = ++i > 2;
<ide> return {value: done ? undefined : <Component />, done: done};
<ide> },
<ide> };
<ide> describe('ReactJSXElementValidator', () => {
<ide> });
<ide>
<ide> it('does not warn for iterable elements with keys', () => {
<del> var iterable = {
<add> const iterable = {
<ide> '@@iterator': function() {
<del> var i = 0;
<add> let i = 0;
<ide> return {
<ide> next: function() {
<del> var done = ++i > 2;
<add> const done = ++i > 2;
<ide> return {
<ide> value: done ? undefined : <Component key={'#' + i} />,
<ide> done: done,
<ide> describe('ReactJSXElementValidator', () => {
<ide> });
<ide>
<ide> it('does not warn for numeric keys in entry iterable as a child', () => {
<del> var iterable = {
<add> const iterable = {
<ide> '@@iterator': function() {
<del> var i = 0;
<add> let i = 0;
<ide> return {
<ide> next: function() {
<del> var done = ++i > 2;
<add> const done = ++i > 2;
<ide> return {value: done ? undefined : [i, <Component />], done: done};
<ide> },
<ide> };
<ide> describe('ReactJSXElementValidator', () => {
<ide> return React.createElement(MiddleComp, {color: 'blue'});
<ide> }
<ide>
<del> var container = document.createElement('div');
<add> const container = document.createElement('div');
<ide> ReactDOM.render(<ParentComp warn={false} />, container);
<ide> ReactDOM.render(<ParentComp warn={true} />, container);
<ide>
<ide> describe('ReactJSXElementValidator', () => {
<ide> });
<ide>
<ide> it('gives a helpful error when passing null, undefined, or boolean', () => {
<del> var Undefined = undefined;
<del> var Null = null;
<del> var True = true;
<del> var Div = 'div';
<add> const Undefined = undefined;
<add> const Null = null;
<add> const True = true;
<add> const Div = 'div';
<ide> spyOnDev(console, 'error');
<ide> void <Undefined />;
<ide> void <Null />;
<ide><path>packages/react/src/__tests__/ReactPureComponent-test.js
<ide>
<ide> 'use strict';
<ide>
<del>var React;
<del>var ReactDOM;
<add>let React;
<add>let ReactDOM;
<ide>
<ide> describe('ReactPureComponent', () => {
<ide> beforeEach(() => {
<ide> describe('ReactPureComponent', () => {
<ide> });
<ide>
<ide> it('should render', () => {
<del> var renders = 0;
<add> let renders = 0;
<ide> class Component extends React.PureComponent {
<ide> constructor() {
<ide> super();
<ide> describe('ReactPureComponent', () => {
<ide> }
<ide> }
<ide>
<del> var container = document.createElement('div');
<del> var text;
<del> var component;
<add> const container = document.createElement('div');
<add> let text;
<add> let component;
<ide>
<ide> text = ['porcini'];
<ide> component = ReactDOM.render(<Component text={text} />, container);
<ide> describe('ReactPureComponent', () => {
<ide>
<ide> it('can override shouldComponentUpdate', () => {
<ide> spyOnDev(console, 'error');
<del> var renders = 0;
<add> let renders = 0;
<ide> class Component extends React.PureComponent {
<ide> render() {
<ide> renders++;
<ide> describe('ReactPureComponent', () => {
<ide> return true;
<ide> }
<ide> }
<del> var container = document.createElement('div');
<add> const container = document.createElement('div');
<ide> ReactDOM.render(<Component />, container);
<ide> ReactDOM.render(<Component />, container);
<ide> if (__DEV__) {
<ide> describe('ReactPureComponent', () => {
<ide> });
<ide>
<ide> it('extends React.Component', () => {
<del> var renders = 0;
<add> let renders = 0;
<ide> class Component extends React.PureComponent {
<ide> render() {
<ide> expect(this instanceof React.Component).toBe(true);
<ide> describe('ReactPureComponent', () => {
<ide> return <div />;
<ide> }
<ide> }
<del> var container = document.createElement('div');
<add> const container = document.createElement('div');
<ide> ReactDOM.render(<PureComponent />, container);
<ide>
<ide> if (__DEV__) {
<ide><path>packages/react/src/__tests__/createReactClassIntegration-test.js
<ide>
<ide> 'use strict';
<ide>
<del>var PropTypes;
<del>var React;
<del>var ReactDOM;
<del>var ReactTestUtils;
<del>var createReactClass;
<add>let PropTypes;
<add>let React;
<add>let ReactDOM;
<add>let ReactTestUtils;
<add>let createReactClass;
<ide>
<ide> describe('create-react-class-integration', () => {
<ide> beforeEach(() => {
<ide> describe('create-react-class-integration', () => {
<ide> });
<ide>
<ide> it('should copy prop types onto the Constructor', () => {
<del> var propValidator = jest.fn();
<del> var TestComponent = createReactClass({
<add> const propValidator = jest.fn();
<add> const TestComponent = createReactClass({
<ide> propTypes: {
<ide> value: propValidator,
<ide> },
<ide> describe('create-react-class-integration', () => {
<ide> });
<ide>
<ide> it('should support statics', () => {
<del> var Component = createReactClass({
<add> const Component = createReactClass({
<ide> statics: {
<ide> abc: 'def',
<ide> def: 0,
<ide> describe('create-react-class-integration', () => {
<ide> return <span />;
<ide> },
<ide> });
<del> var instance = <Component />;
<add> let instance = <Component />;
<ide> instance = ReactTestUtils.renderIntoDocument(instance);
<ide> expect(instance.constructor.abc).toBe('def');
<ide> expect(Component.abc).toBe('def');
<ide> describe('create-react-class-integration', () => {
<ide> });
<ide>
<ide> it('should work with object getInitialState() return values', () => {
<del> var Component = createReactClass({
<add> const Component = createReactClass({
<ide> getInitialState: function() {
<ide> return {
<ide> occupation: 'clown',
<ide> describe('create-react-class-integration', () => {
<ide> return <span />;
<ide> },
<ide> });
<del> var instance = <Component />;
<add> let instance = <Component />;
<ide> instance = ReactTestUtils.renderIntoDocument(instance);
<ide> expect(instance.state.occupation).toEqual('clown');
<ide> });
<ide>
<ide> it('renders based on context getInitialState', () => {
<del> var Foo = createReactClass({
<add> const Foo = createReactClass({
<ide> contextTypes: {
<ide> className: PropTypes.string,
<ide> },
<ide> describe('create-react-class-integration', () => {
<ide> },
<ide> });
<ide>
<del> var Outer = createReactClass({
<add> const Outer = createReactClass({
<ide> childContextTypes: {
<ide> className: PropTypes.string,
<ide> },
<ide> describe('create-react-class-integration', () => {
<ide> },
<ide> });
<ide>
<del> var container = document.createElement('div');
<add> const container = document.createElement('div');
<ide> ReactDOM.render(<Outer />, container);
<ide> expect(container.firstChild.className).toBe('foo');
<ide> });
<ide>
<ide> it('should throw with non-object getInitialState() return values', () => {
<ide> [['an array'], 'a string', 1234].forEach(function(state) {
<del> var Component = createReactClass({
<add> const Component = createReactClass({
<ide> getInitialState: function() {
<ide> return state;
<ide> },
<ide> render: function() {
<ide> return <span />;
<ide> },
<ide> });
<del> var instance = <Component />;
<add> let instance = <Component />;
<ide> expect(function() {
<ide> instance = ReactTestUtils.renderIntoDocument(instance);
<ide> }).toThrowError(
<ide> describe('create-react-class-integration', () => {
<ide> });
<ide>
<ide> it('should work with a null getInitialState() return value', () => {
<del> var Component = createReactClass({
<add> const Component = createReactClass({
<ide> getInitialState: function() {
<ide> return null;
<ide> },
<ide> describe('create-react-class-integration', () => {
<ide>
<ide> it('should throw when using legacy factories', () => {
<ide> spyOnDev(console, 'error');
<del> var Component = createReactClass({
<add> const Component = createReactClass({
<ide> render() {
<ide> return <div />;
<ide> },
<ide> describe('create-react-class-integration', () => {
<ide> });
<ide>
<ide> it('replaceState and callback works', () => {
<del> var ops = [];
<del> var Component = createReactClass({
<add> const ops = [];
<add> const Component = createReactClass({
<ide> getInitialState() {
<ide> return {step: 0};
<ide> },
<ide> describe('create-react-class-integration', () => {
<ide> },
<ide> });
<ide>
<del> var instance = ReactTestUtils.renderIntoDocument(<Component />);
<add> const instance = ReactTestUtils.renderIntoDocument(<Component />);
<ide> instance.replaceState({step: 1}, () => {
<ide> ops.push('Callback: ' + instance.state.step);
<ide> });
<ide> describe('create-react-class-integration', () => {
<ide> it('isMounted works', () => {
<ide> spyOnDev(console, 'error');
<ide>
<del> var ops = [];
<del> var instance;
<del> var Component = createReactClass({
<add> const ops = [];
<add> let instance;
<add> const Component = createReactClass({
<ide> displayName: 'MyComponent',
<ide> mixins: [
<ide> {
<ide> describe('create-react-class-integration', () => {
<ide> },
<ide> });
<ide>
<del> var container = document.createElement('div');
<add> const container = document.createElement('div');
<ide> ReactDOM.render(<Component />, container);
<ide> ReactDOM.render(<Component />, container);
<ide> ReactDOM.unmountComponentAtNode(container);
<ide><path>packages/react/src/__tests__/onlyChild-test.js
<ide> 'use strict';
<ide>
<ide> describe('onlyChild', () => {
<del> var React;
<del> var WrapComponent;
<add> let React;
<add> let WrapComponent;
<ide>
<ide> beforeEach(() => {
<ide> React = require('react');
<ide> describe('onlyChild', () => {
<ide>
<ide> it('should fail when passed two children', () => {
<ide> expect(function() {
<del> var instance = (
<add> const instance = (
<ide> <WrapComponent>
<ide> <div />
<ide> <span />
<ide> describe('onlyChild', () => {
<ide>
<ide> it('should fail when passed nully values', () => {
<ide> expect(function() {
<del> var instance = <WrapComponent>{null}</WrapComponent>;
<add> const instance = <WrapComponent>{null}</WrapComponent>;
<ide> React.Children.only(instance.props.children);
<ide> }).toThrow();
<ide>
<ide> expect(function() {
<del> var instance = <WrapComponent>{undefined}</WrapComponent>;
<add> const instance = <WrapComponent>{undefined}</WrapComponent>;
<ide> React.Children.only(instance.props.children);
<ide> }).toThrow();
<ide> });
<ide>
<ide> it('should fail when key/value objects', () => {
<ide> expect(function() {
<del> var instance = <WrapComponent>{[<span key="abc" />]}</WrapComponent>;
<add> const instance = <WrapComponent>{[<span key="abc" />]}</WrapComponent>;
<ide> React.Children.only(instance.props.children);
<ide> }).toThrow();
<ide> });
<ide>
<ide> it('should not fail when passed interpolated single child', () => {
<ide> expect(function() {
<del> var instance = <WrapComponent>{<span />}</WrapComponent>;
<add> const instance = <WrapComponent>{<span />}</WrapComponent>;
<ide> React.Children.only(instance.props.children);
<ide> }).not.toThrow();
<ide> });
<ide>
<ide> it('should return the only child', () => {
<del> var instance = (
<add> const instance = (
<ide> <WrapComponent>
<ide> <span />
<ide> </WrapComponent> | 21 |
Ruby | Ruby | remove formula reference | a00995fa090f905a5fbba97a8c9270246e788a39 | <ide><path>Library/Homebrew/requirements/osxfuse_requirement.rb
<ide>
<ide> class OsxfuseRequirement < Requirement
<ide> fatal true
<del> default_formula "osxfuse"
<ide> cask "osxfuse"
<ide> download "https://osxfuse.github.io/"
<ide>
<del> satisfy(:build_env => false) { Formula["osxfuse"].installed? || self.class.binary_osxfuse_installed? }
<add> satisfy(:build_env => false) { self.class.binary_osxfuse_installed? }
<ide>
<ide> def self.binary_osxfuse_installed?
<ide> File.exist?("/usr/local/include/osxfuse/fuse.h") && | 1 |
Python | Python | add documentation to several activation functions | 7ff9303041729bb69bd416e2ccb6e7a87ee7cc2a | <ide><path>keras/activations.py
<ide> def softmax(x, axis=-1):
<ide> """Softmax activation function.
<ide>
<ide> # Arguments
<del> x : Tensor.
<add> x: Input tensor.
<ide> axis: Integer, axis along which the softmax normalization is applied.
<ide>
<ide> # Returns
<ide> def softmax(x, axis=-1):
<ide>
<ide>
<ide> def elu(x, alpha=1.0):
<add> """Exponential linear unit.
<add>
<add> # Arguments
<add> x: Input tensor.
<add> alpha: A scalar, slope of negative section.
<add>
<add> # Returns
<add> The exponential linear activation: `x` if `x > 0` and
<add> `alpha * (exp(x)-1)` if `x < 0`.
<add>
<add> # References
<add> - [Fast and Accurate Deep Network Learning by Exponential
<add> Linear Units (ELUs)](https://arxiv.org/abs/1511.07289)
<add> """
<ide> return K.elu(x, alpha)
<ide>
<ide>
<ide> def selu(x):
<del> """Scaled Exponential Linear Unit. (Klambauer et al., 2017).
<add> """Scaled Exponential Linear Unit (SELU).
<add>
<add> SELU is equal to: `scale * elu(x, alpha)`, where alpha and scale
<add> are pre-defined constants. The values of `alpha` and `scale` are
<add> chosen so that the mean and variance of the inputs are preserved
<add> between two consecutive layers as long as the weights are initialized
<add> correctly (see `lecun_normal` initialization) and the number of inputs
<add> is "large enough" (see references for more information).
<ide>
<ide> # Arguments
<ide> x: A tensor or variable to compute the activation function for.
<ide>
<ide> # Returns
<del> Tensor with the same shape and dtype as `x`.
<add> The scaled exponential unit activation: `scale * elu(x, alpha)`.
<ide>
<ide> # Note
<ide> - To be used together with the initialization "lecun_normal".
<ide> def selu(x):
<ide>
<ide>
<ide> def softplus(x):
<add> """Softplus activation function.
<add>
<add> # Arguments
<add> x: Input tensor.
<add>
<add> # Returns
<add> The softplus activation: `log(exp(x) + 1`.
<add> """
<ide> return K.softplus(x)
<ide>
<ide>
<ide> def softsign(x):
<add> """Softsign activation function.
<add>
<add> # Arguments
<add> x: Input tensor.
<add>
<add> # Returns
<add> The softplus activation: `x / (abs(x) + 1)`.
<add> """
<ide> return K.softsign(x)
<ide>
<ide>
<ide> def relu(x, alpha=0., max_value=None):
<add> """(Leaky) Rectified Linear Unit.
<add>
<add> # Arguments
<add> x: Input tensor.
<add> alpha: Slope of the negative part. Defaults to zero.
<add> max_value: Maximum value for the output.
<add>
<add> # Returns
<add> The (leaky) rectified linear unit activation: `x` if `x > 0`,
<add> `alpha * x` if `x < 0`. If `max_value` is defined, the result
<add> is truncated to this value.
<add> """
<ide> return K.relu(x, alpha=alpha, max_value=max_value)
<ide>
<ide>
<ide> def tanh(x):
<add> """Hyperbolic tangent activation function.
<add> """
<ide> return K.tanh(x)
<ide>
<ide>
<ide> def sigmoid(x):
<add> """Sigmoid activation function.
<add> """
<ide> return K.sigmoid(x)
<ide>
<ide>
<ide> def hard_sigmoid(x):
<add> """Hard sigmoid activation function.
<add>
<add> Faster to compute than sigmoid activation.
<add>
<add> # Arguments
<add> x: Input tensor.
<add>
<add> # Returns
<add> Hard sigmoid activation:
<add>
<add> - `0` if `x < -2.5`
<add> - `1` if `x > 2.5`
<add> - `0.2 * x + 0.5` if `-2.5 <= x <= 2.5`.
<add> """
<ide> return K.hard_sigmoid(x)
<ide>
<ide>
<ide> def linear(x):
<add> """Linear (e.g. unit) activation function.
<add> """
<ide> return x
<ide>
<ide> | 1 |
Python | Python | add freeze_backbone flag for image_classification | 20685639e9d6577fa592fc0b2102a1bded53e3bb | <ide><path>official/projects/vit/configs/image_classification.py
<ide> class ImageClassificationTask(cfg.TaskConfig):
<ide> evaluation: Evaluation = Evaluation()
<ide> init_checkpoint: Optional[str] = None
<ide> init_checkpoint_modules: str = 'all' # all or backbone
<add> freeze_backbone: bool = False
<ide>
<ide>
<ide> IMAGENET_TRAIN_EXAMPLES = 1281167
<ide><path>official/vision/configs/image_classification.py
<ide> class ImageClassificationTask(cfg.TaskConfig):
<ide> init_checkpoint_modules: str = 'all' # all or backbone
<ide> model_output_keys: Optional[List[int]] = dataclasses.field(
<ide> default_factory=list)
<add> freeze_backbone: bool = False
<ide>
<ide>
<ide> @exp_factory.register_config_factory('image_classification')
<ide><path>official/vision/tasks/image_classification.py
<ide> def build_model(self):
<ide> input_specs=input_specs,
<ide> model_config=self.task_config.model,
<ide> l2_regularizer=l2_regularizer)
<add>
<add> if self.task_config.freeze_backbone:
<add> model.backbone.trainable = False
<ide> return model
<ide>
<ide> def initialize(self, model: tf.keras.Model): | 3 |
Go | Go | add integration test for --workdir=/ | baacc7006b35badb2e9ba807451ab158936d7832 | <ide><path>integration-cli/docker_cli_run_test.go
<ide> func TestModeHostname(t *testing.T) {
<ide> deleteAllContainers()
<ide>
<ide> logDone("run - hostname and several network modes")
<del>}
<ide>\ No newline at end of file
<add>}
<add>
<add>func TestRootWorkdir(t *testing.T) {
<add> s, _, err := cmd(t, "run", "--workdir", "/", "busybox", "pwd")
<add> if err != nil {
<add> t.Fatal(s, err)
<add> }
<add> if s != "/\n" {
<add> t.Fatalf("pwd returned '%s' (expected /\\n)", s)
<add> }
<add>
<add> deleteAllContainers()
<add>
<add> logDone("run - workdir /")
<add>}
<ide><path>pkg/symlink/fs.go
<ide> func FollowSymlinkInScope(link, root string) (string, error) {
<ide> return root, nil
<ide> }
<ide>
<del>
<ide> if !strings.HasPrefix(filepath.Dir(link), root) {
<ide> return "", fmt.Errorf("%s is not within %s", link, root)
<ide> }
<ide>
<ide> prev := "/"
<del>
<add>
<ide> for _, p := range strings.Split(link, "/") {
<ide> prev = filepath.Join(prev, p)
<ide> prev = filepath.Clean(prev) | 2 |
Ruby | Ruby | fix missed establish_connection | 919eb6dca980ee7390d70f991d34d1e1c6b00f25 | <ide><path>activerecord/lib/active_record/connection_handling.rb
<ide> module ConnectionHandling
<ide> def establish_connection(config_or_env = nil)
<ide> config_or_env ||= DEFAULT_ENV.call.to_sym
<ide> db_config, owner_name = resolve_config_for_connection(config_or_env)
<del> connection_handler.establish_connection(db_config, owner_name: owner_name, shard: current_shard)
<add> connection_handler.establish_connection(db_config, owner_name: owner_name)
<ide> end
<ide>
<ide> # Connects a model to the databases specified. The +database+ keyword
<ide> def connects_to(database: {}, shards: {})
<ide> db_config, owner_name = resolve_config_for_connection(database_key)
<ide> handler = lookup_connection_handler(role.to_sym)
<ide>
<del> connections << handler.establish_connection(db_config, owner_name: owner_name, shard: default_shard)
<add> connections << handler.establish_connection(db_config, owner_name: owner_name)
<ide> end
<ide>
<ide> shards.each do |shard, database_keys|
<ide> def connected_to(database: nil, role: nil, shard: nil, prevent_writes: false, &b
<ide> db_config, owner_name = resolve_config_for_connection(database)
<ide> handler = lookup_connection_handler(role)
<ide>
<del> handler.establish_connection(db_config, default_shard, owner_name)
<add> handler.establish_connection(db_config, owner_name: owner_name)
<ide>
<ide> with_handler(role, &blk)
<ide> elsif shard
<ide><path>activerecord/test/cases/connection_adapters/connection_handlers_multi_db_test.rb
<ide> def test_switching_connections_with_database_and_role_raises
<ide> assert_equal "`connected_to` cannot accept a `database` argument with any other arguments.", error.message
<ide> end
<ide>
<add> def test_database_argument_is_deprecated
<add> assert_deprecated do
<add> ActiveRecord::Base.connected_to(database: { writing: { adapter: "sqlite3", database: "test/db/primary.sqlite3" } }) { }
<add> end
<add> ensure
<add> ActiveRecord::Base.establish_connection(:arunit)
<add> end
<add>
<ide> def test_switching_connections_without_database_and_role_raises
<ide> error = assert_raises(ArgumentError) do
<ide> ActiveRecord::Base.connected_to { } | 2 |
Javascript | Javascript | improve argument handling, start passive | 4629e96c209bbc6e81a4ff178dcb8afa27feb042 | <ide><path>lib/internal/event_target.js
<ide> class EventTarget {
<ide> [kRemoveListener](size, type, listener, capture) {}
<ide>
<ide> addEventListener(type, listener, options = {}) {
<del> validateListener(listener);
<del> type = String(type);
<add> if (arguments.length < 2)
<add> throw new ERR_MISSING_ARGS('type', 'listener');
<ide>
<add> // We validateOptions before the shouldAddListeners check because the spec
<add> // requires us to hit getters.
<ide> const {
<ide> once,
<ide> capture,
<ide> passive
<ide> } = validateEventListenerOptions(options);
<ide>
<add> if (!shouldAddListener(listener)) {
<add> // The DOM silently allows passing undefined as a second argument
<add> // No error code for this since it is a Warning
<add> // eslint-disable-next-line no-restricted-syntax
<add> const w = new Error(`addEventListener called with ${listener}` +
<add> ' which has no effect.');
<add> w.name = 'AddEventListenerArgumentTypeWarning';
<add> w.target = this;
<add> w.type = type;
<add> process.emitWarning(w);
<add> return;
<add> }
<add> type = String(type);
<add>
<ide> let root = this[kEvents].get(type);
<ide>
<ide> if (root === undefined) {
<ide> class EventTarget {
<ide> }
<ide>
<ide> removeEventListener(type, listener, options = {}) {
<del> validateListener(listener);
<add> if (!shouldAddListener(listener))
<add> return;
<add>
<ide> type = String(type);
<del> const { capture } = validateEventListenerOptions(options);
<add> // TODO(@jasnell): If it's determined this cannot be backported
<add> // to 12.x, then this can be simplified to:
<add> // const capture = Boolean(options?.capture);
<add> const capture = options != null && options.capture === true;
<add>
<ide> const root = this[kEvents].get(type);
<ide> if (root === undefined || root.next === undefined)
<ide> return;
<ide> Object.defineProperties(NodeEventTarget.prototype, {
<ide>
<ide> // EventTarget API
<ide>
<del>function validateListener(listener) {
<add>function shouldAddListener(listener) {
<ide> if (typeof listener === 'function' ||
<ide> (listener != null &&
<ide> typeof listener === 'object' &&
<ide> typeof listener.handleEvent === 'function')) {
<del> return;
<add> return true;
<ide> }
<add>
<add> if (listener == null)
<add> return false;
<add>
<ide> throw new ERR_INVALID_ARG_TYPE('listener', 'EventListener', listener);
<ide> }
<ide>
<ide><path>test/parallel/test-eventtarget-whatwg-passive.js
<add>// Flags: --expose-internals
<add>'use strict';
<add>
<add>const common = require('../common');
<add>
<add>const {
<add> Event,
<add> EventTarget,
<add>} = require('internal/event_target');
<add>
<add>const {
<add> fail,
<add> ok,
<add> strictEqual
<add>} = require('assert');
<add>
<add>// Manually ported from WPT AddEventListenerOptions-passive.html
<add>{
<add> const document = new EventTarget();
<add> let supportsPassive = false;
<add> const query_options = {
<add> get passive() {
<add> supportsPassive = true;
<add> return false;
<add> },
<add> get dummy() {
<add> fail('dummy value getter invoked');
<add> return false;
<add> }
<add> };
<add>
<add> document.addEventListener('test_event', null, query_options);
<add> ok(supportsPassive);
<add>
<add> supportsPassive = false;
<add> document.removeEventListener('test_event', null, query_options);
<add> strictEqual(supportsPassive, false);
<add>}
<add>{
<add> function testPassiveValue(optionsValue, expectedDefaultPrevented) {
<add> const document = new EventTarget();
<add> let defaultPrevented;
<add> function handler(e) {
<add> if (e.defaultPrevented) {
<add> fail('Event prematurely marked defaultPrevented');
<add> }
<add> e.preventDefault();
<add> defaultPrevented = e.defaultPrevented;
<add> }
<add> document.addEventListener('test', handler, optionsValue);
<add> // TODO the WHATWG test is more extensive here and tests dispatching on
<add> // document.body, if we ever support getParent we should amend this
<add> const ev = new Event('test', { bubbles: true, cancelable: true });
<add> const uncanceled = document.dispatchEvent(ev);
<add>
<add> strictEqual(defaultPrevented, expectedDefaultPrevented);
<add> strictEqual(uncanceled, !expectedDefaultPrevented);
<add>
<add> document.removeEventListener('test', handler, optionsValue);
<add> }
<add> testPassiveValue(undefined, true);
<add> testPassiveValue({}, true);
<add> testPassiveValue({ passive: false }, true);
<add>
<add> common.skip('TODO: passive listeners is still broken');
<add> testPassiveValue({ passive: 1 }, false);
<add> testPassiveValue({ passive: true }, false);
<add> testPassiveValue({ passive: 0 }, true);
<add>}
<ide><path>test/parallel/test-eventtarget.js
<ide> const common = require('../common');
<ide> const {
<ide> Event,
<ide> EventTarget,
<del> NodeEventTarget,
<ide> defineEventHandler
<ide> } = require('internal/event_target');
<ide>
<ide> const {
<ide> throws,
<ide> } = require('assert');
<ide>
<del>const { once, on } = require('events');
<add>const { once } = require('events');
<add>
<add>const { promisify } = require('util');
<add>const delay = promisify(setTimeout);
<ide>
<ide> // The globals are defined.
<ide> ok(Event);
<ide> ok(EventTarget);
<ide>
<add>// The warning event has special behavior regarding attaching listeners
<add>let lastWarning;
<add>process.on('warning', (e) => {
<add> lastWarning = e;
<add>});
<add>
<add>// Utility promise for parts of the test that need to wait for eachother -
<add>// Namely tests for warning events
<add>/* eslint-disable no-unused-vars */
<add>let asyncTest = Promise.resolve();
<add>
<ide> // First, test Event
<ide> {
<ide> const ev = new Event('foo');
<ide> ok(EventTarget);
<ide> eventTarget.addEventListener('foo', fn, { once: true });
<ide> eventTarget.dispatchEvent(ev);
<ide> }
<del>{
<del> const eventTarget = new NodeEventTarget();
<del> strictEqual(eventTarget.listenerCount('foo'), 0);
<del> deepStrictEqual(eventTarget.eventNames(), []);
<del>
<del> const ev1 = common.mustCall(function(event) {
<del> strictEqual(event.type, 'foo');
<del> strictEqual(this, eventTarget);
<del> }, 2);
<del>
<del> const ev2 = {
<del> handleEvent: common.mustCall(function(event) {
<del> strictEqual(event.type, 'foo');
<del> strictEqual(this, ev2);
<del> })
<del> };
<del>
<del> eventTarget.addEventListener('foo', ev1);
<del> eventTarget.addEventListener('foo', ev2, { once: true });
<del> strictEqual(eventTarget.listenerCount('foo'), 2);
<del> ok(eventTarget.dispatchEvent(new Event('foo')));
<del> strictEqual(eventTarget.listenerCount('foo'), 1);
<del> eventTarget.dispatchEvent(new Event('foo'));
<del>
<del> eventTarget.removeEventListener('foo', ev1);
<del> strictEqual(eventTarget.listenerCount('foo'), 0);
<del> eventTarget.dispatchEvent(new Event('foo'));
<del>}
<del>
<ide>
<ide> {
<ide> const eventTarget = new EventTarget();
<ide> ok(EventTarget);
<ide> eventTarget.addEventListener('foo', fn, false);
<ide> eventTarget.dispatchEvent(event);
<ide> }
<del>{
<del> const eventTarget = new NodeEventTarget();
<del> strictEqual(eventTarget.listenerCount('foo'), 0);
<del> deepStrictEqual(eventTarget.eventNames(), []);
<del>
<del> const ev1 = common.mustCall((event) => {
<del> strictEqual(event.type, 'foo');
<del> }, 2);
<del>
<del> const ev2 = {
<del> handleEvent: common.mustCall((event) => {
<del> strictEqual(event.type, 'foo');
<del> })
<del> };
<del>
<del> strictEqual(eventTarget.on('foo', ev1), eventTarget);
<del> strictEqual(eventTarget.once('foo', ev2, { once: true }), eventTarget);
<del> strictEqual(eventTarget.listenerCount('foo'), 2);
<del> eventTarget.dispatchEvent(new Event('foo'));
<del> strictEqual(eventTarget.listenerCount('foo'), 1);
<del> eventTarget.dispatchEvent(new Event('foo'));
<del>
<del> strictEqual(eventTarget.off('foo', ev1), eventTarget);
<del> strictEqual(eventTarget.listenerCount('foo'), 0);
<del> eventTarget.dispatchEvent(new Event('foo'));
<del>}
<del>
<del>{
<del> const eventTarget = new NodeEventTarget();
<del> strictEqual(eventTarget.listenerCount('foo'), 0);
<del> deepStrictEqual(eventTarget.eventNames(), []);
<del>
<del> const ev1 = common.mustCall((event) => {
<del> strictEqual(event.type, 'foo');
<del> }, 2);
<del>
<del> const ev2 = {
<del> handleEvent: common.mustCall((event) => {
<del> strictEqual(event.type, 'foo');
<del> })
<del> };
<del>
<del> eventTarget.addListener('foo', ev1);
<del> eventTarget.once('foo', ev2, { once: true });
<del> strictEqual(eventTarget.listenerCount('foo'), 2);
<del> eventTarget.dispatchEvent(new Event('foo'));
<del> strictEqual(eventTarget.listenerCount('foo'), 1);
<del> eventTarget.dispatchEvent(new Event('foo'));
<del>
<del> eventTarget.removeListener('foo', ev1);
<del> strictEqual(eventTarget.listenerCount('foo'), 0);
<del> eventTarget.dispatchEvent(new Event('foo'));
<del>}
<del>
<del>{
<del> const eventTarget = new NodeEventTarget();
<del> strictEqual(eventTarget.listenerCount('foo'), 0);
<del> deepStrictEqual(eventTarget.eventNames(), []);
<del>
<del> // Won't actually be called.
<del> const ev1 = () => {};
<del>
<del> // Won't actually be called.
<del> const ev2 = { handleEvent() {} };
<del>
<del> eventTarget.addListener('foo', ev1);
<del> eventTarget.addEventListener('foo', ev1);
<del> eventTarget.once('foo', ev2, { once: true });
<del> eventTarget.once('foo', ev2, { once: false });
<del> eventTarget.on('bar', ev1);
<del> strictEqual(eventTarget.listenerCount('foo'), 2);
<del> strictEqual(eventTarget.listenerCount('bar'), 1);
<del> deepStrictEqual(eventTarget.eventNames(), ['foo', 'bar']);
<del> eventTarget.removeAllListeners('foo');
<del> strictEqual(eventTarget.listenerCount('foo'), 0);
<del> strictEqual(eventTarget.listenerCount('bar'), 1);
<del> deepStrictEqual(eventTarget.eventNames(), ['bar']);
<del> eventTarget.removeAllListeners();
<del> strictEqual(eventTarget.listenerCount('foo'), 0);
<del> strictEqual(eventTarget.listenerCount('bar'), 0);
<del> deepStrictEqual(eventTarget.eventNames(), []);
<del>}
<ide>
<ide> {
<ide> const uncaughtException = common.mustCall((err, event) => {
<ide> ok(EventTarget);
<ide> 1,
<ide> {}, // No handleEvent function
<ide> false,
<del> undefined
<ide> ].forEach((i) => {
<ide> throws(() => target.addEventListener('foo', i), {
<ide> code: 'ERR_INVALID_ARG_TYPE'
<ide> ok(EventTarget);
<ide> 'foo',
<ide> 1,
<ide> {}, // No handleEvent function
<del> false,
<del> undefined
<add> false
<ide> ].forEach((i) => {
<ide> throws(() => target.removeEventListener('foo', i), {
<ide> code: 'ERR_INVALID_ARG_TYPE'
<ide> ok(EventTarget);
<ide> target.dispatchEvent(new Event('foo'));
<ide> }
<ide>
<del>{
<del> const target = new NodeEventTarget();
<del>
<del> process.on('warning', common.mustCall((warning) => {
<del> ok(warning instanceof Error);
<del> strictEqual(warning.name, 'MaxListenersExceededWarning');
<del> strictEqual(warning.target, target);
<del> strictEqual(warning.count, 2);
<del> strictEqual(warning.type, 'foo');
<del> ok(warning.message.includes(
<del> '2 foo listeners added to NodeEventTarget'));
<del> }));
<del>
<del> strictEqual(target.getMaxListeners(), NodeEventTarget.defaultMaxListeners);
<del> target.setMaxListeners(1);
<del> target.on('foo', () => {});
<del> target.on('foo', () => {});
<del>}
<del>
<ide> {
<ide> const target = new EventTarget();
<ide> const event = new Event('foo');
<ide> ok(EventTarget);
<ide> target.dispatchEvent(ev);
<ide> }
<ide>
<del>(async () => {
<del> // test NodeEventTarget async-iterability
<del> const emitter = new NodeEventTarget();
<del> const interval = setInterval(() => {
<del> emitter.dispatchEvent(new Event('foo'));
<del> }, 0);
<del> let count = 0;
<del> for await (const [ item ] of on(emitter, 'foo')) {
<del> count++;
<del> strictEqual(item.type, 'foo');
<del> if (count > 5) {
<del> break;
<del> }
<del> }
<del> clearInterval(interval);
<del>})().then(common.mustCall());
<add>{
<add> const eventTarget = new EventTarget();
<add> // Single argument throws
<add> throws(() => eventTarget.addEventListener('foo'), TypeError);
<add> // Null events - does not throw
<add> eventTarget.addEventListener('foo', null);
<add> eventTarget.removeEventListener('foo', null);
<add> eventTarget.addEventListener('foo', undefined);
<add> eventTarget.removeEventListener('foo', undefined);
<add> // Strings, booleans
<add> throws(() => eventTarget.addEventListener('foo', 'hello'), TypeError);
<add> throws(() => eventTarget.addEventListener('foo', false), TypeError);
<add> throws(() => eventTarget.addEventListener('foo', Symbol()), TypeError);
<add> asyncTest = asyncTest.then(async () => {
<add> const eventTarget = new EventTarget();
<add> // Single argument throws
<add> throws(() => eventTarget.addEventListener('foo'), TypeError);
<add> // Null events - does not throw
<add>
<add> eventTarget.addEventListener('foo', null);
<add> eventTarget.removeEventListener('foo', null);
<add>
<add> // Warnings always happen after nextTick, so wait for a timer of 0
<add> await delay(0);
<add> strictEqual(lastWarning.name, 'AddEventListenerArgumentTypeWarning');
<add> strictEqual(lastWarning.target, eventTarget);
<add> lastWarning = null;
<add> eventTarget.addEventListener('foo', undefined);
<add> await delay(0);
<add> strictEqual(lastWarning.name, 'AddEventListenerArgumentTypeWarning');
<add> strictEqual(lastWarning.target, eventTarget);
<add> eventTarget.removeEventListener('foo', undefined);
<add> // Strings, booleans
<add> throws(() => eventTarget.addEventListener('foo', 'hello'), TypeError);
<add> throws(() => eventTarget.addEventListener('foo', false), TypeError);
<add> throws(() => eventTarget.addEventListener('foo', Symbol()), TypeError);
<add> });
<add>}
<ide><path>test/parallel/test-nodeeventtarget.js
<add>// Flags: --expose-internals --no-warnings
<add>'use strict';
<add>
<add>const common = require('../common');
<add>const {
<add> Event,
<add> NodeEventTarget,
<add>} = require('internal/event_target');
<add>
<add>const {
<add> deepStrictEqual,
<add> ok,
<add> strictEqual,
<add>} = require('assert');
<add>
<add>const { on } = require('events');
<add>
<add>{
<add> const eventTarget = new NodeEventTarget();
<add> strictEqual(eventTarget.listenerCount('foo'), 0);
<add> deepStrictEqual(eventTarget.eventNames(), []);
<add>
<add> const ev1 = common.mustCall(function(event) {
<add> strictEqual(event.type, 'foo');
<add> strictEqual(this, eventTarget);
<add> }, 2);
<add>
<add> const ev2 = {
<add> handleEvent: common.mustCall(function(event) {
<add> strictEqual(event.type, 'foo');
<add> strictEqual(this, ev2);
<add> })
<add> };
<add>
<add> eventTarget.addEventListener('foo', ev1);
<add> eventTarget.addEventListener('foo', ev2, { once: true });
<add> strictEqual(eventTarget.listenerCount('foo'), 2);
<add> ok(eventTarget.dispatchEvent(new Event('foo')));
<add> strictEqual(eventTarget.listenerCount('foo'), 1);
<add> eventTarget.dispatchEvent(new Event('foo'));
<add>
<add> eventTarget.removeEventListener('foo', ev1);
<add> strictEqual(eventTarget.listenerCount('foo'), 0);
<add> eventTarget.dispatchEvent(new Event('foo'));
<add>}
<add>
<add>{
<add> const eventTarget = new NodeEventTarget();
<add> strictEqual(eventTarget.listenerCount('foo'), 0);
<add> deepStrictEqual(eventTarget.eventNames(), []);
<add>
<add> const ev1 = common.mustCall((event) => {
<add> strictEqual(event.type, 'foo');
<add> }, 2);
<add>
<add> const ev2 = {
<add> handleEvent: common.mustCall((event) => {
<add> strictEqual(event.type, 'foo');
<add> })
<add> };
<add>
<add> strictEqual(eventTarget.on('foo', ev1), eventTarget);
<add> strictEqual(eventTarget.once('foo', ev2, { once: true }), eventTarget);
<add> strictEqual(eventTarget.listenerCount('foo'), 2);
<add> eventTarget.dispatchEvent(new Event('foo'));
<add> strictEqual(eventTarget.listenerCount('foo'), 1);
<add> eventTarget.dispatchEvent(new Event('foo'));
<add>
<add> strictEqual(eventTarget.off('foo', ev1), eventTarget);
<add> strictEqual(eventTarget.listenerCount('foo'), 0);
<add> eventTarget.dispatchEvent(new Event('foo'));
<add>}
<add>
<add>{
<add> const eventTarget = new NodeEventTarget();
<add> strictEqual(eventTarget.listenerCount('foo'), 0);
<add> deepStrictEqual(eventTarget.eventNames(), []);
<add>
<add> const ev1 = common.mustCall((event) => {
<add> strictEqual(event.type, 'foo');
<add> }, 2);
<add>
<add> const ev2 = {
<add> handleEvent: common.mustCall((event) => {
<add> strictEqual(event.type, 'foo');
<add> })
<add> };
<add>
<add> eventTarget.addListener('foo', ev1);
<add> eventTarget.once('foo', ev2, { once: true });
<add> strictEqual(eventTarget.listenerCount('foo'), 2);
<add> eventTarget.dispatchEvent(new Event('foo'));
<add> strictEqual(eventTarget.listenerCount('foo'), 1);
<add> eventTarget.dispatchEvent(new Event('foo'));
<add>
<add> eventTarget.removeListener('foo', ev1);
<add> strictEqual(eventTarget.listenerCount('foo'), 0);
<add> eventTarget.dispatchEvent(new Event('foo'));
<add>}
<add>
<add>{
<add> const eventTarget = new NodeEventTarget();
<add> strictEqual(eventTarget.listenerCount('foo'), 0);
<add> deepStrictEqual(eventTarget.eventNames(), []);
<add>
<add> // Won't actually be called.
<add> const ev1 = () => {};
<add>
<add> // Won't actually be called.
<add> const ev2 = { handleEvent() {} };
<add>
<add> eventTarget.addListener('foo', ev1);
<add> eventTarget.addEventListener('foo', ev1);
<add> eventTarget.once('foo', ev2, { once: true });
<add> eventTarget.once('foo', ev2, { once: false });
<add> eventTarget.on('bar', ev1);
<add> strictEqual(eventTarget.listenerCount('foo'), 2);
<add> strictEqual(eventTarget.listenerCount('bar'), 1);
<add> deepStrictEqual(eventTarget.eventNames(), ['foo', 'bar']);
<add> eventTarget.removeAllListeners('foo');
<add> strictEqual(eventTarget.listenerCount('foo'), 0);
<add> strictEqual(eventTarget.listenerCount('bar'), 1);
<add> deepStrictEqual(eventTarget.eventNames(), ['bar']);
<add> eventTarget.removeAllListeners();
<add> strictEqual(eventTarget.listenerCount('foo'), 0);
<add> strictEqual(eventTarget.listenerCount('bar'), 0);
<add> deepStrictEqual(eventTarget.eventNames(), []);
<add>}
<add>
<add>{
<add> const target = new NodeEventTarget();
<add>
<add> process.on('warning', common.mustCall((warning) => {
<add> ok(warning instanceof Error);
<add> strictEqual(warning.name, 'MaxListenersExceededWarning');
<add> strictEqual(warning.target, target);
<add> strictEqual(warning.count, 2);
<add> strictEqual(warning.type, 'foo');
<add> ok(warning.message.includes(
<add> '2 foo listeners added to NodeEventTarget'));
<add> }));
<add>
<add> strictEqual(target.getMaxListeners(), NodeEventTarget.defaultMaxListeners);
<add> target.setMaxListeners(1);
<add> target.on('foo', () => {});
<add> target.on('foo', () => {});
<add>}
<add>
<add>(async () => {
<add> // test NodeEventTarget async-iterability
<add> const emitter = new NodeEventTarget();
<add> const interval = setInterval(() => {
<add> emitter.dispatchEvent(new Event('foo'));
<add> }, 0);
<add> let count = 0;
<add> for await (const [ item ] of on(emitter, 'foo')) {
<add> count++;
<add> strictEqual(item.type, 'foo');
<add> if (count > 5) {
<add> break;
<add> }
<add> }
<add> clearInterval(interval);
<add>})().then(common.mustCall()); | 4 |
Python | Python | use n.ndarray instead of core.multiarray.ndarray | d71637bb914a9b1140c8173024533cf3504ecad8 | <ide><path>numpy/matrixlib/defmatrix.py
<ide> __all__ = ['matrix', 'bmat', 'mat', 'asmatrix']
<ide>
<ide> import sys
<del>from numpy import core
<ide> import numpy.core.numeric as N
<ide> from numpy.core.numeric import concatenate, isscalar, binary_repr, identity, asanyarray
<ide> from numpy.core.numerictypes import issubdtype
<ide> def ravel(self, order='C'):
<ide> numpy.ravel : related function which returns an ndarray
<ide>
<ide> """
<del> return core.multiarray.ndarray.ravel(self, order=order)
<add> return N.ndarray.ravel(self, order=order)
<ide>
<ide>
<ide> def getT(self): | 1 |
PHP | PHP | fix regenerate of original html string | 7994e40688a233d3c6f37f5518b06ca15d3df444 | <ide><path>tests/TestCase/Utility/XmlTest.php
<ide> public function testLoadHtml()
<ide> $this->assertEquals($paragraph, (string)$xml->body->p);
<ide> $this->assertTrue(isset($xml->body->blockquote), 'Blockquote present');
<ide> $this->assertEquals($blockquote, (string)$xml->body->blockquote);
<del> $this->assertEquals($html, "<!DOCTYPE html>\n" . $xml->asXML());
<add> $this->assertEquals($html, '<!DOCTYPE html>' . "\n" . $xml->asXML());
<ide>
<ide> $xml = Xml::loadHtml($html, ['parseHuge' => true]);
<ide> $this->assertTrue(isset($xml->body->p), 'Paragraph present');
<ide> $this->assertEquals($paragraph, (string)$xml->body->p);
<ide> $this->assertTrue(isset($xml->body->blockquote), 'Blockquote present');
<ide> $this->assertEquals($blockquote, (string)$xml->body->blockquote);
<del> $this->assertEquals($html, "<!DOCTYPE html>\n" . $xml->asXML());
<add> $this->assertEquals($html, '<!DOCTYPE html>' . "\n" . $xml->asXML());
<ide> }
<ide>
<ide> /** | 1 |
Ruby | Ruby | add `to_kegs` test | 08bbb95cfba4ba755fc45e427b33802fab9e9cc1 | <ide><path>Library/Homebrew/test/cli/named_args_spec.rb
<ide> def setup_unredable_cask(name)
<ide> end
<ide> end
<ide>
<add> describe "#to_kegs" do
<add> before do
<add> (HOMEBREW_CELLAR/"foo/1.0").mkpath
<add> (HOMEBREW_CELLAR/"foo/2.0").mkpath
<add> (HOMEBREW_CELLAR/"bar/1.0").mkpath
<add> end
<add>
<add> it "resolves kegs with #resolve_kegs" do
<add> expect(described_class.new("foo", "bar").to_kegs.map(&:name)).to eq ["foo", "foo", "bar"]
<add> end
<add>
<add> it "resolves kegs with multiple versions with #resolve_keg" do
<add> expect(described_class.new("foo").to_kegs.map(&->(k) { k.version.version })).to eq ["1.0", "2.0"]
<add> end
<add>
<add> it "when there are no matching kegs returns an array of Kegs" do
<add> expect(described_class.new.to_kegs).to be_empty
<add> end
<add> end
<add>
<ide> describe "#to_default_kegs" do
<ide> before do
<ide> (HOMEBREW_CELLAR/"foo/1.0").mkpath | 1 |
PHP | PHP | fix bug in query class | d65ddb53a842b83810f7e728107b8f1aa5d3f03a | <ide><path>laravel/database/query.php
<ide> public function take($value)
<ide> * @param int $per_page
<ide> * @return Query
<ide> */
<del> public function for_page($page, $per_page = 15)
<add> public function for_page($page, $per_page)
<ide> {
<ide> if ($page < 1 or filter_var($page, FILTER_VALIDATE_INT) === false) $page = 1;
<ide>
<del> return $this->skip(($page - 1) * $per_page)->take($per_page)
<del> }
<del>
<del> /**
<del> * Calculate and set the limit and offset values for a given page.
<del> *
<del> * @param int $page
<del> * @param int $per_page
<del> * @return Query
<del> */
<del> public function for_page($page, $per_page)
<del> {
<ide> return $this->skip(($page - 1) * $per_page)->take($per_page);
<ide> }
<ide> | 1 |
Javascript | Javascript | fix a bug in ordinal.copy. more tests | d2b152ce7f1d09c5eb8c73ba795695b11496f539 | <ide><path>d3.js
<ide> d3.scale.sqrt = function() {
<ide> return d3.scale.pow().exponent(.5);
<ide> };
<ide> d3.scale.ordinal = function() {
<del> return d3_scale_ordinal({}, 0, d3_noop);
<add> return d3_scale_ordinal({}, 0, {t: "range", x: []});
<ide> };
<ide>
<del>function d3_scale_ordinal(domain, size, rerange) {
<del> var range = [],
<del> rangeBand = 0;
<add>function d3_scale_ordinal(domain, size, ranger) {
<add> var range,
<add> rangeBand;
<ide>
<ide> function scale(x) {
<ide> return range[((domain[x] || (domain[x] = ++size)) - 1) % range.length];
<ide> function d3_scale_ordinal(domain, size, rerange) {
<ide> size = 0;
<ide> var i = -1, n = x.length, xi;
<ide> while (++i < n) if (!domain[xi = x[i]]) domain[xi] = ++size;
<del> rerange();
<del> return scale;
<add> return scale[ranger.t](ranger.x, ranger.p);
<ide> };
<ide>
<ide> scale.range = function(x) {
<ide> if (!arguments.length) return range;
<ide> range = x;
<ide> rangeBand = 0;
<del> rerange = d3_noop;
<add> ranger = {t: "range", x: x};
<ide> return scale;
<ide> };
<ide>
<ide> scale.rangePoints = function(x, padding) {
<ide> if (arguments.length < 2) padding = 0;
<del> var start = x[0], stop = x[1];
<del> (rerange = function() {
<del> var step = (stop - start) / (size - 1 + padding);
<del> range = size < 2
<del> ? [(start + stop) / 2]
<del> : d3.range(start + step * padding / 2, stop + step / 2, step);
<del> rangeBand = 0;
<del> })();
<add> var start = x[0],
<add> stop = x[1],
<add> step = (stop - start) / (size - 1 + padding);
<add> range = size < 2 ? [(start + stop) / 2] : d3.range(start + step * padding / 2, stop + step / 2, step);
<add> rangeBand = 0;
<add> ranger = {t: "rangePoints", x: x, p: padding};
<ide> return scale;
<ide> };
<ide>
<ide> scale.rangeBands = function(x, padding) {
<ide> if (arguments.length < 2) padding = 0;
<del> var start = x[0], stop = x[1];
<del> (rerange = function() {
<del> var step = (stop - start) / (size + padding);
<del> range = d3.range(start + step * padding, stop, step);
<del> rangeBand = step * (1 - padding);
<del> })();
<add> var start = x[0],
<add> stop = x[1],
<add> step = (stop - start) / (size + padding);
<add> range = d3.range(start + step * padding, stop, step);
<add> rangeBand = step * (1 - padding);
<add> ranger = {t: "rangeBands", x: x, p: padding};
<ide> return scale;
<ide> };
<ide>
<ide> scale.rangeRoundBands = function(x, padding) {
<ide> if (arguments.length < 2) padding = 0;
<del> var start = x[0], stop = x[1];
<del> (rerange = function() {
<del> var step = Math.floor((stop - start) / (size + padding)),
<del> err = stop - start - (size - padding) * step;
<del> range = d3.range(start + Math.round(err / 2), stop, step);
<del> rangeBand = Math.round(step * (1 - padding));
<del> })();
<add> var start = x[0],
<add> stop = x[1],
<add> step = Math.floor((stop - start) / (size + padding)),
<add> err = stop - start - (size - padding) * step;
<add> range = d3.range(start + Math.round(err / 2), stop, step);
<add> rangeBand = Math.round(step * (1 - padding));
<add> ranger = {t: "rangeRoundBands", x: x, p: padding};
<ide> return scale;
<ide> };
<ide>
<ide> function d3_scale_ordinal(domain, size, rerange) {
<ide> scale.copy = function() {
<ide> var copy = {}, x;
<ide> for (x in domain) copy[x] = domain[x];
<del> return d3_scale_ordinal(copy, size, rerange);
<add> return d3_scale_ordinal(copy, size, ranger);
<ide> };
<ide>
<del> rerange();
<del> return scale;
<add> return scale[ranger.t](ranger.x, ranger.p);
<ide> };
<ide> /*
<ide> * This product includes color specifications and designs developed by Cynthia
<ide><path>d3.min.js
<del>(function(){function cy(){return"circle"}function cx(){return 64}function cw(a,b){var c=(a.ownerSVGElement||a).createSVGPoint();if(cv<0&&(window.scrollX||window.scrollY)){var d=d3.select(document.body).append("svg:svg").style("position","absolute").style("top",0).style("left",0),e=d[0][0].getScreenCTM();cv=!e.f&&!e.e,d.remove()}cv?(c.x=b.pageX,c.y=b.pageY):(c.x=b.clientX,c.y=b.clientY),c=c.matrixTransform(a.getScreenCTM().inverse());return[c.x,c.y]}function cu(a){return function(){var b=a.apply(this,arguments),c=b[0],d=b[1]+bG;return[c*Math.cos(d),c*Math.sin(d)]}}function ct(a){return[a.x,a.y]}function cs(a){return a.endAngle}function cr(a){return a.startAngle}function cq(a){return a.radius}function cp(a){return a.target}function co(a){return a.source}function cn(a){return function(b,c){return a[c][1]}}function cm(a){return function(b,c){return a[c][0]}}function cl(a){function i(f){if(f.length<1)return null;var i=bN(this,f,b,d),j=bN(this,f,b===c?cm(i):c,d===e?cn(i):e);return"M"+g(a(j),h)+"L"+g(a(i.reverse()),h)+"Z"}var b=bO,c=bO,d=0,e=bP,f="linear",g=bQ[f],h=.7;i.x=function(a){if(!arguments.length)return c;b=c=a;return i},i.x0=function(a){if(!arguments.length)return b;b=a;return i},i.x1=function(a){if(!arguments.length)return c;c=a;return i},i.y=function(a){if(!arguments.length)return e;d=e=a;return i},i.y0=function(a){if(!arguments.length)return d;d=a;return i},i.y1=function(a){if(!arguments.length)return e;e=a;return i},i.interpolate=function(a){if(!arguments.length)return f;g=bQ[f=a];return i},i.tension=function(a){if(!arguments.length)return h;h=a;return i};return i}function ck(a){var b,c=-1,d=a.length,e,f;while(++c<d)b=a[c],e=b[0],f=b[1]+bG,b[0]=e*Math.cos(f),b[1]=e*Math.sin(f);return a}function cj(a){return a.length<3?bR(a):a[0]+bX(a,ci(a))}function ci(a){var b=[],c,d,e,f,g=ch(a),h=-1,i=a.length-1;while(++h<i)c=cg(a[h],a[h+1]),Math.abs(c)<1e-6?g[h]=g[h+1]=0:(d=g[h]/c,e=g[h+1]/c,f=d*d+e*e,f>9&&(f=c*3/Math.sqrt(f),g[h]=f*d,g[h+1]=f*e));h=-1;while(++h<=i)f=(a[Math.min(i,h+1)][0]-a[Math.max(0,h-1)][0])/(6*(1+g[h]*g[h])),b.push([f||0,g[h]*f||0]);return b}function ch(a){var b=0,c=a.length-1,d=[],e=a[0],f=a[1],g=d[0]=cg(e,f);while(++b<c)d[b]=g+(g=cg(e=f,f=a[b+1]));d[b]=g;return d}function cg(a,b){return(b[1]-a[1])/(b[0]-a[0])}function cf(a,b,c){a.push("C",cb(cc,b),",",cb(cc,c),",",cb(cd,b),",",cb(cd,c),",",cb(ce,b),",",cb(ce,c))}function cb(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}function ca(a,b){var c=a.length-1,d=a[0][0],e=a[0][1],f=a[c][0]-d,g=a[c][1]-e,h=-1,i,j;while(++h<=c)i=a[h],j=h/c,i[0]=b*i[0]+(1-b)*(d+j*f),i[1]=b*i[1]+(1-b)*(e+j*g);return bZ(a)}function b_(a){var b,c=-1,d=a.length,e=d+4,f,g=[],h=[];while(++c<4)f=a[c%d],g.push(f[0]),h.push(f[1]);b=[cb(ce,g),",",cb(ce,h)],--c;while(++c<e)f=a[c%d],g.shift(),g.push(f[0]),h.shift(),h.push(f[1]),cf(b,g,h);return b.join("")}function b$(a){if(a.length<4)return bR(a);var b=[],c=-1,d=a.length,e,f=[0],g=[0];while(++c<3)e=a[c],f.push(e[0]),g.push(e[1]);b.push(cb(ce,f)+","+cb(ce,g)),--c;while(++c<d)e=a[c],f.shift(),f.push(e[0]),g.shift(),g.push(e[1]),cf(b,f,g);return b.join("")}function bZ(a){if(a.length<3)return bR(a);var b=[],c=1,d=a.length,e=a[0],f=e[0],g=e[1],h=[f,f,f,(e=a[1])[0]],i=[g,g,g,e[1]];b.push(f,",",g),cf(b,h,i);while(++c<d)e=a[c],h.shift(),h.push(e[0]),i.shift(),i.push(e[1]),cf(b,h,i);c=-1;while(++c<2)h.shift(),h.push(e[0]),i.shift(),i.push(e[1]),cf(b,h,i);return b.join("")}function bY(a,b){var c=[],d=(1-b)/2,e,f=a[0],g=a[1],h=1,i=a.length;while(++h<i)e=f,f=g,g=a[h],c.push([d*(g[0]-e[0]),d*(g[1]-e[1])]);return c}function bX(a,b){if(b.length<1||a.length!=b.length&&a.length!=b.length+2)return bR(a);var c=a.length!=b.length,d="",e=a[0],f=a[1],g=b[0],h=g,i=1;c&&(d+="Q"+(f[0]-g[0]*2/3)+","+(f[1]-g[1]*2/3)+","+f[0]+","+f[1],e=a[1],i=2);if(b.length>1){h=b[1],f=a[i],i++,d+="C"+(e[0]+g[0])+","+(e[1]+g[1])+","+(f[0]-h[0])+","+(f[1]-h[1])+","+f[0]+","+f[1];for(var j=2;j<b.length;j++,i++)f=a[i],h=b[j],d+="S"+(f[0]-h[0])+","+(f[1]-h[1])+","+f[0]+","+f[1]}if(c){var k=a[i];d+="Q"+(f[0]+h[0]*2/3)+","+(f[1]+h[1]*2/3)+","+k[0]+","+k[1]}return d}function bW(a,b,c){return a.length<3?bR(a):a[0]+bX(a,bY(a,b))}function bV(a,b){return a.length<3?bR(a):a[0]+bX((a.push(a[0]),a),bY([a[a.length-2]].concat(a,[a[1]]),b))}function bU(a,b){return a.length<4?bR(a):a[1]+bX(a.slice(1,a.length-1),bY(a,b))}function bT(a){var b=[],c=0,d=a.length,e=a[0];b.push(e[0],",",e[1]);while(++c<d)b.push("H",(e=a[c])[0],"V",e[1]);return b.join("")}function bS(a){var b=[],c=0,d=a.length,e=a[0];b.push(e[0],",",e[1]);while(++c<d)b.push("V",(e=a[c])[1],"H",e[0]);return b.join("")}function bR(a){var b=[],c=0,d=a.length,e=a[0];b.push(e[0],",",e[1]);while(++c<d)b.push("L",(e=a[c])[0],",",e[1]);return b.join("")}function bP(a){return a[1]}function bO(a){return a[0]}function bN(a,b,c,d){var e=[],f=-1,g=b.length,h=typeof c=="function",i=typeof d=="function",j;if(h&&i)while(++f<g)e.push([c.call(a,j=b[f],f),d.call(a,j,f)]);else if(h)while(++f<g)e.push([c.call(a,b[f],f),d]);else if(i)while(++f<g)e.push([c,d.call(a,b[f],f)]);else while(++f<g)e.push([c,d]);return e}function bM(a){function g(d){return d.length<1?null:"M"+e(a(bN(this,d,b,c)),f)}var b=bO,c=bP,d="linear",e=bQ[d],f=.7;g.x=function(a){if(!arguments.length)return b;b=a;return g},g.y=function(a){if(!arguments.length)return c;c=a;return g},g.interpolate=function(a){if(!arguments.length)return d;e=bQ[d=a];return g},g.tension=function(a){if(!arguments.length)return f;f=a;return g};return g}function bL(a){return a.endAngle}function bK(a){return a.startAngle}function bJ(a){return a.outerRadius}function bI(a){return a.innerRadius}function bF(a,b,c){function g(){d=c.length/(b-a),e=c.length-1;return f}function f(b){return c[Math.max(0,Math.min(e,Math.floor(d*(b-a))))]}var d,e;f.domain=function(c){if(!arguments.length)return[a,b];a=+c[0],b=+c[c.length-1];return g()},f.range=function(a){if(!arguments.length)return c;c=a;return g()},f.copy=function(){return bF(a,b,c)};return g()}function bE(a,b){function e(a){return isNaN(a=+a)?NaN:b[d3.bisect(c,a)]}function d(){var d=0,f=a.length,g=b.length;c=[];while(++d<g)c[d-1]=d3.quantile(a,d/g);return e}var c;e.domain=function(b){if(!arguments.length)return a;a=b.filter(function(a){return!isNaN(a)}).sort(d3.ascending);return d()},e.range=function(a){if(!arguments.length)return b;b=a;return d()},e.quantiles=function(){return c},e.copy=function(){return bE(a,b)};return d()}function bz(a,b,c){function f(c){return d[((a[c]||(a[c]=++b))-1)%d.length]}var d=[],e=0;f.domain=function(d){if(!arguments.length)return d3.keys(a);a={},b=0;var e=-1,g=d.length,h;while(++e<g)a[h=d[e]]||(a[h]=++b);c();return f},f.range=function(a){if(!arguments.length)return d;d=a,e=0,c=bh;return f},f.rangePoints=function(a,g){arguments.length<2&&(g=0);var h=a[0],i=a[1];(c=function(){var a=(i-h)/(b-1+g);d=b<2?[(h+i)/2]:d3.range(h+a*g/2,i+a/2,a),e=0})();return f},f.rangeBands=function(a,g){arguments.length<2&&(g=0);var h=a[0],i=a[1];(c=function(){var a=(i-h)/(b+g);d=d3.range(h+a*g,i,a),e=a*(1-g)})();return f},f.rangeRoundBands=function(a,g){arguments.length<2&&(g=0);var h=a[0],i=a[1];(c=function(){var a=Math.floor((i-h)/(b+g)),c=i-h-(b-g)*a;d=d3.range(h+Math.round(c/2),i,a),e=Math.round(a*(1-g))})();return f},f.rangeBand=function(){return e},f.copy=function(){var d={},e;for(e in a)d[e]=a[e];return bz(d,b,c)},c();return f}function by(a){return function(b){return b<0?-Math.pow(-b,a):Math.pow(b,a)}}function bx(a,b){function e(b){return a(c(b))}var c=by(b),d=by(1/b);e.invert=function(b){return d(a.invert(b))},e.domain=function(b){if(!arguments.length)return a.domain().map(d);a.domain(b.map(c));return e},e.ticks=function(a){return bp(e.domain(),a)},e.tickFormat=function(a){return bq(e.domain(),a)},e.nice=function(){return e.domain(bj(e.domain(),bn))},e.exponent=function(a){if(!arguments.length)return b;var f=e.domain();c=by(b=a),d=by(1/b);return e.domain(f)},e.copy=function(){return bx(a.copy(),b)};return bm(e,a)}function bw(a){return a.toPrecision(1)}function bv(a){return-Math.log(-a)/Math.LN10}function bu(a){return Math.log(a)/Math.LN10}function bt(a,b){function d(c){return a(b(c))}var c=b.pow;d.invert=function(b){return c(a.invert(b))},d.domain=function(e){if(!arguments.length)return a.domain().map(c);b=e[0]<0?bv:bu,c=b.pow,a.domain(e.map(b));return d},d.nice=function(){a.domain(bj(a.domain(),bk));return d},d.ticks=function(){var d=bi(a.domain()),e=[];if(d.every(isFinite)){var f=Math.floor(d[0]),g=Math.ceil(d[1]),h=c(d[0]),i=c(d[1]);if(b===bv){e.push(c(f));for(;f++<g;)for(var j=9;j>0;j--)e.push(c(f)*j)}else{for(;f<g;f++)for(var j=1;j<10;j++)e.push(c(f)*j);e.push(c(f))}for(f=0;e[f]<h;f++);for(g=e.length;e[g-1]>i;g--);e=e.slice(f,g)}return e},d.tickFormat=function(){return bw},d.copy=function(){return bt(a.copy(),b)};return bm(d,a)}function bs(a,b,c,d){var e=[],f=[],g=0,h=a.length;while(++g<h)e.push(c(a[g-1],a[g])),f.push(d(b[g-1],b[g]));return function(b){var c=d3.bisect(a,b,1,a.length-1)-1;return f[c](e[c](b))}}function br(a,b,c,d){var e=c(a[0],a[1]),f=d(b[0],b[1]);return function(a){return f(e(a))}}function bq(a,b){return d3.format(",."+Math.max(0,-Math.floor(Math.log(bo(a,b)[2])/Math.LN10+.01))+"f")}function bp(a,b){return d3.range.apply(d3,bo(a,b))}function bo(a,b){var c=bi(a),d=c[1]-c[0],e=Math.pow(10,Math.floor(Math.log(d/b)/Math.LN10)),f=b/d*e;f<=.15?e*=10:f<=.35?e*=5:f<=.75&&(e*=2),c[0]=Math.ceil(c[0]/e)*e,c[1]=Math.floor(c[1]/e)*e+e*.5,c[2]=e;return c}function bn(a){a=Math.pow(10,Math.round(Math.log(a)/Math.LN10)-1);return{floor:function(b){return Math.floor(b/a)*a},ceil:function(b){return Math.ceil(b/a)*a}}}function bm(a,b){a.range=d3.rebind(a,b.range),a.rangeRound=d3.rebind(a,b.rangeRound),a.interpolate=d3.rebind(a,b.interpolate),a.clamp=d3.rebind(a,b.clamp);return a}function bl(a,b,c,d){function h(a){return e(a)}function g(){var g=a.length==2?br:bs,i=d?G:F;e=g(a,b,i,c),f=g(b,a,i,d3.interpolate);return h}var e,f;h.invert=function(a){return f(a)},h.domain=function(b){if(!arguments.length)return a;a=b.map(Number);return g()},h.range=function(a){if(!arguments.length)return b;b=a;return g()},h.rangeRound=function(a){return h.range(a).interpolate(d3.interpolateRound)},h.clamp=function(a){if(!arguments.length)return d;d=a;return g()},h.interpolate=function(a){if(!arguments.length)return c;c=a;return g()},h.ticks=function(b){return bp(a,b)},h.tickFormat=function(b){return bq(a,b)},h.nice=function(){bj(a,bn);return g()},h.copy=function(){return bl(a,b,c,d)};return g()}function bk(){return Math}function bj(a,b){var c=0,d=a.length-1,e=a[c],f=a[d],g;f<e&&(g=c,c=d,d=g,g=e,e=f,f=g),b=b(f-e),a[c]=b.floor(e),a[d]=b.ceil(f);return a}function bi(a){var b=a[0],c=a[a.length-1];return b<c?[b,c]:[c,b]}function bh(){}function bf(){var a=null,b=bb,c=Infinity;while(b)b.flush?b=a?a.next=b.next:bb=b.next:(c=Math.min(c,b.then+b.delay),b=(a=b).next);return c}function be(){var a,b=Date.now(),c=bb;while(c)a=b-c.then,a>=c.delay&&(c.flush=c.callback(a)),c=c.next;var d=bf()-b;d>24?(isFinite(d)&&(clearTimeout(bd),bd=setTimeout(be,d)),bc=0):(bc=1,bg(be))}function ba(a){return typeof a=="function"?function(b,c,d){var e=a.call(this,b,c)+"";return d!=e&&d3.interpolate(d,e)}:(a=a+"",function(b,c,d){return d!=a&&d3.interpolate(d,a)})}function _(a){function n(b){var h=!0,l=-1;a.each(function(){if(i[++l]!==2){var a=(b-j[l])/k[l],n=this.__transition__,o,p,q=e[l];if(a<1){h=!1;if(a<0)return}else a=1;if(i[l]){if(!n||n.active!==c){i[l]=2;return}}else{if(!n||n.active>c){i[l]=2;return}i[l]=1,g.start.dispatch.apply(this,arguments),q=e[l]={},n.active=c;for(p in d)if(o=d[p].apply(this,arguments))q[p]=o}o=m(a);for(p in q)q[p].call(this,o);if(a===1){i[l]=2;if(n.active===c){var r=n.owner;r===c&&(delete this.__transition__,f&&this.parentNode&&this.parentNode.removeChild(this)),$=c,g.end.dispatch.apply(this,arguments),$=0,n.owner=r}}}});return h}var b={},c=$||++Z,d={},e=[],f=!1,g=d3.dispatch("start","end"),i=[],j=[],k=[],l,m=d3.ease("cubic-in-out");a.each(function(){(this.__transition__||(this.__transition__={})).owner=c}),b.delay=function(c){var d=Infinity,e=-1;typeof c=="function"?a.each(function(a,b){var f=j[++e]=+c.apply(this,arguments);f<d&&(d=f)}):(d=+c,a.each(function(a,b){j[++e]=d})),d3.timer(n,d);return b},b.duration=function(c){var d=-1;typeof c=="function"?(l=0,a.each(function(a,b){var e=k[++d]=+c.apply(this,arguments);e>l&&(l=e)})):(l=+c,a.each(function(a,b){k[++d]=l}));return b},b.ease=function(a){m=typeof a=="function"?a:d3.ease.apply(d3,arguments);return b},b.attrTween=function(a,c){function f(b,d){var e=c.call(this,b,d,this.getAttributeNS(a.space,a.local));return e&&function(b){this.setAttributeNS(a.space,a.local,e(b))}}function e(b,d){var e=c.call(this,b,d,this.getAttribute(a));return e&&function(b){this.setAttribute(a,e(b))}}d["attr."+a]=a.local?f:e;return b},b.attr=function(a,c){return b.attrTween(a,ba(c))},b.styleTween=function(a,c,e){function f(b,d){var f=c.call(this,b,d,window.getComputedStyle(this,null).getPropertyValue(a));return f&&function(b){this.style.setProperty(a,f(b),e)}}arguments.length<3&&(e=null),d["style."+a]=f;return b},b.style=function(a,c,d){arguments.length<3&&(d=null);return b.styleTween(a,ba(c),d)},b.text=function(a){d.text=function(b,c){this.textContent=typeof a=="function"?a.call(this,b,c):a};return b},b.select=function(b){var c,d=_(a.select(b)).ease(m);c=-1,d.delay(function(a,b){return j[++c]}),c=-1,d.duration(function(a,b){return k[++c]});return d},b.selectAll=function(b){var c,d=_(a.selectAll(b)).ease(m);c=-1,d.delay(function(a,b){return j[b?c:++c]}),c=-1,d.duration(function(a,b){return k[b?c:++c]});return d},b.remove=function(){f=!0;return b},b.each=function(a,c){g[a].add(c);return b},b.call=h;return b.delay(0).duration(250)}function Y(a){return{__data__:a}}function X(a){arguments.length||(a=d3.ascending);return function(b,c){return a(b&&b.__data__,c&&c.__data__)}}function W(a){function b(b){var c=[],d,e,f,g;for(var h=0,i=a.length;h<i;h++){f=a[h],c.push(d=[]),d.parentNode=f.parentNode;for(var j=0,k=f.length;j<k;j++)(g=f[j])?(d.push(e=b(f.parentNode)),e.__data__=g.__data__):d.push(null)}return V(c)}a.append=function(a){function d(b){return b.appendChild(document.createElementNS(a.space,a.local))}function c(b){return b.appendChild(document.createElement(a))}a=d3.ns.qualify(a);return b(a.local?d:c)},a.insert=function(a,c){function e(b){return b.insertBefore(document.createElementNS(a.space,a.local),S(c,b))}function d(b){return b.insertBefore(document.createElement(a),S(c,b))}a=d3.ns.qualify(a);return b(a.local?e:d)};return a}function V(a){function d(b){for(var c=0,d=a.length;c<d;c++){var e=a[c];for(var f=0,g=e.length;f<g;f++){var h=e[f];if(h)return b.call(h,h.__data__,f)}}return null}function c(b){var c=[],d,e,f;for(var g=0,h=a.length;g<h;g++){e=a[g];for(var i=0,j=e.length;i<j;i++)if(f=e[i])c.push(d=b(f)),d.parentNode=f}return V(c)}function b(b){var c=[],d,e,f,g;for(var h=0,i=a.length;h<i;h++){f=a[h],c.push(d=[]),d.parentNode=f.parentNode;for(var j=0,k=f.length;j<k;j++)(g=f[j])?(d.push(e=b(g)),e&&"__data__"in g&&(e.__data__=g.__data__)):d.push(null)}return V(c)}a.select=function(a){return b(function(b){return S(a,b)})},a.selectAll=function(a){return c(function(b){return T(a,b)})},a.filter=function(b){var c=[],d,e,f;for(var g=0,h=a.length;g<h;g++){e=a[g],c.push(d=[]),d.parentNode=e.parentNode;for(var i=0,j=e.length;i<j;i++)(f=e[i])&&b.call(f,f.__data__,i)&&d.push(f)}return V(c)},a.map=function(b){var c,d;for(var e=0,f=a.length;e<f;e++){c=a[e];for(var g=0,h=c.length;g<h;g++)if(d=c[g])d.__data__=b.call(d,d.__data__,g)}return a},a.data=function(b,c){function g(a,b){var g=0,h=a.length,i=b.length,j=Math.min(h,i),k=Math.max(h,i),l=[],m=[],n=[],o,p;if(c){var q={},r=[],s,t=b.length;for(g=0;g<h;g++)s=c.call(o=a[g],o.__data__,g),s in q?n[t++]=o:q[s]=o,r.push(s);for(g=0;g<i;g++)o=q[s=c.call(b,p=b[g],g)],o?(o.__data__=p,l[g]=o,m[g]=n[g]=null):(m[g]=Y(p),l[g]=n[g]=null),delete q[s];for(g=0;g<h;g++)r[g]in q&&(n[g]=a[g])}else{for(;g<j;g++)o=a[g],p=b[g],o?(o.__data__=p,l[g]=o,m[g]=n[g]=null):(m[g]=Y(p),l[g]=n[g]=null);for(;g<i;g++)m[g]=Y(b[g]),l[g]=n[g]=null;for(;g<k;g++)n[g]=a[g],m[g]=l[g]=null}m.parentNode=l.parentNode=n.parentNode=a.parentNode,d.push(m),e.push(l),f.push(n)}var d=[],e=[],f=[],h=-1,i=a.length,j;if(typeof b=="function")while(++h<i)g(j=a[h],b.call(j,j.parentNode.__data__,h));else while(++h<i)g(j=a[h],b);var k=V(e);k.enter=function(){return W(d)},k.exit=function(){return V(f)};return k},a.each=function(b){for(var c=0,d=a.length;c<d;c++){var e=a[c];for(var f=0,g=e.length;f<g;f++){var h=e[f];h&&b.call(h,h.__data__,f)}}return a},a.empty=function(){return!d(function(){return!0})},a.node=function(){return d(function(){return this})},a.attr=function(b,c){function j(){var a=c.apply(this,arguments);a==null?this.removeAttributeNS(b.space,b.local):this.setAttributeNS(b.space,b.local,a)}function i(){var a=c.apply(this,arguments);a==null?this.removeAttribute(b):this.setAttribute(b,a)}function h(){this.setAttributeNS(b.space,b.local,c)}function g(){this.setAttribute(b,c)}function f(){this.removeAttributeNS(b.space,b.local)}function e(){this.removeAttribute(b)}b=d3.ns.qualify(b);return arguments.length<2?d(b.local?function(){return this.getAttributeNS(b.space,b.local)}:function(){return this.getAttribute(b)}):a.each(c==null?b.local?f:e:typeof c=="function"?b.local?j:i:b.local?h:g)},a.classed=function(b,c){function i(){(c.apply(this,arguments)?f:h).call(this)}function h(){if(a=this.classList)return a.remove(b);var a=this.className,c=a.baseVal!=null,d=c?a.baseVal:a;d=g(d.replace(e," ")),c?a.baseVal=d:this.className=d}function f(){if(a=this.classList)return a.add(b);var a=this.className,c=a.baseVal!=null,d=c?a.baseVal:a;e.lastIndex=0,e.test(d)||(d=g(d+" "+b),c?a.baseVal=d:this.className=d)}var e=new RegExp("(^|\\s+)"+d3.requote(b)+"(\\s+|$)","g");return arguments.length<2?d(function(){if(a=this.classList)return a.contains(b);var a=this.className;e.lastIndex=0;return e.test(a.baseVal!=null?a.baseVal:a)}):a.each(typeof c=="function"?i:c?f:h)},a.style=function(b,c,e){function h(){var a=c.apply(this,arguments);a==null?this.style.removeProperty(b):this.style.setProperty(b,a,e)}function g(){this.style.setProperty(b,c,e)}function f(){this.style.removeProperty(b)}arguments.length<3&&(e="");return arguments.length<2?d(function(){return window.getComputedStyle(this,null).getPropertyValue(b)}):a.each(c==null?f:typeof c=="function"?h:g)},a.property=function(b,c){function g(){var a=c.apply(this,arguments);a==null?delete this[b]:this[b]=a}function f(){this[b]=c}function e(){delete this[b]}b=d3.ns.qualify(b);return arguments.length<2?d(function(){return this[b]}):a.each(c==null?e:typeof c=="function"?g:f)},a.text=function(b){function e(){this.textContent=b.apply(this,arguments)}function c(){this.textContent=b}return arguments.length<1?d(function(){return this.textContent}):a.each(typeof b=="function"?e:c)},a.html=function(b){function e(){this.innerHTML=b.apply(this,arguments)}function c(){this.innerHTML=b}return arguments.length<1?d(function(){return this.innerHTML}):a.each(typeof b=="function"?e:c)},a.append=function(a){function d(b){return b.appendChild(document.createElementNS(a.space,a.local))}function c(b){return b.appendChild(document.createElement(a))}a=d3.ns.qualify(a);return b(a.local?d:c)},a.insert=function(a,c){function e(b){return b.insertBefore(document.createElementNS(a.space,a.local),S(c,b))}function d(b){return b.insertBefore(document.createElement(a),S(c,b))}a=d3.ns.qualify(a);return b(a.local?e:d)},a.remove=function(){return a.each(function(){var a=this.parentNode;a&&a.removeChild(this)})},a.sort=function(b){b=X.apply(this,arguments);for(var c=0,d=a.length;c<d;c++){var e=a[c];e.sort(b);for(var f=1,g=e.length,h=e[0];f<g;f++){var i=e[f];i&&(h&&h.parentNode.insertBefore(i,h.nextSibling),h=i)}}return a},a.on=function(b,c,d){arguments.length<3&&(d=!1);var e=b.indexOf("."),f=e===-1?b:b.substring(0,e),g="__on"+b;return a.each(function(a,b){function h(a){var d=d3.event;d3.event=a;try{c.call(this,e.__data__,b)}finally{d3.event=d}}this[g]&&this.removeEventListener(f,this[g],d),c&&this.addEventListener(f,this[g]=h,d);var e=this})},a.transition=function(){return _(a)},a.call=h;return a}function R(a,b,c){function g(a){return Math.round(f(a)*255)}function f(a){a>360?a-=360:a<0&&(a+=360);return a<60?d+(e-d)*a/60:a<180?e:a<240?d+(e-d)*(240-a)/60:d}var d,e;a=a%360,a<0&&(a+=360),b=b<0?0:b>1?1:b,c=c<0?0:c>1?1:c,e=c<=.5?c*(1+b):c+b-c*b,d=2*c-e;return H(g(a+120),g(a),g(a-120))}function Q(a,b,c){this.h=a,this.s=b,this.l=c}function P(a,b,c){return new Q(a,b,c)}function M(a){var b=parseFloat(a);return a.charAt(a.length-1)==="%"?Math.round(b*2.55):b}function L(a,b,c){var d=Math.min(a/=255,b/=255,c/=255),e=Math.max(a,b,c),f=e-d,g,h,i=(e+d)/2;f?(h=i<.5?f/(e+d):f/(2-e-d),a==e?g=(b-c)/f+(b<c?6:0):b==e?g=(c-a)/f+2:g=(a-b)/f+4,g*=60):h=g=0;return P(g,h,i)}function K(a,b,c){var d=0,e=0,f=0,g,h,i;g=/([a-z]+)\((.*)\)/i.exec(a);if(g){h=g[2].split(",");switch(g[1]){case"hsl":return c(parseFloat(h[0]),parseFloat(h[1])/100,parseFloat(h[2])/100);case"rgb":return b(M(h[0]),M(h[1]),M(h[2]))}}if(i=N[a])return b(i.r,i.g,i.b);a!=null&&a.charAt(0)==="#"&&(a.length===4?(d=a.charAt(1),d+=d,e=a.charAt(2),e+=e,f=a.charAt(3),f+=f):a.length===7&&(d=a.substring(1,3),e=a.substring(3,5),f=a.substring(5,7)),d=parseInt(d,16),e=parseInt(e,16),f=parseInt(f,16));return b(d,e,f)}function J(a){return a<16?"0"+a.toString(16):a.toString(16)}function I(a,b,c){this.r=a,this.g=b,this.b=c}function H(a,b,c){return new I(a,b,c)}function G(a,b){b=1/(b-(a=+a));return function(c){return Math.max(0,Math.min(1,(c-a)*b))}}function F(a,b){b=1/(b-(a=+a));return function(c){return(c-a)*b}}function E(a){return a in D||/\bcolor\b/.test(a)?d3.interpolateRgb:d3.interpolate}function B(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375}function A(a){a||(a=1.70158);return function(b){return b*b*((a+1)*b-a)}}function z(a,b){var c;arguments.length<2&&(b=.45),arguments.length<1?(a=1,c=b/4):c=b/(2*Math.PI)*Math.asin(1/a);return function(d){return 1+a*Math.pow(2,10*-d)*Math.sin((d-c)*2*Math.PI/b)}}function y(a){return 1-Math.sqrt(1-a*a)}function x(a){return Math.pow(2,10*(a-1))}function w(a){return 1-Math.cos(a*Math.PI/2)}function v(a){return function(b){return Math.pow(b,a)}}function u(a){return a}function t(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}}function s(a){return function(b){return 1-a(1-b)}}function n(a){var b=a.lastIndexOf("."),c=b>=0?a.substring(b):(b=a.length,""),d=[];while(b>0)d.push(a.substring(b-=3,b+3));return d.reverse().join(",")+c}function m(a){return a+""}function j(a){var b={},c=[];b.add=function(a){for(var d=0;d<c.length;d++)if(c[d].listener==a)return b;c.push({listener:a,on:!0});return b},b.remove=function(a){for(var d=0;d<c.length;d++){var e=c[d];if(e.listener==a){e.on=!1,c=c.slice(0,d).concat(c.slice(d+1));break}}return b},b.dispatch=function(){var a=c;for(var b=0,d=a.length;b<d;b++){var e=a[b];e.on&&e.listener.apply(this,arguments)}};return b}function h(a){a.apply(this,(arguments[0]=this,arguments));return this}function g(a){return a.replace(/(^\s+)|(\s+$)/g,"").replace(/\s+/g," ")}function f(a){return a==null}function e(a){return a.length}function c(a){return Array.prototype.slice.call(a)}function b(a){var b=-1,c=a.length,d=[];while(++b<c)d.push(a[b]);return d}d3={version:"1.29.5"},Date.now||(Date.now=function(){return+(new Date)}),Object.create||(Object.create=function(a){function b(){}b.prototype=a;return new b});var a=c;try{a(document.documentElement.childNodes)[0].nodeType}catch(d){a=b}d3.functor=function(a){return typeof a=="function"?a:function(){return a}},d3.rebind=function(a,b){return function(){var c=b.apply(a,arguments);return arguments.length?a:c}},d3.ascending=function(a,b){return a<b?-1:a>b?1:a>=b?0:NaN},d3.descending=function(a,b){return b<a?-1:b>a?1:b>=a?0:NaN},d3.min=function(a,b){var c=-1,d=a.length,e,f;if(arguments.length===1){while(++c<d&&((e=a[c])==null||e!=e))e=undefined;while(++c<d)(f=a[c])!=null&&e>f&&(e=f)}else{while(++c<d&&((e=b.call(a,a[c],c))==null||e!=e))e=undefined;while(++c<d)(f=b.call(a,a[c],c))!=null&&e>f&&(e=f)}return e},d3.max=function(a,b){var c=-1,d=a.length,e,f;if(arguments.length===1){while(++c<d&&((e=a[c])==null||e!=e))e=undefined;while(++c<d)(f=a[c])!=null&&f>e&&(e=f)}else{while(++c<d&&((e=b.call(a,a[c],c))==null||e!=e))e=undefined;while(++c<d)(f=b.call(a,a[c],c))!=null&&f>e&&(e=f)}return e},d3.sum=function(a,b){var c=0,d=a.length,e,f=-1;if(arguments.length===1)while(++f<d)isNaN(e=+a[f])||(c+=e);else while(++f<d)isNaN(e=+b.call(a,a[f],f))||(c+=e);return c},d3.quantile=function(a,b){var c=(a.length-1)*b+1,d=Math.floor(c),e=a[d-1],f=c-d;return f?e+f*(a[d]-e):e},d3.zip=function(){if(!(f=arguments.length))return[];for(var a=-1,b=d3.min(arguments,e),c=Array(b);++a<b;)for(var d=-1,f,g=c[a]=Array(f);++d<f;)g[d]=arguments[d][a];return c},d3.bisectLeft=function(a,b,c,d){arguments.length<3&&(c=0),arguments.length<4&&(d=a.length);while(c<d){var e=c+d>>1;a[e]<b?c=e+1:d=e}return c},d3.bisect=d3.bisectRight=function(a,b,c,d){arguments.length<3&&(c=0),arguments.length<4&&(d=a.length);while(c<d){var e=c+d>>1;b<a[e]?d=e:c=e+1}return c},d3.first=function(a,b){var c=0,d=a.length,e=a[0],f;arguments.length===1&&(b=d3.ascending);while(++c<d)b.call(a,e,f=a[c])>0&&(e=f);return e},d3.last=function(a,b){var c=0,d=a.length,e=a[0],f;arguments.length===1&&(b=d3.ascending);while(++c<d)b.call(a,e,f=a[c])<=0&&(e=f);return e},d3.nest=function(){function g(a,d){if(d>=b.length)return a;var e=[],f=c[d++],h;for(h in a)e.push({key:h,values:g(a[h],d)});f&&e.sort(function(a,b){return f(a.key,b.key)});return e}function f(c,g){if(g>=b.length)return e?e.call(a,c):d?c.sort(d):c;var h=-1,i=c.length,j=b[g++],k,l,m={};while(++h<i)(k=j(l=c[h]))in m?m[k].push(l):m[k]=[l];for(k in m)m[k]=f(m[k],g);return m}var a={},b=[],c=[],d,e;a.map=function(a){return f(a,0)},a.entries=function(a){return g(f(a,0),0)},a.key=function(c){b.push(c);return a},a.sortKeys=function(d){c[b.length-1]=d;return a},a.sortValues=function(b){d=b;return a},a.rollup=function(b){e=b;return a};return a},d3.keys=function(a){var b=[];for(var c in a)b.push(c);return b},d3.values=function(a){var b=[];for(var c in a)b.push(a[c]);return b},d3.entries=function(a){var b=[];for(var c in a)b.push({key:c,value:a[c]});return b},d3.permute=function(a,b){var c=[],d=-1,e=b.length;while(++d<e)c[d]=a[b[d]];return c},d3.merge=function(a){return Array.prototype.concat.apply([],a)},d3.split=function(a,b){var c=[],d=[],e,g=-1,h=a.length;arguments.length<2&&(b=f);while(++g<h)b.call(d,e=a[g],g)?d=[]:(d.length||c.push(d),d.push(e));return c},d3.range=function(a,b,c){arguments.length<3&&(c=1,arguments.length<2&&(b=a,a=0));if((b-a)/c==Infinity)throw new Error("infinite range");var d=[],e=-1,f;if(c<0)while((f=a+c*++e)>b)d.push(f);else while((f=a+c*++e)<b)d.push(f);return d},d3.requote=function(a){return a.replace(i,"\\$&")};var i=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;d3.round=function(a,b){return b?Math.round(a*Math.pow(10,b))*Math.pow(10,-b):Math.round(a)},d3.xhr=function(a,b,c){var d=new XMLHttpRequest;arguments.length<3?c=b:b&&d.overrideMimeType&&d.overrideMimeType(b),d.open("GET",a,!0),d.onreadystatechange=function(){d.readyState===4&&c(d.status<300?d:null)},d.send(null)},d3.text=function(a,b,c){function d(a){c(a&&a.responseText)}arguments.length<3&&(c=b,b=null),d3.xhr(a,b,d)},d3.json=function(a,b){d3.text(a,"application/json",function(a){b(a?JSON.parse(a):null)})},d3.html=function(a,b){d3.text(a,"text/html",function(a){if(a!=null){var c=document.createRange();c.selectNode(document.body),a=c.createContextualFragment(a)}b(a)})},d3.xml=function(a,b,c){function d(a){c(a&&a.responseXML)}arguments.length<3&&(c=b,b=null),d3.xhr(a,b,d)},d3.ns={prefix:{svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},qualify:function(a){var b=a.indexOf(":");return b<0?a:{space:d3.ns.prefix[a.substring(0,b)],local:a.substring(b+1)}}},d3.dispatch=function(a){var b={},c;for(var d=0,e=arguments.length;d<e;d++)c=arguments[d],b[c]=j(c);return b},d3.format=function(a){var b=k.exec(a),c=b[1]||" ",d=b[3]||"",e=b[5],f=+b[6],g=b[7],h=b[8],i=b[9],j=!1,o=!1;h&&(h=h.substring(1)),e&&(c="0",g&&(f-=Math.floor((f-1)/4)));switch(i){case"n":g=!0,i="g";break;case"%":j=!0,i="f";break;case"p":j=!0,i="r";break;case"d":o=!0,h="0"}i=l[i]||m;return function(a){var b=j?a*100:+a,k=b<0&&(b=-b)?"−":d;if(o&&b%1)return"";a=i(b,h);if(e){var l=a.length+k.length;l<f&&(a=Array(f-l+1).join(c)+a),g&&(a=n(a)),a=k+a}else{g&&(a=n(a)),a=k+a;var l=a.length;l<f&&(a=Array(f-l+1).join(c)+a)}j&&(a+="%");return a}};var k=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,l={g:function(a,b){return a.toPrecision(b)},e:function(a,b){return a.toExponential(b)},f:function(a,b){return a.toFixed(b)},r:function(a,b){var c=1+Math.floor(1e-15+Math.log(a)/Math.LN10);return d3.round(a,b-c).toFixed(Math.max(0,Math.min(20,b-c)))}},o=v(2),p=v(3),q={linear:function(){return u},poly:v,quad:function(){return o},cubic:function(){return p},sin:function(){return w},exp:function(){return x},circle:function(){return y},elastic:z,back:A,bounce:function(){return B}},r={"in":function(a){return a},out:s,"in-out":t,"out-in":function(a){return t(s(a))}};d3.ease=function(a){var b=a.indexOf("-"),c=b>=0?a.substring(0,b):a,d=b>=0?a.substring(b+1):"in";return r[d](q[c].apply(null,Array.prototype.slice.call(arguments,1)))},d3.event=null,d3.interpolate=function(a,b){var c=d3.interpolators.length,d;while(--c>=0&&!(d=d3.interpolators[c](a,b)));return d},d3.interpolateNumber=function(a,b){b-=a;return function(c){return a+b*c}},d3.interpolateRound=function(a,b){b-=a;return function(c){return Math.round(a+b*c)}},d3.interpolateString=function(a,b){var c,d,e,f=0,g=0,h=[],i=[],j,k;C.lastIndex=0;for(d=0;c=C.exec(b);++d)c.index&&h.push(b.substring(f,g=c.index)),i.push({i:h.length,x:c[0]}),h.push(null),f=C.lastIndex;f<b.length&&h.push(b.substring(f));for(d=0,j=i.length;(c=C.exec(a))&&d<j;++d){k=i[d];if(k.x==c[0]){if(k.i)if(h[k.i+1]==null){h[k.i-1]+=k.x,h.splice(k.i,1);for(e=d+1;e<j;++e)i[e].i--}else{h[k.i-1]+=k.x+h[k.i+1],h.splice(k.i,2);for(e=d+1;e<j;++e)i[e].i-=2}else if(h[k.i+1]==null)h[k.i]=k.x;else{h[k.i]=k.x+h[k.i+1],h.splice(k.i+1,1);for(e=d+1;e<j;++e)i[e].i--}i.splice(d,1),j--,d--}else k.x=d3.interpolateNumber(parseFloat(c[0]),parseFloat(k.x))}while(d<j)k=i.pop(),h[k.i+1]==null?h[k.i]=k.x:(h[k.i]=k.x+h[k.i+1],h.splice(k.i+1,1)),j--;return h.length===1?h[0]==null?i[0].x:function(){return b}:function(a){for(d=0;d<j;++d)h[(k=i[d]).i]=k.x(a);return h.join("")}},d3.interpolateRgb=function(a,b){a=d3.rgb(a),b=d3.rgb(b);var c=a.r,d=a.g,e=a.b,f=b.r-c,g=b.g-d,h=b.b-e;return function(a){return"rgb("+Math.round(c+f*a)+","+Math.round(d+g*a)+","+Math.round(e+h*a)+")"}},d3.interpolateHsl=function(a,b){a=d3.hsl(a),b=d3.hsl(b);var c=a.h,d=a.s,e=a.l,f=b.h-c,g=b.s-d,h=b.l-e;return function(a){return R(c+f*a,d+g*a,e+h*a).toString()}},d3.interpolateArray=function(a,b){var c=[],d=[],e=a.length,f=b.length,g=Math.min(a.length,b.length),h;for(h=0;h<g;++h)c.push(d3.interpolate(a[h],b[h]));for(;h<e;++h)d[h]=a[h];for(;h<f;++h)d[h]=b[h];return function(a){for(h=0;h<g;++h)d[h]=c[h](a);return d}},d3.interpolateObject=function(a,b){var c={},d={},e;for(e in a)e in b?c[e]=E(e)(a[e],b[e]):d[e]=a[e];for(e in b)e in a||(d[e]=b[e]);return function(a){for(e in c)d[e]=c[e](a);return d}};var C=/[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g,D={background:1,fill:1,stroke:1};d3.interpolators=[d3.interpolateObject,function(a,b){return b instanceof Array&&d3.interpolateArray(a,b)},function(a,b){return typeof b=="string"&&d3.interpolateString(String(a),b)},function(a,b){return(typeof b=="string"?b in N||/^(#|rgb\(|hsl\()/.test(b):b instanceof I||b instanceof Q)&&d3.interpolateRgb(String(a),b)},function(a,b){return typeof b=="number"&&d3.interpolateNumber(+a,b)}],d3.rgb=function(a,b,c){return arguments.length===1?K(""+a,H,R):H(~~a,~~b,~~c)},I.prototype.brighter=function(a){a=Math.pow(.7,arguments.length?a:1);var b=this.r,c=this.g,d=this.b,e=30;if(!b&&!c&&!d)return H(e,e,e);b&&b<e&&(b=e),c&&c<e&&(c=e),d&&d<e&&(d=e);return H(Math.min(255,Math.floor(b/a)),Math.min(255,Math.floor(c/a)),Math.min(255,Math.floor(d/a)))},I.prototype.darker=function(a){a=Math.pow(.7,arguments.length?a:1);return H(Math.max(0,Math.floor(a*this.r)),Math.max(0,Math.floor(a*this.g)),Math.max(0,Math.floor(a*this.b)))},I.prototype.hsl=function(){return L(this.r,this.g,this.b)},I.prototype.toString=function(){return"#"+J(this.r)+J(this.g)+J(this.b)};var N={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet
<del>:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};for(var O in N)N[O]=K(N[O],H,R);d3.hsl=function(a,b,c){return arguments.length===1?K(""+a,L,P):P(+a,+b,+c)},Q.prototype.brighter=function(a){a=Math.pow(.7,arguments.length?a:1);return P(this.h,this.s,this.l/a)},Q.prototype.darker=function(a){a=Math.pow(.7,arguments.length?a:1);return P(this.h,this.s,a*this.l)},Q.prototype.rgb=function(){return R(this.h,this.s,this.l)},Q.prototype.toString=function(){return"hsl("+this.h+","+this.s*100+"%,"+this.l*100+"%)"};var S=function(a,b){return b.querySelector(a)},T=function(b,c){return a(c.querySelectorAll(b))};typeof Sizzle=="function"&&(S=function(a,b){return Sizzle(a,b)[0]},T=function(a,b){return Sizzle.uniqueSort(Sizzle(a,b))});var U=V([[document]]);U[0].parentNode=document.documentElement,d3.select=function(a){return typeof a=="string"?U.select(a):V([[a]])},d3.selectAll=function(b){return typeof b=="string"?U.selectAll(b):V([a(b)])},d3.transition=U.transition;var Z=0,$=0,bb=null,bc,bd;d3.timer=function(a,b){var c=Date.now(),d=!1,e,f=bb;if(arguments.length<2)b=0;else if(!isFinite(b))return;while(f){if(f.callback===a){f.then=c,f.delay=b,d=!0;break}e=f,f=f.next}d||(bb={callback:a,then:c,delay:b,next:bb}),bc||(bd=clearTimeout(bd),bc=1,bg(be))},d3.timer.flush=function(){var a,b=Date.now(),c=bb;while(c)a=b-c.then,c.delay||(c.flush=c.callback(a)),c=c.next;bf()};var bg=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,17)};d3.scale={},d3.scale.linear=function(){return bl([0,1],[0,1],d3.interpolate,!1)},d3.scale.log=function(){return bt(d3.scale.linear(),bu)},bu.pow=function(a){return Math.pow(10,a)},bv.pow=function(a){return-Math.pow(10,-a)},d3.scale.pow=function(){return bx(d3.scale.linear(),1)},d3.scale.sqrt=function(){return d3.scale.pow().exponent(.5)},d3.scale.ordinal=function(){return bz({},0,bh)},d3.scale.category10=function(){return d3.scale.ordinal().range(bA)},d3.scale.category20=function(){return d3.scale.ordinal().range(bB)},d3.scale.category20b=function(){return d3.scale.ordinal().range(bC)},d3.scale.category20c=function(){return d3.scale.ordinal().range(bD)};var bA=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],bB=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],bC=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],bD=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];d3.scale.quantile=function(){return bE([],[])},d3.scale.quantize=function(){return bF(0,1,[0,1])},d3.svg={},d3.svg.arc=function(){function e(){var e=a.apply(this,arguments),f=b.apply(this,arguments),g=c.apply(this,arguments)+bG,h=d.apply(this,arguments)+bG,i=(h<g&&(i=g,g=h,h=i),h-g),j=i<Math.PI?"0":"1",k=Math.cos(g),l=Math.sin(g),m=Math.cos(h),n=Math.sin(h);return i>=bH?e?"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+ -f+"A"+f+","+f+" 0 1,1 0,"+f+"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+ -e+"A"+e+","+e+" 0 1,1 0,"+e+"Z":"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+ -f+"A"+f+","+f+" 0 1,1 0,"+f+"Z":e?"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L"+e*m+","+e*n+"A"+e+","+e+" 0 "+j+",0 "+e*k+","+e*l+"Z":"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L0,0"+"Z"}var a=bI,b=bJ,c=bK,d=bL;e.innerRadius=function(b){if(!arguments.length)return a;a=d3.functor(b);return e},e.outerRadius=function(a){if(!arguments.length)return b;b=d3.functor(a);return e},e.startAngle=function(a){if(!arguments.length)return c;c=d3.functor(a);return e},e.endAngle=function(a){if(!arguments.length)return d;d=d3.functor(a);return e},e.centroid=function(){var e=(a.apply(this,arguments)+b.apply(this,arguments))/2,f=(c.apply(this,arguments)+d.apply(this,arguments))/2+bG;return[Math.cos(f)*e,Math.sin(f)*e]};return e};var bG=-Math.PI/2,bH=2*Math.PI-1e-6;d3.svg.line=function(){return bM(Object)};var bQ={linear:bR,"step-before":bS,"step-after":bT,basis:bZ,"basis-open":b$,"basis-closed":b_,bundle:ca,cardinal:bW,"cardinal-open":bU,"cardinal-closed":bV,monotone:cj},cc=[0,2/3,1/3,0],cd=[0,1/3,2/3,0],ce=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var a=bM(ck);a.radius=a.x,delete a.x,a.angle=a.y,delete a.y;return a},d3.svg.area=function(){return cl(Object)},d3.svg.area.radial=function(){var a=cl(ck);a.radius=a.x,delete a.x,a.innerRadius=a.x0,delete a.x0,a.outerRadius=a.x1,delete a.x1,a.angle=a.y,delete a.y,a.startAngle=a.y0,delete a.y0,a.endAngle=a.y1,delete a.y1;return a},d3.svg.chord=function(){function j(a,b,c,d){return"Q 0,0 "+d}function i(a,b){return"A"+a+","+a+" 0 0,1 "+b}function h(a,b){return a.a0==b.a0&&a.a1==b.a1}function g(a,b,f,g){var h=b.call(a,f,g),i=c.call(a,h,g),j=d.call(a,h,g)+bG,k=e.call(a,h,g)+bG;return{r:i,a0:j,a1:k,p0:[i*Math.cos(j),i*Math.sin(j)],p1:[i*Math.cos(k),i*Math.sin(k)]}}function f(c,d){var e=g(this,a,c,d),f=g(this,b,c,d);return"M"+e.p0+i(e.r,e.p1)+(h(e,f)?j(e.r,e.p1,e.r,e.p0):j(e.r,e.p1,f.r,f.p0)+i(f.r,f.p1)+j(f.r,f.p1,e.r,e.p0))+"Z"}var a=co,b=cp,c=cq,d=bK,e=bL;f.radius=function(a){if(!arguments.length)return c;c=d3.functor(a);return f},f.source=function(b){if(!arguments.length)return a;a=d3.functor(b);return f},f.target=function(a){if(!arguments.length)return b;b=d3.functor(a);return f},f.startAngle=function(a){if(!arguments.length)return d;d=d3.functor(a);return f},f.endAngle=function(a){if(!arguments.length)return e;e=d3.functor(a);return f};return f},d3.svg.diagonal=function(){function d(d,e){var f=a.call(this,d,e),g=b.call(this,d,e),h=(f.y+g.y)/2,i=[f,{x:f.x,y:h},{x:g.x,y:h},g];i=i.map(c);return"M"+i[0]+"C"+i[1]+" "+i[2]+" "+i[3]}var a=co,b=cp,c=ct;d.source=function(b){if(!arguments.length)return a;a=d3.functor(b);return d},d.target=function(a){if(!arguments.length)return b;b=d3.functor(a);return d},d.projection=function(a){if(!arguments.length)return c;c=a;return d};return d},d3.svg.diagonal.radial=function(){var a=d3.svg.diagonal(),b=ct,c=a.projection;a.projection=function(a){return arguments.length?c(cu(b=a)):b};return a},d3.svg.mouse=function(a){return cw(a,d3.event)};var cv=/WebKit/.test(navigator.userAgent)?-1:0;d3.svg.touches=function(b){var c=d3.event.touches;return c?a(c).map(function(a){var c=cw(b,a);c.identifier=a.identifier;return c}):[]},d3.svg.symbol=function(){function c(c,d){return(cz[a.call(this,c,d)]||cz.circle)(b.call(this,c,d))}var a=cy,b=cx;c.type=function(b){if(!arguments.length)return a;a=d3.functor(b);return c},c.size=function(a){if(!arguments.length)return b;b=d3.functor(a);return c};return c};var cz={circle:function(a){var b=Math.sqrt(a/Math.PI);return"M0,"+b+"A"+b+","+b+" 0 1,1 0,"+ -b+"A"+b+","+b+" 0 1,1 0,"+b+"Z"},cross:function(a){var b=Math.sqrt(a/5)/2;return"M"+ -3*b+","+ -b+"H"+ -b+"V"+ -3*b+"H"+b+"V"+ -b+"H"+3*b+"V"+b+"H"+b+"V"+3*b+"H"+ -b+"V"+b+"H"+ -3*b+"Z"},diamond:function(a){var b=Math.sqrt(a/(2*cB)),c=b*cB;return"M0,"+ -b+"L"+c+",0"+" 0,"+b+" "+ -c+",0"+"Z"},square:function(a){var b=Math.sqrt(a)/2;return"M"+ -b+","+ -b+"L"+b+","+ -b+" "+b+","+b+" "+ -b+","+b+"Z"},"triangle-down":function(a){var b=Math.sqrt(a/cA),c=b*cA/2;return"M0,"+c+"L"+b+","+ -c+" "+ -b+","+ -c+"Z"},"triangle-up":function(a){var b=Math.sqrt(a/cA),c=b*cA/2;return"M0,"+ -c+"L"+b+","+c+" "+ -b+","+c+"Z"}};d3.svg.symbolTypes=d3.keys(cz);var cA=Math.sqrt(3),cB=Math.tan(30*Math.PI/180)})()
<ide>\ No newline at end of file
<add>(function(){function cy(){return"circle"}function cx(){return 64}function cw(a,b){var c=(a.ownerSVGElement||a).createSVGPoint();if(cv<0&&(window.scrollX||window.scrollY)){var d=d3.select(document.body).append("svg:svg").style("position","absolute").style("top",0).style("left",0),e=d[0][0].getScreenCTM();cv=!e.f&&!e.e,d.remove()}cv?(c.x=b.pageX,c.y=b.pageY):(c.x=b.clientX,c.y=b.clientY),c=c.matrixTransform(a.getScreenCTM().inverse());return[c.x,c.y]}function cu(a){return function(){var b=a.apply(this,arguments),c=b[0],d=b[1]+bG;return[c*Math.cos(d),c*Math.sin(d)]}}function ct(a){return[a.x,a.y]}function cs(a){return a.endAngle}function cr(a){return a.startAngle}function cq(a){return a.radius}function cp(a){return a.target}function co(a){return a.source}function cn(a){return function(b,c){return a[c][1]}}function cm(a){return function(b,c){return a[c][0]}}function cl(a){function i(f){if(f.length<1)return null;var i=bN(this,f,b,d),j=bN(this,f,b===c?cm(i):c,d===e?cn(i):e);return"M"+g(a(j),h)+"L"+g(a(i.reverse()),h)+"Z"}var b=bO,c=bO,d=0,e=bP,f="linear",g=bQ[f],h=.7;i.x=function(a){if(!arguments.length)return c;b=c=a;return i},i.x0=function(a){if(!arguments.length)return b;b=a;return i},i.x1=function(a){if(!arguments.length)return c;c=a;return i},i.y=function(a){if(!arguments.length)return e;d=e=a;return i},i.y0=function(a){if(!arguments.length)return d;d=a;return i},i.y1=function(a){if(!arguments.length)return e;e=a;return i},i.interpolate=function(a){if(!arguments.length)return f;g=bQ[f=a];return i},i.tension=function(a){if(!arguments.length)return h;h=a;return i};return i}function ck(a){var b,c=-1,d=a.length,e,f;while(++c<d)b=a[c],e=b[0],f=b[1]+bG,b[0]=e*Math.cos(f),b[1]=e*Math.sin(f);return a}function cj(a){return a.length<3?bR(a):a[0]+bX(a,ci(a))}function ci(a){var b=[],c,d,e,f,g=ch(a),h=-1,i=a.length-1;while(++h<i)c=cg(a[h],a[h+1]),Math.abs(c)<1e-6?g[h]=g[h+1]=0:(d=g[h]/c,e=g[h+1]/c,f=d*d+e*e,f>9&&(f=c*3/Math.sqrt(f),g[h]=f*d,g[h+1]=f*e));h=-1;while(++h<=i)f=(a[Math.min(i,h+1)][0]-a[Math.max(0,h-1)][0])/(6*(1+g[h]*g[h])),b.push([f||0,g[h]*f||0]);return b}function ch(a){var b=0,c=a.length-1,d=[],e=a[0],f=a[1],g=d[0]=cg(e,f);while(++b<c)d[b]=g+(g=cg(e=f,f=a[b+1]));d[b]=g;return d}function cg(a,b){return(b[1]-a[1])/(b[0]-a[0])}function cf(a,b,c){a.push("C",cb(cc,b),",",cb(cc,c),",",cb(cd,b),",",cb(cd,c),",",cb(ce,b),",",cb(ce,c))}function cb(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}function ca(a,b){var c=a.length-1,d=a[0][0],e=a[0][1],f=a[c][0]-d,g=a[c][1]-e,h=-1,i,j;while(++h<=c)i=a[h],j=h/c,i[0]=b*i[0]+(1-b)*(d+j*f),i[1]=b*i[1]+(1-b)*(e+j*g);return bZ(a)}function b_(a){var b,c=-1,d=a.length,e=d+4,f,g=[],h=[];while(++c<4)f=a[c%d],g.push(f[0]),h.push(f[1]);b=[cb(ce,g),",",cb(ce,h)],--c;while(++c<e)f=a[c%d],g.shift(),g.push(f[0]),h.shift(),h.push(f[1]),cf(b,g,h);return b.join("")}function b$(a){if(a.length<4)return bR(a);var b=[],c=-1,d=a.length,e,f=[0],g=[0];while(++c<3)e=a[c],f.push(e[0]),g.push(e[1]);b.push(cb(ce,f)+","+cb(ce,g)),--c;while(++c<d)e=a[c],f.shift(),f.push(e[0]),g.shift(),g.push(e[1]),cf(b,f,g);return b.join("")}function bZ(a){if(a.length<3)return bR(a);var b=[],c=1,d=a.length,e=a[0],f=e[0],g=e[1],h=[f,f,f,(e=a[1])[0]],i=[g,g,g,e[1]];b.push(f,",",g),cf(b,h,i);while(++c<d)e=a[c],h.shift(),h.push(e[0]),i.shift(),i.push(e[1]),cf(b,h,i);c=-1;while(++c<2)h.shift(),h.push(e[0]),i.shift(),i.push(e[1]),cf(b,h,i);return b.join("")}function bY(a,b){var c=[],d=(1-b)/2,e,f=a[0],g=a[1],h=1,i=a.length;while(++h<i)e=f,f=g,g=a[h],c.push([d*(g[0]-e[0]),d*(g[1]-e[1])]);return c}function bX(a,b){if(b.length<1||a.length!=b.length&&a.length!=b.length+2)return bR(a);var c=a.length!=b.length,d="",e=a[0],f=a[1],g=b[0],h=g,i=1;c&&(d+="Q"+(f[0]-g[0]*2/3)+","+(f[1]-g[1]*2/3)+","+f[0]+","+f[1],e=a[1],i=2);if(b.length>1){h=b[1],f=a[i],i++,d+="C"+(e[0]+g[0])+","+(e[1]+g[1])+","+(f[0]-h[0])+","+(f[1]-h[1])+","+f[0]+","+f[1];for(var j=2;j<b.length;j++,i++)f=a[i],h=b[j],d+="S"+(f[0]-h[0])+","+(f[1]-h[1])+","+f[0]+","+f[1]}if(c){var k=a[i];d+="Q"+(f[0]+h[0]*2/3)+","+(f[1]+h[1]*2/3)+","+k[0]+","+k[1]}return d}function bW(a,b,c){return a.length<3?bR(a):a[0]+bX(a,bY(a,b))}function bV(a,b){return a.length<3?bR(a):a[0]+bX((a.push(a[0]),a),bY([a[a.length-2]].concat(a,[a[1]]),b))}function bU(a,b){return a.length<4?bR(a):a[1]+bX(a.slice(1,a.length-1),bY(a,b))}function bT(a){var b=[],c=0,d=a.length,e=a[0];b.push(e[0],",",e[1]);while(++c<d)b.push("H",(e=a[c])[0],"V",e[1]);return b.join("")}function bS(a){var b=[],c=0,d=a.length,e=a[0];b.push(e[0],",",e[1]);while(++c<d)b.push("V",(e=a[c])[1],"H",e[0]);return b.join("")}function bR(a){var b=[],c=0,d=a.length,e=a[0];b.push(e[0],",",e[1]);while(++c<d)b.push("L",(e=a[c])[0],",",e[1]);return b.join("")}function bP(a){return a[1]}function bO(a){return a[0]}function bN(a,b,c,d){var e=[],f=-1,g=b.length,h=typeof c=="function",i=typeof d=="function",j;if(h&&i)while(++f<g)e.push([c.call(a,j=b[f],f),d.call(a,j,f)]);else if(h)while(++f<g)e.push([c.call(a,b[f],f),d]);else if(i)while(++f<g)e.push([c,d.call(a,b[f],f)]);else while(++f<g)e.push([c,d]);return e}function bM(a){function g(d){return d.length<1?null:"M"+e(a(bN(this,d,b,c)),f)}var b=bO,c=bP,d="linear",e=bQ[d],f=.7;g.x=function(a){if(!arguments.length)return b;b=a;return g},g.y=function(a){if(!arguments.length)return c;c=a;return g},g.interpolate=function(a){if(!arguments.length)return d;e=bQ[d=a];return g},g.tension=function(a){if(!arguments.length)return f;f=a;return g};return g}function bL(a){return a.endAngle}function bK(a){return a.startAngle}function bJ(a){return a.outerRadius}function bI(a){return a.innerRadius}function bF(a,b,c){function g(){d=c.length/(b-a),e=c.length-1;return f}function f(b){return c[Math.max(0,Math.min(e,Math.floor(d*(b-a))))]}var d,e;f.domain=function(c){if(!arguments.length)return[a,b];a=+c[0],b=+c[c.length-1];return g()},f.range=function(a){if(!arguments.length)return c;c=a;return g()},f.copy=function(){return bF(a,b,c)};return g()}function bE(a,b){function e(a){return isNaN(a=+a)?NaN:b[d3.bisect(c,a)]}function d(){var d=0,f=a.length,g=b.length;c=[];while(++d<g)c[d-1]=d3.quantile(a,d/g);return e}var c;e.domain=function(b){if(!arguments.length)return a;a=b.filter(function(a){return!isNaN(a)}).sort(d3.ascending);return d()},e.range=function(a){if(!arguments.length)return b;b=a;return d()},e.quantiles=function(){return c},e.copy=function(){return bE(a,b)};return d()}function bz(a,b,c){function f(c){return d[((a[c]||(a[c]=++b))-1)%d.length]}var d,e;f.domain=function(d){if(!arguments.length)return d3.keys(a);a={},b=0;var e=-1,g=d.length,h;while(++e<g)a[h=d[e]]||(a[h]=++b);return f[c.t](c.x,c.p)},f.range=function(a){if(!arguments.length)return d;d=a,e=0,c={t:"range",x:a};return f},f.rangePoints=function(a,g){arguments.length<2&&(g=0);var h=a[0],i=a[1],j=(i-h)/(b-1+g);d=b<2?[(h+i)/2]:d3.range(h+j*g/2,i+j/2,j),e=0,c={t:"rangePoints",x:a,p:g};return f},f.rangeBands=function(a,g){arguments.length<2&&(g=0);var h=a[0],i=a[1],j=(i-h)/(b+g);d=d3.range(h+j*g,i,j),e=j*(1-g),c={t:"rangeBands",x:a,p:g};return f},f.rangeRoundBands=function(a,g){arguments.length<2&&(g=0);var h=a[0],i=a[1],j=Math.floor((i-h)/(b+g)),k=i-h-(b-g)*j;d=d3.range(h+Math.round(k/2),i,j),e=Math.round(j*(1-g)),c={t:"rangeRoundBands",x:a,p:g};return f},f.rangeBand=function(){return e},f.copy=function(){var d={},e;for(e in a)d[e]=a[e];return bz(d,b,c)};return f[c.t](c.x,c.p)}function by(a){return function(b){return b<0?-Math.pow(-b,a):Math.pow(b,a)}}function bx(a,b){function e(b){return a(c(b))}var c=by(b),d=by(1/b);e.invert=function(b){return d(a.invert(b))},e.domain=function(b){if(!arguments.length)return a.domain().map(d);a.domain(b.map(c));return e},e.ticks=function(a){return bp(e.domain(),a)},e.tickFormat=function(a){return bq(e.domain(),a)},e.nice=function(){return e.domain(bj(e.domain(),bn))},e.exponent=function(a){if(!arguments.length)return b;var f=e.domain();c=by(b=a),d=by(1/b);return e.domain(f)},e.copy=function(){return bx(a.copy(),b)};return bm(e,a)}function bw(a){return a.toPrecision(1)}function bv(a){return-Math.log(-a)/Math.LN10}function bu(a){return Math.log(a)/Math.LN10}function bt(a,b){function d(c){return a(b(c))}var c=b.pow;d.invert=function(b){return c(a.invert(b))},d.domain=function(e){if(!arguments.length)return a.domain().map(c);b=e[0]<0?bv:bu,c=b.pow,a.domain(e.map(b));return d},d.nice=function(){a.domain(bj(a.domain(),bk));return d},d.ticks=function(){var d=bi(a.domain()),e=[];if(d.every(isFinite)){var f=Math.floor(d[0]),g=Math.ceil(d[1]),h=c(d[0]),i=c(d[1]);if(b===bv){e.push(c(f));for(;f++<g;)for(var j=9;j>0;j--)e.push(c(f)*j)}else{for(;f<g;f++)for(var j=1;j<10;j++)e.push(c(f)*j);e.push(c(f))}for(f=0;e[f]<h;f++);for(g=e.length;e[g-1]>i;g--);e=e.slice(f,g)}return e},d.tickFormat=function(){return bw},d.copy=function(){return bt(a.copy(),b)};return bm(d,a)}function bs(a,b,c,d){var e=[],f=[],g=0,h=a.length;while(++g<h)e.push(c(a[g-1],a[g])),f.push(d(b[g-1],b[g]));return function(b){var c=d3.bisect(a,b,1,a.length-1)-1;return f[c](e[c](b))}}function br(a,b,c,d){var e=c(a[0],a[1]),f=d(b[0],b[1]);return function(a){return f(e(a))}}function bq(a,b){return d3.format(",."+Math.max(0,-Math.floor(Math.log(bo(a,b)[2])/Math.LN10+.01))+"f")}function bp(a,b){return d3.range.apply(d3,bo(a,b))}function bo(a,b){var c=bi(a),d=c[1]-c[0],e=Math.pow(10,Math.floor(Math.log(d/b)/Math.LN10)),f=b/d*e;f<=.15?e*=10:f<=.35?e*=5:f<=.75&&(e*=2),c[0]=Math.ceil(c[0]/e)*e,c[1]=Math.floor(c[1]/e)*e+e*.5,c[2]=e;return c}function bn(a){a=Math.pow(10,Math.round(Math.log(a)/Math.LN10)-1);return{floor:function(b){return Math.floor(b/a)*a},ceil:function(b){return Math.ceil(b/a)*a}}}function bm(a,b){a.range=d3.rebind(a,b.range),a.rangeRound=d3.rebind(a,b.rangeRound),a.interpolate=d3.rebind(a,b.interpolate),a.clamp=d3.rebind(a,b.clamp);return a}function bl(a,b,c,d){function h(a){return e(a)}function g(){var g=a.length==2?br:bs,i=d?G:F;e=g(a,b,i,c),f=g(b,a,i,d3.interpolate);return h}var e,f;h.invert=function(a){return f(a)},h.domain=function(b){if(!arguments.length)return a;a=b.map(Number);return g()},h.range=function(a){if(!arguments.length)return b;b=a;return g()},h.rangeRound=function(a){return h.range(a).interpolate(d3.interpolateRound)},h.clamp=function(a){if(!arguments.length)return d;d=a;return g()},h.interpolate=function(a){if(!arguments.length)return c;c=a;return g()},h.ticks=function(b){return bp(a,b)},h.tickFormat=function(b){return bq(a,b)},h.nice=function(){bj(a,bn);return g()},h.copy=function(){return bl(a,b,c,d)};return g()}function bk(){return Math}function bj(a,b){var c=0,d=a.length-1,e=a[c],f=a[d],g;f<e&&(g=c,c=d,d=g,g=e,e=f,f=g),b=b(f-e),a[c]=b.floor(e),a[d]=b.ceil(f);return a}function bi(a){var b=a[0],c=a[a.length-1];return b<c?[b,c]:[c,b]}function bh(){}function bf(){var a=null,b=bb,c=Infinity;while(b)b.flush?b=a?a.next=b.next:bb=b.next:(c=Math.min(c,b.then+b.delay),b=(a=b).next);return c}function be(){var a,b=Date.now(),c=bb;while(c)a=b-c.then,a>=c.delay&&(c.flush=c.callback(a)),c=c.next;var d=bf()-b;d>24?(isFinite(d)&&(clearTimeout(bd),bd=setTimeout(be,d)),bc=0):(bc=1,bg(be))}function ba(a){return typeof a=="function"?function(b,c,d){var e=a.call(this,b,c)+"";return d!=e&&d3.interpolate(d,e)}:(a=a+"",function(b,c,d){return d!=a&&d3.interpolate(d,a)})}function _(a){function n(b){var h=!0,l=-1;a.each(function(){if(i[++l]!==2){var a=(b-j[l])/k[l],n=this.__transition__,o,p,q=e[l];if(a<1){h=!1;if(a<0)return}else a=1;if(i[l]){if(!n||n.active!==c){i[l]=2;return}}else{if(!n||n.active>c){i[l]=2;return}i[l]=1,g.start.dispatch.apply(this,arguments),q=e[l]={},n.active=c;for(p in d)if(o=d[p].apply(this,arguments))q[p]=o}o=m(a);for(p in q)q[p].call(this,o);if(a===1){i[l]=2;if(n.active===c){var r=n.owner;r===c&&(delete this.__transition__,f&&this.parentNode&&this.parentNode.removeChild(this)),$=c,g.end.dispatch.apply(this,arguments),$=0,n.owner=r}}}});return h}var b={},c=$||++Z,d={},e=[],f=!1,g=d3.dispatch("start","end"),i=[],j=[],k=[],l,m=d3.ease("cubic-in-out");a.each(function(){(this.__transition__||(this.__transition__={})).owner=c}),b.delay=function(c){var d=Infinity,e=-1;typeof c=="function"?a.each(function(a,b){var f=j[++e]=+c.apply(this,arguments);f<d&&(d=f)}):(d=+c,a.each(function(a,b){j[++e]=d})),d3.timer(n,d);return b},b.duration=function(c){var d=-1;typeof c=="function"?(l=0,a.each(function(a,b){var e=k[++d]=+c.apply(this,arguments);e>l&&(l=e)})):(l=+c,a.each(function(a,b){k[++d]=l}));return b},b.ease=function(a){m=typeof a=="function"?a:d3.ease.apply(d3,arguments);return b},b.attrTween=function(a,c){function f(b,d){var e=c.call(this,b,d,this.getAttributeNS(a.space,a.local));return e&&function(b){this.setAttributeNS(a.space,a.local,e(b))}}function e(b,d){var e=c.call(this,b,d,this.getAttribute(a));return e&&function(b){this.setAttribute(a,e(b))}}d["attr."+a]=a.local?f:e;return b},b.attr=function(a,c){return b.attrTween(a,ba(c))},b.styleTween=function(a,c,e){function f(b,d){var f=c.call(this,b,d,window.getComputedStyle(this,null).getPropertyValue(a));return f&&function(b){this.style.setProperty(a,f(b),e)}}arguments.length<3&&(e=null),d["style."+a]=f;return b},b.style=function(a,c,d){arguments.length<3&&(d=null);return b.styleTween(a,ba(c),d)},b.text=function(a){d.text=function(b,c){this.textContent=typeof a=="function"?a.call(this,b,c):a};return b},b.select=function(b){var c,d=_(a.select(b)).ease(m);c=-1,d.delay(function(a,b){return j[++c]}),c=-1,d.duration(function(a,b){return k[++c]});return d},b.selectAll=function(b){var c,d=_(a.selectAll(b)).ease(m);c=-1,d.delay(function(a,b){return j[b?c:++c]}),c=-1,d.duration(function(a,b){return k[b?c:++c]});return d},b.remove=function(){f=!0;return b},b.each=function(a,c){g[a].add(c);return b},b.call=h;return b.delay(0).duration(250)}function Y(a){return{__data__:a}}function X(a){arguments.length||(a=d3.ascending);return function(b,c){return a(b&&b.__data__,c&&c.__data__)}}function W(a){function b(b){var c=[],d,e,f,g;for(var h=0,i=a.length;h<i;h++){f=a[h],c.push(d=[]),d.parentNode=f.parentNode;for(var j=0,k=f.length;j<k;j++)(g=f[j])?(d.push(e=b(f.parentNode)),e.__data__=g.__data__):d.push(null)}return V(c)}a.append=function(a){function d(b){return b.appendChild(document.createElementNS(a.space,a.local))}function c(b){return b.appendChild(document.createElement(a))}a=d3.ns.qualify(a);return b(a.local?d:c)},a.insert=function(a,c){function e(b){return b.insertBefore(document.createElementNS(a.space,a.local),S(c,b))}function d(b){return b.insertBefore(document.createElement(a),S(c,b))}a=d3.ns.qualify(a);return b(a.local?e:d)};return a}function V(a){function d(b){for(var c=0,d=a.length;c<d;c++){var e=a[c];for(var f=0,g=e.length;f<g;f++){var h=e[f];if(h)return b.call(h,h.__data__,f)}}return null}function c(b){var c=[],d,e,f;for(var g=0,h=a.length;g<h;g++){e=a[g];for(var i=0,j=e.length;i<j;i++)if(f=e[i])c.push(d=b(f)),d.parentNode=f}return V(c)}function b(b){var c=[],d,e,f,g;for(var h=0,i=a.length;h<i;h++){f=a[h],c.push(d=[]),d.parentNode=f.parentNode;for(var j=0,k=f.length;j<k;j++)(g=f[j])?(d.push(e=b(g)),e&&"__data__"in g&&(e.__data__=g.__data__)):d.push(null)}return V(c)}a.select=function(a){return b(function(b){return S(a,b)})},a.selectAll=function(a){return c(function(b){return T(a,b)})},a.filter=function(b){var c=[],d,e,f;for(var g=0,h=a.length;g<h;g++){e=a[g],c.push(d=[]),d.parentNode=e.parentNode;for(var i=0,j=e.length;i<j;i++)(f=e[i])&&b.call(f,f.__data__,i)&&d.push(f)}return V(c)},a.map=function(b){var c,d;for(var e=0,f=a.length;e<f;e++){c=a[e];for(var g=0,h=c.length;g<h;g++)if(d=c[g])d.__data__=b.call(d,d.__data__,g)}return a},a.data=function(b,c){function g(a,b){var g=0,h=a.length,i=b.length,j=Math.min(h,i),k=Math.max(h,i),l=[],m=[],n=[],o,p;if(c){var q={},r=[],s,t=b.length;for(g=0;g<h;g++)s=c.call(o=a[g],o.__data__,g),s in q?n[t++]=o:q[s]=o,r.push(s);for(g=0;g<i;g++)o=q[s=c.call(b,p=b[g],g)],o?(o.__data__=p,l[g]=o,m[g]=n[g]=null):(m[g]=Y(p),l[g]=n[g]=null),delete q[s];for(g=0;g<h;g++)r[g]in q&&(n[g]=a[g])}else{for(;g<j;g++)o=a[g],p=b[g],o?(o.__data__=p,l[g]=o,m[g]=n[g]=null):(m[g]=Y(p),l[g]=n[g]=null);for(;g<i;g++)m[g]=Y(b[g]),l[g]=n[g]=null;for(;g<k;g++)n[g]=a[g],m[g]=l[g]=null}m.parentNode=l.parentNode=n.parentNode=a.parentNode,d.push(m),e.push(l),f.push(n)}var d=[],e=[],f=[],h=-1,i=a.length,j;if(typeof b=="function")while(++h<i)g(j=a[h],b.call(j,j.parentNode.__data__,h));else while(++h<i)g(j=a[h],b);var k=V(e);k.enter=function(){return W(d)},k.exit=function(){return V(f)};return k},a.each=function(b){for(var c=0,d=a.length;c<d;c++){var e=a[c];for(var f=0,g=e.length;f<g;f++){var h=e[f];h&&b.call(h,h.__data__,f)}}return a},a.empty=function(){return!d(function(){return!0})},a.node=function(){return d(function(){return this})},a.attr=function(b,c){function j(){var a=c.apply(this,arguments);a==null?this.removeAttributeNS(b.space,b.local):this.setAttributeNS(b.space,b.local,a)}function i(){var a=c.apply(this,arguments);a==null?this.removeAttribute(b):this.setAttribute(b,a)}function h(){this.setAttributeNS(b.space,b.local,c)}function g(){this.setAttribute(b,c)}function f(){this.removeAttributeNS(b.space,b.local)}function e(){this.removeAttribute(b)}b=d3.ns.qualify(b);return arguments.length<2?d(b.local?function(){return this.getAttributeNS(b.space,b.local)}:function(){return this.getAttribute(b)}):a.each(c==null?b.local?f:e:typeof c=="function"?b.local?j:i:b.local?h:g)},a.classed=function(b,c){function i(){(c.apply(this,arguments)?f:h).call(this)}function h(){if(a=this.classList)return a.remove(b);var a=this.className,c=a.baseVal!=null,d=c?a.baseVal:a;d=g(d.replace(e," ")),c?a.baseVal=d:this.className=d}function f(){if(a=this.classList)return a.add(b);var a=this.className,c=a.baseVal!=null,d=c?a.baseVal:a;e.lastIndex=0,e.test(d)||(d=g(d+" "+b),c?a.baseVal=d:this.className=d)}var e=new RegExp("(^|\\s+)"+d3.requote(b)+"(\\s+|$)","g");return arguments.length<2?d(function(){if(a=this.classList)return a.contains(b);var a=this.className;e.lastIndex=0;return e.test(a.baseVal!=null?a.baseVal:a)}):a.each(typeof c=="function"?i:c?f:h)},a.style=function(b,c,e){function h(){var a=c.apply(this,arguments);a==null?this.style.removeProperty(b):this.style.setProperty(b,a,e)}function g(){this.style.setProperty(b,c,e)}function f(){this.style.removeProperty(b)}arguments.length<3&&(e="");return arguments.length<2?d(function(){return window.getComputedStyle(this,null).getPropertyValue(b)}):a.each(c==null?f:typeof c=="function"?h:g)},a.property=function(b,c){function g(){var a=c.apply(this,arguments);a==null?delete this[b]:this[b]=a}function f(){this[b]=c}function e(){delete this[b]}b=d3.ns.qualify(b);return arguments.length<2?d(function(){return this[b]}):a.each(c==null?e:typeof c=="function"?g:f)},a.text=function(b){function e(){this.textContent=b.apply(this,arguments)}function c(){this.textContent=b}return arguments.length<1?d(function(){return this.textContent}):a.each(typeof b=="function"?e:c)},a.html=function(b){function e(){this.innerHTML=b.apply(this,arguments)}function c(){this.innerHTML=b}return arguments.length<1?d(function(){return this.innerHTML}):a.each(typeof b=="function"?e:c)},a.append=function(a){function d(b){return b.appendChild(document.createElementNS(a.space,a.local))}function c(b){return b.appendChild(document.createElement(a))}a=d3.ns.qualify(a);return b(a.local?d:c)},a.insert=function(a,c){function e(b){return b.insertBefore(document.createElementNS(a.space,a.local),S(c,b))}function d(b){return b.insertBefore(document.createElement(a),S(c,b))}a=d3.ns.qualify(a);return b(a.local?e:d)},a.remove=function(){return a.each(function(){var a=this.parentNode;a&&a.removeChild(this)})},a.sort=function(b){b=X.apply(this,arguments);for(var c=0,d=a.length;c<d;c++){var e=a[c];e.sort(b);for(var f=1,g=e.length,h=e[0];f<g;f++){var i=e[f];i&&(h&&h.parentNode.insertBefore(i,h.nextSibling),h=i)}}return a},a.on=function(b,c,d){arguments.length<3&&(d=!1);var e=b.indexOf("."),f=e===-1?b:b.substring(0,e),g="__on"+b;return a.each(function(a,b){function h(a){var d=d3.event;d3.event=a;try{c.call(this,e.__data__,b)}finally{d3.event=d}}this[g]&&this.removeEventListener(f,this[g],d),c&&this.addEventListener(f,this[g]=h,d);var e=this})},a.transition=function(){return _(a)},a.call=h;return a}function R(a,b,c){function g(a){return Math.round(f(a)*255)}function f(a){a>360?a-=360:a<0&&(a+=360);return a<60?d+(e-d)*a/60:a<180?e:a<240?d+(e-d)*(240-a)/60:d}var d,e;a=a%360,a<0&&(a+=360),b=b<0?0:b>1?1:b,c=c<0?0:c>1?1:c,e=c<=.5?c*(1+b):c+b-c*b,d=2*c-e;return H(g(a+120),g(a),g(a-120))}function Q(a,b,c){this.h=a,this.s=b,this.l=c}function P(a,b,c){return new Q(a,b,c)}function M(a){var b=parseFloat(a);return a.charAt(a.length-1)==="%"?Math.round(b*2.55):b}function L(a,b,c){var d=Math.min(a/=255,b/=255,c/=255),e=Math.max(a,b,c),f=e-d,g,h,i=(e+d)/2;f?(h=i<.5?f/(e+d):f/(2-e-d),a==e?g=(b-c)/f+(b<c?6:0):b==e?g=(c-a)/f+2:g=(a-b)/f+4,g*=60):h=g=0;return P(g,h,i)}function K(a,b,c){var d=0,e=0,f=0,g,h,i;g=/([a-z]+)\((.*)\)/i.exec(a);if(g){h=g[2].split(",");switch(g[1]){case"hsl":return c(parseFloat(h[0]),parseFloat(h[1])/100,parseFloat(h[2])/100);case"rgb":return b(M(h[0]),M(h[1]),M(h[2]))}}if(i=N[a])return b(i.r,i.g,i.b);a!=null&&a.charAt(0)==="#"&&(a.length===4?(d=a.charAt(1),d+=d,e=a.charAt(2),e+=e,f=a.charAt(3),f+=f):a.length===7&&(d=a.substring(1,3),e=a.substring(3,5),f=a.substring(5,7)),d=parseInt(d,16),e=parseInt(e,16),f=parseInt(f,16));return b(d,e,f)}function J(a){return a<16?"0"+a.toString(16):a.toString(16)}function I(a,b,c){this.r=a,this.g=b,this.b=c}function H(a,b,c){return new I(a,b,c)}function G(a,b){b=1/(b-(a=+a));return function(c){return Math.max(0,Math.min(1,(c-a)*b))}}function F(a,b){b=1/(b-(a=+a));return function(c){return(c-a)*b}}function E(a){return a in D||/\bcolor\b/.test(a)?d3.interpolateRgb:d3.interpolate}function B(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375}function A(a){a||(a=1.70158);return function(b){return b*b*((a+1)*b-a)}}function z(a,b){var c;arguments.length<2&&(b=.45),arguments.length<1?(a=1,c=b/4):c=b/(2*Math.PI)*Math.asin(1/a);return function(d){return 1+a*Math.pow(2,10*-d)*Math.sin((d-c)*2*Math.PI/b)}}function y(a){return 1-Math.sqrt(1-a*a)}function x(a){return Math.pow(2,10*(a-1))}function w(a){return 1-Math.cos(a*Math.PI/2)}function v(a){return function(b){return Math.pow(b,a)}}function u(a){return a}function t(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}}function s(a){return function(b){return 1-a(1-b)}}function n(a){var b=a.lastIndexOf("."),c=b>=0?a.substring(b):(b=a.length,""),d=[];while(b>0)d.push(a.substring(b-=3,b+3));return d.reverse().join(",")+c}function m(a){return a+""}function j(a){var b={},c=[];b.add=function(a){for(var d=0;d<c.length;d++)if(c[d].listener==a)return b;c.push({listener:a,on:!0});return b},b.remove=function(a){for(var d=0;d<c.length;d++){var e=c[d];if(e.listener==a){e.on=!1,c=c.slice(0,d).concat(c.slice(d+1));break}}return b},b.dispatch=function(){var a=c;for(var b=0,d=a.length;b<d;b++){var e=a[b];e.on&&e.listener.apply(this,arguments)}};return b}function h(a){a.apply(this,(arguments[0]=this,arguments));return this}function g(a){return a.replace(/(^\s+)|(\s+$)/g,"").replace(/\s+/g," ")}function f(a){return a==null}function e(a){return a.length}function c(a){return Array.prototype.slice.call(a)}function b(a){var b=-1,c=a.length,d=[];while(++b<c)d.push(a[b]);return d}d3={version:"1.29.5"},Date.now||(Date.now=function(){return+(new Date)}),Object.create||(Object.create=function(a){function b(){}b.prototype=a;return new b});var a=c;try{a(document.documentElement.childNodes)[0].nodeType}catch(d){a=b}d3.functor=function(a){return typeof a=="function"?a:function(){return a}},d3.rebind=function(a,b){return function(){var c=b.apply(a,arguments);return arguments.length?a:c}},d3.ascending=function(a,b){return a<b?-1:a>b?1:a>=b?0:NaN},d3.descending=function(a,b){return b<a?-1:b>a?1:b>=a?0:NaN},d3.min=function(a,b){var c=-1,d=a.length,e,f;if(arguments.length===1){while(++c<d&&((e=a[c])==null||e!=e))e=undefined;while(++c<d)(f=a[c])!=null&&e>f&&(e=f)}else{while(++c<d&&((e=b.call(a,a[c],c))==null||e!=e))e=undefined;while(++c<d)(f=b.call(a,a[c],c))!=null&&e>f&&(e=f)}return e},d3.max=function(a,b){var c=-1,d=a.length,e,f;if(arguments.length===1){while(++c<d&&((e=a[c])==null||e!=e))e=undefined;while(++c<d)(f=a[c])!=null&&f>e&&(e=f)}else{while(++c<d&&((e=b.call(a,a[c],c))==null||e!=e))e=undefined;while(++c<d)(f=b.call(a,a[c],c))!=null&&f>e&&(e=f)}return e},d3.sum=function(a,b){var c=0,d=a.length,e,f=-1;if(arguments.length===1)while(++f<d)isNaN(e=+a[f])||(c+=e);else while(++f<d)isNaN(e=+b.call(a,a[f],f))||(c+=e);return c},d3.quantile=function(a,b){var c=(a.length-1)*b+1,d=Math.floor(c),e=a[d-1],f=c-d;return f?e+f*(a[d]-e):e},d3.zip=function(){if(!(f=arguments.length))return[];for(var a=-1,b=d3.min(arguments,e),c=Array(b);++a<b;)for(var d=-1,f,g=c[a]=Array(f);++d<f;)g[d]=arguments[d][a];return c},d3.bisectLeft=function(a,b,c,d){arguments.length<3&&(c=0),arguments.length<4&&(d=a.length);while(c<d){var e=c+d>>1;a[e]<b?c=e+1:d=e}return c},d3.bisect=d3.bisectRight=function(a,b,c,d){arguments.length<3&&(c=0),arguments.length<4&&(d=a.length);while(c<d){var e=c+d>>1;b<a[e]?d=e:c=e+1}return c},d3.first=function(a,b){var c=0,d=a.length,e=a[0],f;arguments.length===1&&(b=d3.ascending);while(++c<d)b.call(a,e,f=a[c])>0&&(e=f);return e},d3.last=function(a,b){var c=0,d=a.length,e=a[0],f;arguments.length===1&&(b=d3.ascending);while(++c<d)b.call(a,e,f=a[c])<=0&&(e=f);return e},d3.nest=function(){function g(a,d){if(d>=b.length)return a;var e=[],f=c[d++],h;for(h in a)e.push({key:h,values:g(a[h],d)});f&&e.sort(function(a,b){return f(a.key,b.key)});return e}function f(c,g){if(g>=b.length)return e?e.call(a,c):d?c.sort(d):c;var h=-1,i=c.length,j=b[g++],k,l,m={};while(++h<i)(k=j(l=c[h]))in m?m[k].push(l):m[k]=[l];for(k in m)m[k]=f(m[k],g);return m}var a={},b=[],c=[],d,e;a.map=function(a){return f(a,0)},a.entries=function(a){return g(f(a,0),0)},a.key=function(c){b.push(c);return a},a.sortKeys=function(d){c[b.length-1]=d;return a},a.sortValues=function(b){d=b;return a},a.rollup=function(b){e=b;return a};return a},d3.keys=function(a){var b=[];for(var c in a)b.push(c);return b},d3.values=function(a){var b=[];for(var c in a)b.push(a[c]);return b},d3.entries=function(a){var b=[];for(var c in a)b.push({key:c,value:a[c]});return b},d3.permute=function(a,b){var c=[],d=-1,e=b.length;while(++d<e)c[d]=a[b[d]];return c},d3.merge=function(a){return Array.prototype.concat.apply([],a)},d3.split=function(a,b){var c=[],d=[],e,g=-1,h=a.length;arguments.length<2&&(b=f);while(++g<h)b.call(d,e=a[g],g)?d=[]:(d.length||c.push(d),d.push(e));return c},d3.range=function(a,b,c){arguments.length<3&&(c=1,arguments.length<2&&(b=a,a=0));if((b-a)/c==Infinity)throw new Error("infinite range");var d=[],e=-1,f;if(c<0)while((f=a+c*++e)>b)d.push(f);else while((f=a+c*++e)<b)d.push(f);return d},d3.requote=function(a){return a.replace(i,"\\$&")};var i=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;d3.round=function(a,b){return b?Math.round(a*Math.pow(10,b))*Math.pow(10,-b):Math.round(a)},d3.xhr=function(a,b,c){var d=new XMLHttpRequest;arguments.length<3?c=b:b&&d.overrideMimeType&&d.overrideMimeType(b),d.open("GET",a,!0),d.onreadystatechange=function(){d.readyState===4&&c(d.status<300?d:null)},d.send(null)},d3.text=function(a,b,c){function d(a){c(a&&a.responseText)}arguments.length<3&&(c=b,b=null),d3.xhr(a,b,d)},d3.json=function(a,b){d3.text(a,"application/json",function(a){b(a?JSON.parse(a):null)})},d3.html=function(a,b){d3.text(a,"text/html",function(a){if(a!=null){var c=document.createRange();c.selectNode(document.body),a=c.createContextualFragment(a)}b(a)})},d3.xml=function(a,b,c){function d(a){c(a&&a.responseXML)}arguments.length<3&&(c=b,b=null),d3.xhr(a,b,d)},d3.ns={prefix:{svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},qualify:function(a){var b=a.indexOf(":");return b<0?a:{space:d3.ns.prefix[a.substring(0,b)],local:a.substring(b+1)}}},d3.dispatch=function(a){var b={},c;for(var d=0,e=arguments.length;d<e;d++)c=arguments[d],b[c]=j(c);return b},d3.format=function(a){var b=k.exec(a),c=b[1]||" ",d=b[3]||"",e=b[5],f=+b[6],g=b[7],h=b[8],i=b[9],j=!1,o=!1;h&&(h=h.substring(1)),e&&(c="0",g&&(f-=Math.floor((f-1)/4)));switch(i){case"n":g=!0,i="g";break;case"%":j=!0,i="f";break;case"p":j=!0,i="r";break;case"d":o=!0,h="0"}i=l[i]||m;return function(a){var b=j?a*100:+a,k=b<0&&(b=-b)?"−":d;if(o&&b%1)return"";a=i(b,h);if(e){var l=a.length+k.length;l<f&&(a=Array(f-l+1).join(c)+a),g&&(a=n(a)),a=k+a}else{g&&(a=n(a)),a=k+a;var l=a.length;l<f&&(a=Array(f-l+1).join(c)+a)}j&&(a+="%");return a}};var k=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,l={g:function(a,b){return a.toPrecision(b)},e:function(a,b){return a.toExponential(b)},f:function(a,b){return a.toFixed(b)},r:function(a,b){var c=1+Math.floor(1e-15+Math.log(a)/Math.LN10);return d3.round(a,b-c).toFixed(Math.max(0,Math.min(20,b-c)))}},o=v(2),p=v(3),q={linear:function(){return u},poly:v,quad:function(){return o},cubic:function(){return p},sin:function(){return w},exp:function(){return x},circle:function(){return y},elastic:z,back:A,bounce:function(){return B}},r={"in":function(a){return a},out:s,"in-out":t,"out-in":function(a){return t(s(a))}};d3.ease=function(a){var b=a.indexOf("-"),c=b>=0?a.substring(0,b):a,d=b>=0?a.substring(b+1):"in";return r[d](q[c].apply(null,Array.prototype.slice.call(arguments,1)))},d3.event=null,d3.interpolate=function(a,b){var c=d3.interpolators.length,d;while(--c>=0&&!(d=d3.interpolators[c](a,b)));return d},d3.interpolateNumber=function(a,b){b-=a;return function(c){return a+b*c}},d3.interpolateRound=function(a,b){b-=a;return function(c){return Math.round(a+b*c)}},d3.interpolateString=function(a,b){var c,d,e,f=0,g=0,h=[],i=[],j,k;C.lastIndex=0;for(d=0;c=C.exec(b);++d)c.index&&h.push(b.substring(f,g=c.index)),i.push({i:h.length,x:c[0]}),h.push(null),f=C.lastIndex;f<b.length&&h.push(b.substring(f));for(d=0,j=i.length;(c=C.exec(a))&&d<j;++d){k=i[d];if(k.x==c[0]){if(k.i)if(h[k.i+1]==null){h[k.i-1]+=k.x,h.splice(k.i,1);for(e=d+1;e<j;++e)i[e].i--}else{h[k.i-1]+=k.x+h[k.i+1],h.splice(k.i,2);for(e=d+1;e<j;++e)i[e].i-=2}else if(h[k.i+1]==null)h[k.i]=k.x;else{h[k.i]=k.x+h[k.i+1],h.splice(k.i+1,1);for(e=d+1;e<j;++e)i[e].i--}i.splice(d,1),j--,d--}else k.x=d3.interpolateNumber(parseFloat(c[0]),parseFloat(k.x))}while(d<j)k=i.pop(),h[k.i+1]==null?h[k.i]=k.x:(h[k.i]=k.x+h[k.i+1],h.splice(k.i+1,1)),j--;return h.length===1?h[0]==null?i[0].x:function(){return b}:function(a){for(d=0;d<j;++d)h[(k=i[d]).i]=k.x(a);return h.join("")}},d3.interpolateRgb=function(a,b){a=d3.rgb(a),b=d3.rgb(b);var c=a.r,d=a.g,e=a.b,f=b.r-c,g=b.g-d,h=b.b-e;return function(a){return"rgb("+Math.round(c+f*a)+","+Math.round(d+g*a)+","+Math.round(e+h*a)+")"}},d3.interpolateHsl=function(a,b){a=d3.hsl(a),b=d3.hsl(b);var c=a.h,d=a.s,e=a.l,f=b.h-c,g=b.s-d,h=b.l-e;return function(a){return R(c+f*a,d+g*a,e+h*a).toString()}},d3.interpolateArray=function(a,b){var c=[],d=[],e=a.length,f=b.length,g=Math.min(a.length,b.length),h;for(h=0;h<g;++h)c.push(d3.interpolate(a[h],b[h]));for(;h<e;++h)d[h]=a[h];for(;h<f;++h)d[h]=b[h];return function(a){for(h=0;h<g;++h)d[h]=c[h](a);return d}},d3.interpolateObject=function(a,b){var c={},d={},e;for(e in a)e in b?c[e]=E(e)(a[e],b[e]):d[e]=a[e];for(e in b)e in a||(d[e]=b[e]);return function(a){for(e in c)d[e]=c[e](a);return d}};var C=/[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g,D={background:1,fill:1,stroke:1};d3.interpolators=[d3.interpolateObject,function(a,b){return b instanceof Array&&d3.interpolateArray(a,b)},function(a,b){return typeof b=="string"&&d3.interpolateString(String(a),b)},function(a,b){return(typeof b=="string"?b in N||/^(#|rgb\(|hsl\()/.test(b):b instanceof I||b instanceof Q)&&d3.interpolateRgb(String(a),b)},function(a,b){return typeof b=="number"&&d3.interpolateNumber(+a,b)}],d3.rgb=function(a,b,c){return arguments.length===1?K(""+a,H,R):H(~~a,~~b,~~c)},I.prototype.brighter=function(a){a=Math.pow(.7,arguments.length?a:1);var b=this.r,c=this.g,d=this.b,e=30;if(!b&&!c&&!d)return H(e,e,e);b&&b<e&&(b=e),c&&c<e&&(c=e),d&&d<e&&(d=e);return H(Math.min(255,Math.floor(b/a)),Math.min(255,Math.floor(c/a)),Math.min(255,Math.floor(d/a)))},I.prototype.darker=function(a){a=Math.pow(.7,arguments.length?a:1);return H(Math.max(0,Math.floor(a*this.r)),Math.max(0,Math.floor(a*this.g)),Math.max(0,Math.floor(a*this.b)))},I.prototype.hsl=function(){return L(this.r,this.g,this.b)},I.prototype.toString=function(){return"#"+J(this.r)+J(this.g)+J(this.b)};var N={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000"
<add>,blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};for(var O in N)N[O]=K(N[O],H,R);d3.hsl=function(a,b,c){return arguments.length===1?K(""+a,L,P):P(+a,+b,+c)},Q.prototype.brighter=function(a){a=Math.pow(.7,arguments.length?a:1);return P(this.h,this.s,this.l/a)},Q.prototype.darker=function(a){a=Math.pow(.7,arguments.length?a:1);return P(this.h,this.s,a*this.l)},Q.prototype.rgb=function(){return R(this.h,this.s,this.l)},Q.prototype.toString=function(){return"hsl("+this.h+","+this.s*100+"%,"+this.l*100+"%)"};var S=function(a,b){return b.querySelector(a)},T=function(b,c){return a(c.querySelectorAll(b))};typeof Sizzle=="function"&&(S=function(a,b){return Sizzle(a,b)[0]},T=function(a,b){return Sizzle.uniqueSort(Sizzle(a,b))});var U=V([[document]]);U[0].parentNode=document.documentElement,d3.select=function(a){return typeof a=="string"?U.select(a):V([[a]])},d3.selectAll=function(b){return typeof b=="string"?U.selectAll(b):V([a(b)])},d3.transition=U.transition;var Z=0,$=0,bb=null,bc,bd;d3.timer=function(a,b){var c=Date.now(),d=!1,e,f=bb;if(arguments.length<2)b=0;else if(!isFinite(b))return;while(f){if(f.callback===a){f.then=c,f.delay=b,d=!0;break}e=f,f=f.next}d||(bb={callback:a,then:c,delay:b,next:bb}),bc||(bd=clearTimeout(bd),bc=1,bg(be))},d3.timer.flush=function(){var a,b=Date.now(),c=bb;while(c)a=b-c.then,c.delay||(c.flush=c.callback(a)),c=c.next;bf()};var bg=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,17)};d3.scale={},d3.scale.linear=function(){return bl([0,1],[0,1],d3.interpolate,!1)},d3.scale.log=function(){return bt(d3.scale.linear(),bu)},bu.pow=function(a){return Math.pow(10,a)},bv.pow=function(a){return-Math.pow(10,-a)},d3.scale.pow=function(){return bx(d3.scale.linear(),1)},d3.scale.sqrt=function(){return d3.scale.pow().exponent(.5)},d3.scale.ordinal=function(){return bz({},0,{t:"range",x:[]})},d3.scale.category10=function(){return d3.scale.ordinal().range(bA)},d3.scale.category20=function(){return d3.scale.ordinal().range(bB)},d3.scale.category20b=function(){return d3.scale.ordinal().range(bC)},d3.scale.category20c=function(){return d3.scale.ordinal().range(bD)};var bA=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],bB=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],bC=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],bD=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];d3.scale.quantile=function(){return bE([],[])},d3.scale.quantize=function(){return bF(0,1,[0,1])},d3.svg={},d3.svg.arc=function(){function e(){var e=a.apply(this,arguments),f=b.apply(this,arguments),g=c.apply(this,arguments)+bG,h=d.apply(this,arguments)+bG,i=(h<g&&(i=g,g=h,h=i),h-g),j=i<Math.PI?"0":"1",k=Math.cos(g),l=Math.sin(g),m=Math.cos(h),n=Math.sin(h);return i>=bH?e?"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+ -f+"A"+f+","+f+" 0 1,1 0,"+f+"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+ -e+"A"+e+","+e+" 0 1,1 0,"+e+"Z":"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+ -f+"A"+f+","+f+" 0 1,1 0,"+f+"Z":e?"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L"+e*m+","+e*n+"A"+e+","+e+" 0 "+j+",0 "+e*k+","+e*l+"Z":"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L0,0"+"Z"}var a=bI,b=bJ,c=bK,d=bL;e.innerRadius=function(b){if(!arguments.length)return a;a=d3.functor(b);return e},e.outerRadius=function(a){if(!arguments.length)return b;b=d3.functor(a);return e},e.startAngle=function(a){if(!arguments.length)return c;c=d3.functor(a);return e},e.endAngle=function(a){if(!arguments.length)return d;d=d3.functor(a);return e},e.centroid=function(){var e=(a.apply(this,arguments)+b.apply(this,arguments))/2,f=(c.apply(this,arguments)+d.apply(this,arguments))/2+bG;return[Math.cos(f)*e,Math.sin(f)*e]};return e};var bG=-Math.PI/2,bH=2*Math.PI-1e-6;d3.svg.line=function(){return bM(Object)};var bQ={linear:bR,"step-before":bS,"step-after":bT,basis:bZ,"basis-open":b$,"basis-closed":b_,bundle:ca,cardinal:bW,"cardinal-open":bU,"cardinal-closed":bV,monotone:cj},cc=[0,2/3,1/3,0],cd=[0,1/3,2/3,0],ce=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var a=bM(ck);a.radius=a.x,delete a.x,a.angle=a.y,delete a.y;return a},d3.svg.area=function(){return cl(Object)},d3.svg.area.radial=function(){var a=cl(ck);a.radius=a.x,delete a.x,a.innerRadius=a.x0,delete a.x0,a.outerRadius=a.x1,delete a.x1,a.angle=a.y,delete a.y,a.startAngle=a.y0,delete a.y0,a.endAngle=a.y1,delete a.y1;return a},d3.svg.chord=function(){function j(a,b,c,d){return"Q 0,0 "+d}function i(a,b){return"A"+a+","+a+" 0 0,1 "+b}function h(a,b){return a.a0==b.a0&&a.a1==b.a1}function g(a,b,f,g){var h=b.call(a,f,g),i=c.call(a,h,g),j=d.call(a,h,g)+bG,k=e.call(a,h,g)+bG;return{r:i,a0:j,a1:k,p0:[i*Math.cos(j),i*Math.sin(j)],p1:[i*Math.cos(k),i*Math.sin(k)]}}function f(c,d){var e=g(this,a,c,d),f=g(this,b,c,d);return"M"+e.p0+i(e.r,e.p1)+(h(e,f)?j(e.r,e.p1,e.r,e.p0):j(e.r,e.p1,f.r,f.p0)+i(f.r,f.p1)+j(f.r,f.p1,e.r,e.p0))+"Z"}var a=co,b=cp,c=cq,d=bK,e=bL;f.radius=function(a){if(!arguments.length)return c;c=d3.functor(a);return f},f.source=function(b){if(!arguments.length)return a;a=d3.functor(b);return f},f.target=function(a){if(!arguments.length)return b;b=d3.functor(a);return f},f.startAngle=function(a){if(!arguments.length)return d;d=d3.functor(a);return f},f.endAngle=function(a){if(!arguments.length)return e;e=d3.functor(a);return f};return f},d3.svg.diagonal=function(){function d(d,e){var f=a.call(this,d,e),g=b.call(this,d,e),h=(f.y+g.y)/2,i=[f,{x:f.x,y:h},{x:g.x,y:h},g];i=i.map(c);return"M"+i[0]+"C"+i[1]+" "+i[2]+" "+i[3]}var a=co,b=cp,c=ct;d.source=function(b){if(!arguments.length)return a;a=d3.functor(b);return d},d.target=function(a){if(!arguments.length)return b;b=d3.functor(a);return d},d.projection=function(a){if(!arguments.length)return c;c=a;return d};return d},d3.svg.diagonal.radial=function(){var a=d3.svg.diagonal(),b=ct,c=a.projection;a.projection=function(a){return arguments.length?c(cu(b=a)):b};return a},d3.svg.mouse=function(a){return cw(a,d3.event)};var cv=/WebKit/.test(navigator.userAgent)?-1:0;d3.svg.touches=function(b){var c=d3.event.touches;return c?a(c).map(function(a){var c=cw(b,a);c.identifier=a.identifier;return c}):[]},d3.svg.symbol=function(){function c(c,d){return(cz[a.call(this,c,d)]||cz.circle)(b.call(this,c,d))}var a=cy,b=cx;c.type=function(b){if(!arguments.length)return a;a=d3.functor(b);return c},c.size=function(a){if(!arguments.length)return b;b=d3.functor(a);return c};return c};var cz={circle:function(a){var b=Math.sqrt(a/Math.PI);return"M0,"+b+"A"+b+","+b+" 0 1,1 0,"+ -b+"A"+b+","+b+" 0 1,1 0,"+b+"Z"},cross:function(a){var b=Math.sqrt(a/5)/2;return"M"+ -3*b+","+ -b+"H"+ -b+"V"+ -3*b+"H"+b+"V"+ -b+"H"+3*b+"V"+b+"H"+b+"V"+3*b+"H"+ -b+"V"+b+"H"+ -3*b+"Z"},diamond:function(a){var b=Math.sqrt(a/(2*cB)),c=b*cB;return"M0,"+ -b+"L"+c+",0"+" 0,"+b+" "+ -c+",0"+"Z"},square:function(a){var b=Math.sqrt(a)/2;return"M"+ -b+","+ -b+"L"+b+","+ -b+" "+b+","+b+" "+ -b+","+b+"Z"},"triangle-down":function(a){var b=Math.sqrt(a/cA),c=b*cA/2;return"M0,"+c+"L"+b+","+ -c+" "+ -b+","+ -c+"Z"},"triangle-up":function(a){var b=Math.sqrt(a/cA),c=b*cA/2;return"M0,"+ -c+"L"+b+","+c+" "+ -b+","+c+"Z"}};d3.svg.symbolTypes=d3.keys(cz);var cA=Math.sqrt(3),cB=Math.tan(30*Math.PI/180)})()
<ide>\ No newline at end of file
<ide><path>src/scale/ordinal.js
<ide> d3.scale.ordinal = function() {
<del> return d3_scale_ordinal({}, 0, d3_noop);
<add> return d3_scale_ordinal({}, 0, {t: "range", x: []});
<ide> };
<ide>
<del>function d3_scale_ordinal(domain, size, rerange) {
<del> var range = [],
<del> rangeBand = 0;
<add>function d3_scale_ordinal(domain, size, ranger) {
<add> var range,
<add> rangeBand;
<ide>
<ide> function scale(x) {
<ide> return range[((domain[x] || (domain[x] = ++size)) - 1) % range.length];
<ide> function d3_scale_ordinal(domain, size, rerange) {
<ide> size = 0;
<ide> var i = -1, n = x.length, xi;
<ide> while (++i < n) if (!domain[xi = x[i]]) domain[xi] = ++size;
<del> rerange();
<del> return scale;
<add> return scale[ranger.t](ranger.x, ranger.p);
<ide> };
<ide>
<ide> scale.range = function(x) {
<ide> if (!arguments.length) return range;
<ide> range = x;
<ide> rangeBand = 0;
<del> rerange = d3_noop;
<add> ranger = {t: "range", x: x};
<ide> return scale;
<ide> };
<ide>
<ide> scale.rangePoints = function(x, padding) {
<ide> if (arguments.length < 2) padding = 0;
<del> var start = x[0], stop = x[1];
<del> (rerange = function() {
<del> var step = (stop - start) / (size - 1 + padding);
<del> range = size < 2
<del> ? [(start + stop) / 2]
<del> : d3.range(start + step * padding / 2, stop + step / 2, step);
<del> rangeBand = 0;
<del> })();
<add> var start = x[0],
<add> stop = x[1],
<add> step = (stop - start) / (size - 1 + padding);
<add> range = size < 2 ? [(start + stop) / 2] : d3.range(start + step * padding / 2, stop + step / 2, step);
<add> rangeBand = 0;
<add> ranger = {t: "rangePoints", x: x, p: padding};
<ide> return scale;
<ide> };
<ide>
<ide> scale.rangeBands = function(x, padding) {
<ide> if (arguments.length < 2) padding = 0;
<del> var start = x[0], stop = x[1];
<del> (rerange = function() {
<del> var step = (stop - start) / (size + padding);
<del> range = d3.range(start + step * padding, stop, step);
<del> rangeBand = step * (1 - padding);
<del> })();
<add> var start = x[0],
<add> stop = x[1],
<add> step = (stop - start) / (size + padding);
<add> range = d3.range(start + step * padding, stop, step);
<add> rangeBand = step * (1 - padding);
<add> ranger = {t: "rangeBands", x: x, p: padding};
<ide> return scale;
<ide> };
<ide>
<ide> scale.rangeRoundBands = function(x, padding) {
<ide> if (arguments.length < 2) padding = 0;
<del> var start = x[0], stop = x[1];
<del> (rerange = function() {
<del> var step = Math.floor((stop - start) / (size + padding)),
<del> err = stop - start - (size - padding) * step;
<del> range = d3.range(start + Math.round(err / 2), stop, step);
<del> rangeBand = Math.round(step * (1 - padding));
<del> })();
<add> var start = x[0],
<add> stop = x[1],
<add> step = Math.floor((stop - start) / (size + padding)),
<add> err = stop - start - (size - padding) * step;
<add> range = d3.range(start + Math.round(err / 2), stop, step);
<add> rangeBand = Math.round(step * (1 - padding));
<add> ranger = {t: "rangeRoundBands", x: x, p: padding};
<ide> return scale;
<ide> };
<ide>
<ide> function d3_scale_ordinal(domain, size, rerange) {
<ide> scale.copy = function() {
<ide> var copy = {}, x;
<ide> for (x in domain) copy[x] = domain[x];
<del> return d3_scale_ordinal(copy, size, rerange);
<add> return d3_scale_ordinal(copy, size, ranger);
<ide> };
<ide>
<del> rerange();
<del> return scale;
<add> return scale[ranger.t](ranger.x, ranger.p);
<ide> };
<ide><path>test/env-assert.js
<ide> var assert = require("assert");
<ide>
<del>assert.inDelta = function (actual, expected, delta, message) {
<del> var lower = expected - delta;
<del> var upper = expected + delta;
<del> if (actual != +actual || actual < lower || actual > upper) {
<del> assert.fail(actual, expected, message || "expected {actual} to be in within *" + delta.toString() + "* of {expected}", null, assert.inDelta);
<add>assert.inDelta = function(actual, expected, delta, message) {
<add> if (!inDelta(actual, expected, delta)) {
<add> assert.fail(actual, expected, message || "expected {actual} to be in within *" + delta + "* of {expected}", null, assert.inDelta);
<ide> }
<ide> };
<ide>
<ide> assert.pathEqual = function(actual, expected, message) {
<ide> }
<ide> };
<ide>
<add>function inDelta(actual, expected, delta) {
<add> return (Array.isArray(expected) ? inDeltaArray : inDeltaNumber)(actual, expected, delta);
<add>}
<add>
<add>function inDeltaArray(actual, expected, delta) {
<add> var n = expected.length, i = -1;
<add> if (actual.length !== n) return false;
<add> while (++i < n) if (!inDelta(actual[i], expected[i], delta)) return false;
<add> return true;
<add>}
<add>
<add>function inDeltaNumber(actual, expected, delta) {
<add> return actual >= expected - delta && actual <= expected + delta;
<add>}
<add>
<ide> function pathEqual(a, b) {
<ide> a = parsePath(a);
<ide> b = parsePath(b);
<ide> function parsePath(path) {
<ide> }
<ide>
<ide> function formatPath(path) {
<del> return path.replace(reNumber, function(s) {
<del> return Math.abs((s = +s) - Math.floor(s)) < 1e-6 ? Math.floor(s) : s.toFixed(6);
<del> });
<add> return path.replace(reNumber, formatNumber);
<add>}
<add>
<add>function formatNumber(s) {
<add> return Math.abs((s = +s) - Math.floor(s)) < 1e-6 ? Math.floor(s) : s.toFixed(6);
<ide> }
<ide><path>test/scale/category-test.js
<ide> suite.addBatch({
<ide> function category(category, n) {
<ide> return {
<ide> "is an ordinal scale": function() {
<del> var x = category();
<add> var x = category(), colors = x.range();
<ide> assert.length(x.domain(), 0);
<ide> assert.length(x.range(), n);
<add> assert.equal(x(1), colors[0]);
<add> assert.equal(x(2), colors[1]);
<add> assert.equal(x(1), colors[0]);
<add> var y = x.copy();
<add> assert.deepEqual(y.domain(), x.domain());
<add> assert.deepEqual(y.range(), x.range());
<add> x.domain(d3.range(n));
<add> for (var i = 0; i < n; ++i) assert.equal(x(i + n), x(i));
<add> assert.equal(y(1), colors[0]);
<add> assert.equal(y(2), colors[1]);
<ide> },
<ide> "each instance is isolated": function() {
<ide> var a = category(), b = category(), colors = a.range();
<ide> function category(category, n) {
<ide> assert.equal(b(1), colors[1]);
<ide> assert.equal(a(1), colors[0]);
<ide> },
<del> "discrete domain values are remembered": function() {
<del> var x = category(), colors = x.range();
<del> assert.equal(x(1), colors[0]);
<del> assert.equal(x(2), colors[1]);
<del> assert.equal(x(1), colors[0]);
<del> },
<del> "recycles range values when exhausted": function() {
<del> var x = category();
<del> for (var i = 0; i < n; ++i) x(i);
<del> for (; i < 2 * n; ++i) assert.equal(x(i), x(i - n));
<del> },
<ide> "contains the expected number of values in the range": function() {
<ide> var x = category();
<ide> assert.length(x.range(), n);
<ide><path>test/scale/linear-test.js
<ide> suite.addBatch({
<ide> topic: function() {
<ide> return d3.scale.linear;
<ide> },
<del> "has the default domain [0, 1]": function(linear) {
<del> var x = linear();
<del> assert.deepEqual(x.domain(), [0, 1]);
<del> assert.inDelta(x(.5), .5, 1e-6);
<add>
<add> "domain": {
<add> "defaults to [0, 1]": function(linear) {
<add> var x = linear();
<add> assert.deepEqual(x.domain(), [0, 1]);
<add> assert.inDelta(x(.5), .5, 1e-6);
<add> },
<add> "coerces domain values to numbers": function(linear) {
<add> var x = linear().domain([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<add> assert.equal(typeof x.domain()[0], "number");
<add> assert.equal(typeof x.domain()[1], "number");
<add> assert.inDelta(x(new Date(1989, 09, 20)), -.2, 1e-2);
<add> assert.inDelta(x(new Date(1990, 00, 01)), 0, 1e-2);
<add> assert.inDelta(x(new Date(1990, 02, 15)), .2, 1e-2);
<add> assert.inDelta(x(new Date(1990, 04, 27)), .4, 1e-2);
<add> assert.inDelta(x(new Date(1991, 00, 01)), 1, 1e-2);
<add> assert.inDelta(x(new Date(1991, 02, 15)), 1.2, 1e-2);
<add> var x = linear().domain(["0", "1"]);
<add> assert.equal(typeof x.domain()[0], "number");
<add> assert.equal(typeof x.domain()[1], "number");
<add> assert.inDelta(x(.5), .5, 1e-6);
<add> var x = linear().domain([new Number(0), new Number(1)]);
<add> assert.equal(typeof x.domain()[0], "number");
<add> assert.equal(typeof x.domain()[1], "number");
<add> assert.inDelta(x(.5), .5, 1e-6);
<add> },
<add> "can specify a polylinear domain and range": function(linear) {
<add> var x = linear().domain([-10, 0, 100]).range(["red", "white", "green"]);
<add> assert.equal(x(-5), "rgb(255,128,128)");
<add> assert.equal(x(50), "rgb(128,192,128)");
<add> assert.equal(x(75), "rgb(64,160,64)");
<add> }
<ide> },
<del> "has the default range [0, 1]": function(linear) {
<del> var x = linear();
<del> assert.deepEqual(x.range(), [0, 1]);
<del> assert.inDelta(x.invert(.5), .5, 1e-6);
<add>
<add> "range": {
<add> "defaults to [0, 1]": function(linear) {
<add> var x = linear();
<add> assert.deepEqual(x.range(), [0, 1]);
<add> assert.inDelta(x.invert(.5), .5, 1e-6);
<add> },
<add> "does not coerce range to numbers": function(linear) {
<add> var x = linear().range(["0", "2"]);
<add> assert.equal(typeof x.range()[0], "string");
<add> assert.equal(typeof x.range()[1], "string");
<add> },
<add> "can specify range values as colors": function(linear) {
<add> var x = linear().range(["red", "blue"]);
<add> assert.equal(x(.5), "rgb(128,0,128)");
<add> var x = linear().range(["#ff0000", "#0000ff"]);
<add> assert.equal(x(.5), "rgb(128,0,128)");
<add> var x = linear().range(["#f00", "#00f"]);
<add> assert.equal(x(.5), "rgb(128,0,128)");
<add> var x = linear().range([d3.rgb(255,0,0), d3.hsl(240,1,.5)]);
<add> assert.equal(x(.5), "rgb(128,0,128)");
<add> var x = linear().range(["hsl(0,100%,50%)", "hsl(240,100%,50%)"]);
<add> assert.equal(x(.5), "rgb(128,0,128)");
<add> },
<add> "can specify range values as arrays or objects": function(linear) {
<add> var x = linear().range([{color: "red"}, {color: "blue"}]);
<add> assert.deepEqual(x(.5), {color: "rgb(128,0,128)"});
<add> var x = linear().range([["red"], ["blue"]]);
<add> assert.deepEqual(x(.5), ["rgb(128,0,128)"]);
<add> }
<ide> },
<del> "has the default interpolator d3.interpolate": function(linear) {
<del> var x = linear().range(["red", "blue"]);
<del> assert.equal(x.interpolate(), d3.interpolate);
<del> assert.equal(x(.5), "rgb(128,0,128)");
<add>
<add> "interpolate": {
<add> "defaults to d3.interpolate": function(linear) {
<add> var x = linear().range(["red", "blue"]);
<add> assert.equal(x.interpolate(), d3.interpolate);
<add> assert.equal(x(.5), "rgb(128,0,128)");
<add> },
<add> "can specify a custom interpolator": function(linear) {
<add> var x = linear().range(["red", "blue"]).interpolate(d3.interpolateHsl);
<add> assert.equal(x(.5), "#00ff00");
<add> }
<ide> },
<del> "does not clamp by default": function(linear) {
<del> var x = linear();
<del> assert.isFalse(x.clamp());
<del> assert.inDelta(x(-.5), -.5, 1e-6);
<del> assert.inDelta(x(1.5), 1.5, 1e-6);
<add>
<add> "clamp": {
<add> "defaults to false": function(linear) {
<add> var x = linear();
<add> assert.isFalse(x.clamp());
<add> assert.inDelta(x(-.5), -.5, 1e-6);
<add> assert.inDelta(x(1.5), 1.5, 1e-6);
<add> },
<add> "can clamp to the domain": function(linear) {
<add> var x = linear().clamp(true);
<add> assert.inDelta(x(-.5), 0, 1e-6);
<add> assert.inDelta(x(.5), .5, 1e-6);
<add> assert.inDelta(x(1.5), 1, 1e-6);
<add> var x = linear().domain([1, 0]).clamp(true);
<add> assert.inDelta(x(-.5), 1, 1e-6);
<add> assert.inDelta(x(.5), .5, 1e-6);
<add> assert.inDelta(x(1.5), 0, 1e-6);
<add> }
<ide> },
<add>
<ide> "maps a number to a number": function(linear) {
<ide> var x = linear().domain([1, 2]);
<ide> assert.inDelta(x(.5), -.5, 1e-6);
<ide> suite.addBatch({
<ide> assert.inDelta(x(2), 1, 1e-6);
<ide> assert.inDelta(x(2.5), 1.5, 1e-6);
<ide> },
<del> "coerces domain to numbers": function(linear) {
<del> var x = linear().domain([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<del> assert.equal(typeof x.domain()[0], "number");
<del> assert.equal(typeof x.domain()[1], "number");
<del> assert.inDelta(x(new Date(1989, 09, 20)), -.2, 1e-2);
<del> assert.inDelta(x(new Date(1990, 00, 01)), 0, 1e-2);
<del> assert.inDelta(x(new Date(1990, 02, 15)), .2, 1e-2);
<del> assert.inDelta(x(new Date(1990, 04, 27)), .4, 1e-2);
<del> assert.inDelta(x(new Date(1991, 00, 01)), 1, 1e-2);
<del> assert.inDelta(x(new Date(1991, 02, 15)), 1.2, 1e-2);
<del> var x = linear().domain(["0", "1"]);
<del> assert.equal(typeof x.domain()[0], "number");
<del> assert.equal(typeof x.domain()[1], "number");
<del> assert.inDelta(x(.5), .5, 1e-6);
<del> var x = linear().domain([new Number(0), new Number(1)]);
<del> assert.equal(typeof x.domain()[0], "number");
<del> assert.equal(typeof x.domain()[1], "number");
<del> assert.inDelta(x(.5), .5, 1e-6);
<del> },
<del> "does not coerce range to numbers": function(linear) {
<del> var x = linear().range(["0", "2"]);
<del> assert.equal(typeof x.range()[0], "string");
<del> assert.equal(typeof x.range()[1], "string");
<del> },
<del> "coerces range value to number on invert": function(linear) {
<del> var x = linear().range(["0", "2"]);
<del> assert.inDelta(x.invert("1"), .5, 1e-6);
<del> var x = linear().range([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<del> assert.inDelta(x.invert(new Date(1990, 6, 2, 13)), .5, 1e-6);
<del> var x = linear().range(["#000", "#fff"]);
<del> assert.isNaN(x.invert("#999"));
<del> },
<del> "can specify range values as colors": function(linear) {
<del> var x = linear().range(["red", "blue"]);
<del> assert.equal(x(.5), "rgb(128,0,128)");
<del> var x = linear().range(["#ff0000", "#0000ff"]);
<del> assert.equal(x(.5), "rgb(128,0,128)");
<del> var x = linear().range(["#f00", "#00f"]);
<del> assert.equal(x(.5), "rgb(128,0,128)");
<del> var x = linear().range([d3.rgb(255,0,0), d3.hsl(240,1,.5)]);
<del> assert.equal(x(.5), "rgb(128,0,128)");
<del> var x = linear().range(["hsl(0,100%,50%)", "hsl(240,100%,50%)"]);
<del> assert.equal(x(.5), "rgb(128,0,128)");
<del> },
<del> "can specify range values as arrays or objects": function(linear) {
<del> var x = linear().range([{color: "red"}, {color: "blue"}]);
<del> assert.deepEqual(x(.5), {color: "rgb(128,0,128)"});
<del> var x = linear().range([["red"], ["blue"]]);
<del> assert.deepEqual(x(.5), ["rgb(128,0,128)"]);
<del> },
<del> "can specify a custom interpolator": function(linear) {
<del> var x = linear().range(["red", "blue"]).interpolate(d3.interpolateHsl);
<del> assert.equal(x(.5), "#00ff00");
<del> },
<del> "can clamp to the domain": function(linear) {
<del> var x = linear().clamp(true);
<del> assert.inDelta(x(-.5), 0, 1e-6);
<del> assert.inDelta(x(.5), .5, 1e-6);
<del> assert.inDelta(x(1.5), 1, 1e-6);
<del> var x = linear().domain([1, 0]).clamp(true);
<del> assert.inDelta(x(-.5), 1, 1e-6);
<del> assert.inDelta(x(.5), .5, 1e-6);
<del> assert.inDelta(x(1.5), 0, 1e-6);
<del> },
<del> "can generate ticks of varying degree": function(linear) {
<del> var x = linear();
<del> assert.deepEqual(x.ticks(1).map(x.tickFormat(1)), [0, 1]);
<del> assert.deepEqual(x.ticks(2).map(x.tickFormat(2)), [0, .5, 1]);
<del> assert.deepEqual(x.ticks(5).map(x.tickFormat(5)), [0, .2, .4, .6, .8, 1]);
<del> assert.deepEqual(x.ticks(10).map(x.tickFormat(10)), [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1]);
<del> var x = linear().domain([1, 0]);
<del> assert.deepEqual(x.ticks(1).map(x.tickFormat(1)), [0, 1]);
<del> assert.deepEqual(x.ticks(2).map(x.tickFormat(2)), [0, .5, 1]);
<del> assert.deepEqual(x.ticks(5).map(x.tickFormat(5)), [0, .2, .4, .6, .8, 1]);
<del> assert.deepEqual(x.ticks(10).map(x.tickFormat(10)), [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1]);
<add>
<add> "invert": {
<add> "maps a number to a number": function(linear) {
<add> var x = linear().range([1, 2]);
<add> assert.inDelta(x.invert(.5), -.5, 1e-6);
<add> assert.inDelta(x.invert(1), 0, 1e-6);
<add> assert.inDelta(x.invert(1.5), .5, 1e-6);
<add> assert.inDelta(x.invert(2), 1, 1e-6);
<add> assert.inDelta(x.invert(2.5), 1.5, 1e-6);
<add> },
<add> "coerces range value to numbers": function(linear) {
<add> var x = linear().range(["0", "2"]);
<add> assert.inDelta(x.invert("1"), .5, 1e-6);
<add> var x = linear().range([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<add> assert.inDelta(x.invert(new Date(1990, 6, 2, 13)), .5, 1e-6);
<add> var x = linear().range(["#000", "#fff"]);
<add> assert.isNaN(x.invert("#999"));
<add> }
<ide> },
<del> "can nice the domain, extending it to round numbers": function(linear) {
<del> var x = linear().domain([1.1, 10.9]).nice();
<del> assert.deepEqual(x.domain(), [1, 11]);
<del> var x = linear().domain([10.9, 1.1]).nice();
<del> assert.deepEqual(x.domain(), [11, 1]);
<del> var x = linear().domain([.7, 11.001]).nice();
<del> assert.deepEqual(x.domain(), [0, 12]);
<del> var x = linear().domain([123.1, 6.7]).nice();
<del> assert.deepEqual(x.domain(), [130, 0]);
<del> var x = linear().domain([0, .49]).nice();
<del> assert.deepEqual(x.domain(), [0, .5]);
<add>
<add> "ticks": {
<add> "generates ticks of varying degree": function(linear) {
<add> var x = linear();
<add> assert.deepEqual(x.ticks(1).map(x.tickFormat(1)), [0, 1]);
<add> assert.deepEqual(x.ticks(2).map(x.tickFormat(2)), [0, .5, 1]);
<add> assert.deepEqual(x.ticks(5).map(x.tickFormat(5)), [0, .2, .4, .6, .8, 1]);
<add> assert.deepEqual(x.ticks(10).map(x.tickFormat(10)), [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1]);
<add> var x = linear().domain([1, 0]);
<add> assert.deepEqual(x.ticks(1).map(x.tickFormat(1)), [0, 1]);
<add> assert.deepEqual(x.ticks(2).map(x.tickFormat(2)), [0, .5, 1]);
<add> assert.deepEqual(x.ticks(5).map(x.tickFormat(5)), [0, .2, .4, .6, .8, 1]);
<add> assert.deepEqual(x.ticks(10).map(x.tickFormat(10)), [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1]);
<add> },
<add> "formats ticks with the appropriate precision": function(linear) {
<add> var x = linear().domain([.123456789, 1.23456789]);
<add> assert.strictEqual(x.tickFormat(1)(x.ticks(1)[0]), "1");
<add> assert.strictEqual(x.tickFormat(2)(x.ticks(2)[0]), "0.5");
<add> assert.strictEqual(x.tickFormat(4)(x.ticks(4)[0]), "0.2");
<add> assert.strictEqual(x.tickFormat(8)(x.ticks(8)[0]), "0.2");
<add> assert.strictEqual(x.tickFormat(16)(x.ticks(16)[0]), "0.2");
<add> assert.strictEqual(x.tickFormat(32)(x.ticks(32)[0]), "0.15");
<add> assert.strictEqual(x.tickFormat(64)(x.ticks(64)[0]), "0.14");
<add> assert.strictEqual(x.tickFormat(128)(x.ticks(128)[0]), "0.13");
<add> assert.strictEqual(x.tickFormat(256)(x.ticks(256)[0]), "0.125");
<add> }
<ide> },
<del> "can specify a polylinear domain and range": function(linear) {
<del> var x = linear().domain([-10, 0, 100]).range(["red", "white", "green"]);
<del> assert.equal(x(-5), "rgb(255,128,128)");
<del> assert.equal(x(50), "rgb(128,192,128)");
<del> assert.equal(x(75), "rgb(64,160,64)");
<add>
<add> "nice": {
<add> "nices the domain, extending it to round numbers": function(linear) {
<add> var x = linear().domain([1.1, 10.9]).nice();
<add> assert.deepEqual(x.domain(), [1, 11]);
<add> var x = linear().domain([10.9, 1.1]).nice();
<add> assert.deepEqual(x.domain(), [11, 1]);
<add> var x = linear().domain([.7, 11.001]).nice();
<add> assert.deepEqual(x.domain(), [0, 12]);
<add> var x = linear().domain([123.1, 6.7]).nice();
<add> assert.deepEqual(x.domain(), [130, 0]);
<add> var x = linear().domain([0, .49]).nice();
<add> assert.deepEqual(x.domain(), [0, .5]);
<add> },
<add> "nicing a polylinear domain only affects the extent": function(linear) {
<add> var x = linear().domain([1.1, 1, 2, 3, 10.9]).nice();
<add> assert.deepEqual(x.domain(), [1, 1, 2, 3, 11]);
<add> var x = linear().domain([123.1, 1, 2, 3, -.9]).nice();
<add> assert.deepEqual(x.domain(), [130, 1, 2, 3, -10]);
<add> }
<ide> },
<del> "nicing a polylinear domain only affects the extent": function(linear) {
<del> var x = linear().domain([1.1, 1, 2, 3, 10.9]).nice();
<del> assert.deepEqual(x.domain(), [1, 1, 2, 3, 11]);
<del> var x = linear().domain([123.1, 1, 2, 3, -.9]).nice();
<del> assert.deepEqual(x.domain(), [130, 1, 2, 3, -10]);
<add>
<add> "copy": {
<add> "changes to the domain are isolated": function(linear) {
<add> var x = linear(), y = x.copy();
<add> x.domain([1, 2]);
<add> assert.deepEqual(y.domain(), [0, 1]);
<add> assert.equal(x(1), 0);
<add> assert.equal(y(1), 1);
<add> y.domain([2, 3]);
<add> assert.equal(x(2), 1);
<add> assert.equal(y(2), 0);
<add> assert.deepEqual(x.domain(), [1, 2]);
<add> assert.deepEqual(y.domain(), [2, 3]);
<add> },
<add> "changes to the range are isolated": function(linear) {
<add> var x = linear(), y = x.copy();
<add> x.range([1, 2]);
<add> assert.equal(x.invert(1), 0);
<add> assert.equal(y.invert(1), 1);
<add> assert.deepEqual(y.range(), [0, 1]);
<add> y.range([2, 3]);
<add> assert.equal(x.invert(2), 1);
<add> assert.equal(y.invert(2), 0);
<add> assert.deepEqual(x.range(), [1, 2]);
<add> assert.deepEqual(y.range(), [2, 3]);
<add> },
<add> "changes to the interpolator are isolated": function(linear) {
<add> var x = linear().range(["red", "blue"]), y = x.copy();
<add> x.interpolate(d3.interpolateHsl);
<add> assert.equal(x(0.5), "#00ff00");
<add> assert.equal(y(0.5), "rgb(128,0,128)");
<add> assert.equal(y.interpolate(), d3.interpolate);
<add> },
<add> "changes to clamping are isolated": function(linear) {
<add> var x = linear().clamp(true), y = x.copy();
<add> x.clamp(false);
<add> assert.equal(x(2), 2);
<add> assert.equal(y(2), 1);
<add> assert.isTrue(y.clamp());
<add> y.clamp(false);
<add> assert.equal(x(2), 2);
<add> assert.equal(y(2), 2);
<add> assert.isFalse(x.clamp());
<add> }
<ide> }
<ide> }
<ide> });
<ide><path>test/scale/log-test.js
<ide> suite.addBatch({
<ide> topic: function() {
<ide> return d3.scale.log;
<ide> },
<del> "has the default domain [1, 10]": function(log) {
<del> var x = log();
<del> assert.deepEqual(x.domain(), [1, 10]);
<del> assert.inDelta(x(5), 0.69897, 1e-6);
<add>
<add> "domain": {
<add> "defaults to [1, 10]": function(log) {
<add> var x = log();
<add> assert.deepEqual(x.domain(), [1, 10]);
<add> assert.inDelta(x(5), 0.69897, 1e-6);
<add> },
<add> "coerces domain values to numbers": function(log) {
<add> var x = log().domain([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<add> assert.equal(typeof x.domain()[0], "number");
<add> assert.equal(typeof x.domain()[1], "number");
<add> assert.inDelta(x(new Date(1989, 09, 20)), -.2, 1e-2);
<add> assert.inDelta(x(new Date(1990, 00, 01)), 0, 1e-2);
<add> assert.inDelta(x(new Date(1990, 02, 15)), .2, 1e-2);
<add> assert.inDelta(x(new Date(1990, 04, 27)), .4, 1e-2);
<add> assert.inDelta(x(new Date(1991, 00, 01)), 1, 1e-2);
<add> assert.inDelta(x(new Date(1991, 02, 15)), 1.2, 1e-2);
<add> var x = log().domain(["1", "10"]);
<add> assert.equal(typeof x.domain()[0], "number");
<add> assert.equal(typeof x.domain()[1], "number");
<add> assert.inDelta(x(5), 0.69897, 1e-6);
<add> var x = log().domain([new Number(1), new Number(10)]);
<add> assert.equal(typeof x.domain()[0], "number");
<add> assert.equal(typeof x.domain()[1], "number");
<add> assert.inDelta(x(5), 0.69897, 1e-6);
<add> },
<add> "can specify negative domain values": function(log) {
<add> var x = log().domain([-100, -1]);
<add> assert.deepEqual(x.ticks().map(x.tickFormat()), [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]);
<add> assert.inDelta(x(-50), 0.150515, 1e-6);
<add> },
<add> "can specify a polylog domain and range": function(log) {
<add> var x = log().domain([.1, 1, 100]).range(["red", "white", "green"]);
<add> assert.equal(x(.5), "rgb(255,178,178)");
<add> assert.equal(x(50), "rgb(38,147,38)");
<add> assert.equal(x(75), "rgb(16,136,16)");
<add> }
<ide> },
<del> "has the default range [0, 1]": function(log) {
<del> var x = log();
<del> assert.deepEqual(x.range(), [0, 1]);
<del> assert.inDelta(x.invert(.5), 3.162278, 1e-6);
<add>
<add> "range": {
<add> "defaults to [0, 1]": function(log) {
<add> var x = log();
<add> assert.deepEqual(x.range(), [0, 1]);
<add> assert.inDelta(x.invert(.5), 3.162278, 1e-6);
<add> },
<add> "does not coerce range to numbers": function(log) {
<add> var x = log().range(["0", "2"]);
<add> assert.equal(typeof x.range()[0], "string");
<add> assert.equal(typeof x.range()[1], "string");
<add> },
<add> "can specify range values as colors": function(log) {
<add> var x = log().range(["red", "blue"]);
<add> assert.equal(x(5), "rgb(77,0,178)");
<add> var x = log().range(["#ff0000", "#0000ff"]);
<add> assert.equal(x(5), "rgb(77,0,178)");
<add> var x = log().range(["#f00", "#00f"]);
<add> assert.equal(x(5), "rgb(77,0,178)");
<add> var x = log().range([d3.rgb(255,0,0), d3.hsl(240,1,.5)]);
<add> assert.equal(x(5), "rgb(77,0,178)");
<add> var x = log().range(["hsl(0,100%,50%)", "hsl(240,100%,50%)"]);
<add> assert.equal(x(5), "rgb(77,0,178)");
<add> },
<add> "can specify range values as arrays or objects": function(log) {
<add> var x = log().range([{color: "red"}, {color: "blue"}]);
<add> assert.deepEqual(x(5), {color: "rgb(77,0,178)"});
<add> var x = log().range([["red"], ["blue"]]);
<add> assert.deepEqual(x(5), ["rgb(77,0,178)"]);
<add> }
<ide> },
<del> "has the default interpolator d3.interpolate": function(log) {
<del> var x = log().range(["red", "blue"]);
<del> assert.equal(x.interpolate(), d3.interpolate);
<del> assert.equal(x(5), "rgb(77,0,178)");
<add>
<add> "interpolate": {
<add> "defaults to d3.interpolate": function(log) {
<add> var x = log().range(["red", "blue"]);
<add> assert.equal(x.interpolate(), d3.interpolate);
<add> assert.equal(x(5), "rgb(77,0,178)");
<add> },
<add> "can specify a custom interpolator": function(log) {
<add> var x = log().range(["red", "blue"]).interpolate(d3.interpolateHsl);
<add> assert.equal(x(5), "#00ffcb");
<add> }
<ide> },
<del> "does not clamp by default": function(log) {
<del> var x = log();
<del> assert.isFalse(x.clamp());
<del> assert.inDelta(x(.5), -0.3010299, 1e-6);
<del> assert.inDelta(x(15), 1.1760913, 1e-6);
<add>
<add> "clamp": {
<add> "defaults to false": function(log) {
<add> var x = log();
<add> assert.isFalse(x.clamp());
<add> assert.inDelta(x(.5), -0.3010299, 1e-6);
<add> assert.inDelta(x(15), 1.1760913, 1e-6);
<add> },
<add> "can clamp to the domain": function(log) {
<add> var x = log().clamp(true);
<add> assert.inDelta(x(.5), 0, 1e-6);
<add> assert.inDelta(x(5), 0.69897, 1e-6);
<add> assert.inDelta(x(15), 1, 1e-6);
<add> var x = log().domain([10, 1]).clamp(true);
<add> assert.inDelta(x(.5), 1, 1e-6);
<add> assert.inDelta(x(5), 0.30103, 1e-6);
<add> assert.inDelta(x(15), 0, 1e-6);
<add> }
<ide> },
<add>
<ide> "maps a number to a number": function(log) {
<ide> var x = log().domain([1, 2]);
<ide> assert.inDelta(x(.5), -1, 1e-6);
<ide> suite.addBatch({
<ide> assert.inDelta(x(2), 1, 1e-6);
<ide> assert.inDelta(x(2.5), 1.3219281, 1e-6);
<ide> },
<del> "coerces domain to numbers": function(log) {
<del> var x = log().domain([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<del> assert.equal(typeof x.domain()[0], "number");
<del> assert.equal(typeof x.domain()[1], "number");
<del> assert.inDelta(x(new Date(1989, 09, 20)), -.2, 1e-2);
<del> assert.inDelta(x(new Date(1990, 00, 01)), 0, 1e-2);
<del> assert.inDelta(x(new Date(1990, 02, 15)), .2, 1e-2);
<del> assert.inDelta(x(new Date(1990, 04, 27)), .4, 1e-2);
<del> assert.inDelta(x(new Date(1991, 00, 01)), 1, 1e-2);
<del> assert.inDelta(x(new Date(1991, 02, 15)), 1.2, 1e-2);
<del> var x = log().domain(["1", "10"]);
<del> assert.equal(typeof x.domain()[0], "number");
<del> assert.equal(typeof x.domain()[1], "number");
<del> assert.inDelta(x(5), 0.69897, 1e-6);
<del> var x = log().domain([new Number(1), new Number(10)]);
<del> assert.equal(typeof x.domain()[0], "number");
<del> assert.equal(typeof x.domain()[1], "number");
<del> assert.inDelta(x(5), 0.69897, 1e-6);
<del> },
<del> "does not coerce range to numbers": function(log) {
<del> var x = log().range(["0", "2"]);
<del> assert.equal(typeof x.range()[0], "string");
<del> assert.equal(typeof x.range()[1], "string");
<del> },
<del> "coerces range value to number on invert": function(log) {
<del> var x = log().range(["0", "2"]);
<del> assert.inDelta(x.invert("1"), 3.1622777, 1e-6);
<del> var x = log().range([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<del> assert.inDelta(x.invert(new Date(1990, 6, 2, 13)), 3.1622777, 1e-6);
<del> var x = log().range(["#000", "#fff"]);
<del> assert.isNaN(x.invert("#999"));
<del> },
<del> "can specify negative domain values": function(log) {
<del> var x = log().domain([-100, -1]);
<del> assert.deepEqual(x.ticks().map(x.tickFormat()), [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]);
<del> assert.inDelta(x(-50), 0.150515, 1e-6);
<del> },
<del> "can specify range values as colors": function(log) {
<del> var x = log().range(["red", "blue"]);
<del> assert.equal(x(5), "rgb(77,0,178)");
<del> var x = log().range(["#ff0000", "#0000ff"]);
<del> assert.equal(x(5), "rgb(77,0,178)");
<del> var x = log().range(["#f00", "#00f"]);
<del> assert.equal(x(5), "rgb(77,0,178)");
<del> var x = log().range([d3.rgb(255,0,0), d3.hsl(240,1,.5)]);
<del> assert.equal(x(5), "rgb(77,0,178)");
<del> var x = log().range(["hsl(0,100%,50%)", "hsl(240,100%,50%)"]);
<del> assert.equal(x(5), "rgb(77,0,178)");
<del> },
<del> "can specify range values as arrays or objects": function(log) {
<del> var x = log().range([{color: "red"}, {color: "blue"}]);
<del> assert.deepEqual(x(5), {color: "rgb(77,0,178)"});
<del> var x = log().range([["red"], ["blue"]]);
<del> assert.deepEqual(x(5), ["rgb(77,0,178)"]);
<del> },
<del> "can specify a custom interpolator": function(log) {
<del> var x = log().range(["red", "blue"]).interpolate(d3.interpolateHsl);
<del> assert.equal(x(5), "#00ffcb");
<del> },
<del> "can clamp to the domain": function(log) {
<del> var x = log().clamp(true);
<del> assert.inDelta(x(.5), 0, 1e-6);
<del> assert.inDelta(x(5), 0.69897, 1e-6);
<del> assert.inDelta(x(15), 1, 1e-6);
<del> var x = log().domain([10, 1]).clamp(true);
<del> assert.inDelta(x(.5), 1, 1e-6);
<del> assert.inDelta(x(5), 0.30103, 1e-6);
<del> assert.inDelta(x(15), 0, 1e-6);
<del> },
<del> "can generate ticks": function(log) {
<del> var x = log();
<del> assert.deepEqual(x.ticks().map(x.tickFormat()), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
<del> var x = log().domain([100, 1]);
<del> assert.deepEqual(x.ticks().map(x.tickFormat()), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]);
<add>
<add> "invert": {
<add> "maps a number to a number": function(log) {
<add> var x = log().domain([1, 2]);
<add> assert.inDelta(x.invert(-1), .5, 1e-6);
<add> assert.inDelta(x.invert(0), 1, 1e-6);
<add> assert.inDelta(x.invert(0.5849625), 1.5, 1e-6);
<add> assert.inDelta(x.invert(1), 2, 1e-6);
<add> assert.inDelta(x.invert(1.3219281), 2.5, 1e-6);
<add> },
<add> "coerces range value to number on invert": function(log) {
<add> var x = log().range(["0", "2"]);
<add> assert.inDelta(x.invert("1"), 3.1622777, 1e-6);
<add> var x = log().range([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<add> assert.inDelta(x.invert(new Date(1990, 6, 2, 13)), 3.1622777, 1e-6);
<add> var x = log().range(["#000", "#fff"]);
<add> assert.isNaN(x.invert("#999"));
<add> }
<ide> },
<del> "can nice the domain, extending it to powers of ten": function(log) {
<del> var x = log().domain([1.1, 10.9]).nice();
<del> assert.deepEqual(x.domain(), [1, 100]);
<del> var x = log().domain([10.9, 1.1]).nice();
<del> assert.deepEqual(x.domain(), [100, 1]);
<del> var x = log().domain([.7, 11.001]).nice();
<del> assert.deepEqual(x.domain(), [.1, 100]);
<del> var x = log().domain([123.1, 6.7]).nice();
<del> assert.deepEqual(x.domain(), [1000, 1]);
<del> var x = log().domain([.01, .49]).nice();
<del> assert.deepEqual(x.domain(), [.01, 1]);
<add>
<add> "ticks": {
<add> "can generate ticks": function(log) {
<add> var x = log();
<add> assert.deepEqual(x.ticks().map(x.tickFormat()), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
<add> var x = log().domain([100, 1]);
<add> assert.deepEqual(x.ticks().map(x.tickFormat()), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]);
<add> }
<ide> },
<del> "can specify a polylog domain and range": function(log) {
<del> var x = log().domain([.1, 1, 100]).range(["red", "white", "green"]);
<del> assert.equal(x(.5), "rgb(255,178,178)");
<del> assert.equal(x(50), "rgb(38,147,38)");
<del> assert.equal(x(75), "rgb(16,136,16)");
<add>
<add> "nice": {
<add> "can nice the domain, extending it to powers of ten": function(log) {
<add> var x = log().domain([1.1, 10.9]).nice();
<add> assert.deepEqual(x.domain(), [1, 100]);
<add> var x = log().domain([10.9, 1.1]).nice();
<add> assert.deepEqual(x.domain(), [100, 1]);
<add> var x = log().domain([.7, 11.001]).nice();
<add> assert.deepEqual(x.domain(), [.1, 100]);
<add> var x = log().domain([123.1, 6.7]).nice();
<add> assert.deepEqual(x.domain(), [1000, 1]);
<add> var x = log().domain([.01, .49]).nice();
<add> assert.deepEqual(x.domain(), [.01, 1]);
<add> },
<add> "nicing a polylog domain only affects the extent": function(log) {
<add> var x = log().domain([1.1, 1.5, 10.9]).nice();
<add> assert.deepEqual(x.domain(), [1, 1.5, 100]);
<add> var x = log().domain([-123.1, -1.5, -.5]).nice();
<add> assert.deepEqual(x.domain(), [-1000, -1.5, -.1]);
<add> }
<ide> },
<del> "nicing a polylog domain only affects the extent": function(log) {
<del> var x = log().domain([1.1, 1.5, 10.9]).nice();
<del> assert.deepEqual(x.domain(), [1, 1.5, 100]);
<del> var x = log().domain([-123.1, -1.5, -.5]).nice();
<del> assert.deepEqual(x.domain(), [-1000, -1.5, -.1]);
<add>
<add> "copy": {
<add> "changes to the domain are isolated": function(log) {
<add> var x = log(), y = x.copy();
<add> x.domain([10, 100]);
<add> assert.deepEqual(y.domain(), [1, 10]);
<add> assert.equal(x(10), 0);
<add> assert.equal(y(1), 0);
<add> y.domain([100, 1000]);
<add> assert.equal(x(100), 1);
<add> assert.equal(y(100), 0);
<add> assert.deepEqual(x.domain(), [10, 100]);
<add> assert.deepEqual(y.domain().map(Math.round), [100, 1000]);
<add> },
<add> "changes to the range are isolated": function(log) {
<add> var x = log(), y = x.copy();
<add> x.range([1, 2]);
<add> assert.equal(x.invert(1), 1);
<add> assert.equal(y.invert(1), 10);
<add> assert.deepEqual(y.range(), [0, 1]);
<add> y.range([2, 3]);
<add> assert.equal(x.invert(2), 10);
<add> assert.equal(y.invert(2), 1);
<add> assert.deepEqual(x.range(), [1, 2]);
<add> assert.deepEqual(y.range(), [2, 3]);
<add> },
<add> "changes to the interpolator are isolated": function(log) {
<add> var x = log().range(["red", "blue"]), y = x.copy();
<add> x.interpolate(d3.interpolateHsl);
<add> assert.equal(x(5), "#00ffcb");
<add> assert.equal(y(5), "rgb(77,0,178)");
<add> assert.equal(y.interpolate(), d3.interpolate);
<add> },
<add> "changes to clamping are isolated": function(log) {
<add> var x = log().clamp(true), y = x.copy();
<add> x.clamp(false);
<add> assert.inDelta(x(.5), -0.30103, 1e-6);
<add> assert.equal(y(.5), 0);
<add> assert.isTrue(y.clamp());
<add> y.clamp(false);
<add> assert.inDelta(x(20), 1.30103, 1e-6);
<add> assert.inDelta(y(20), 1.30103, 1e-6);
<add> assert.isFalse(x.clamp());
<add> }
<ide> }
<ide> }
<ide> });
<ide><path>test/scale/ordinal-test.js
<ide> suite.addBatch({
<ide> topic: function() {
<ide> return d3.scale.ordinal;
<ide> },
<del> "has an empty domain by default": function(ordinal) {
<del> assert.isEmpty(ordinal().domain());
<add>
<add> "domain": {
<add> "defaults to the empty array": function(ordinal) {
<add> assert.isEmpty(ordinal().domain());
<add> },
<add> "new input values are added to the domain": function(ordinal) {
<add> var x = ordinal().range(["foo", "bar"]);
<add> assert.equal(x(0), "foo");
<add> assert.deepEqual(x.domain(), ["0"]);
<add> assert.equal(x(1), "bar");
<add> assert.deepEqual(x.domain(), ["0", "1"]);
<add> assert.equal(x(0), "foo");
<add> assert.deepEqual(x.domain(), ["0", "1"]);
<add> },
<add> "setting the domain forgets previous values": function(ordinal) {
<add> var x = ordinal().range(["foo", "bar"]);
<add> assert.equal(x(1), "foo");
<add> assert.equal(x(0), "bar");
<add> assert.deepEqual(x.domain(), ["0", "1"]);
<add> x.domain(["0", "1"]);
<add> assert.equal(x(0), "foo"); // it changed!
<add> assert.equal(x(1), "bar");
<add> assert.deepEqual(x.domain(), ["0", "1"]);
<add> },
<add> "coerces domain values to strings": function(ordinal) {
<add> var x = ordinal().domain([0, 1]);
<add> assert.deepEqual(x.domain(), ["0", "1"]);
<add> assert.typeOf(x.domain()[0], "string");
<add> assert.typeOf(x.domain()[1], "string");
<add> }
<ide> },
<del> "has an empty range by default": function(ordinal) {
<del> assert.isEmpty(ordinal().range());
<add>
<add> "range": {
<add> "defaults to the empty array": function(ordinal) {
<add> var x = ordinal();
<add> assert.isEmpty(x.range());
<add> assert.isUndefined(x(0));
<add> },
<add> "setting the range remembers previous values": function(ordinal) {
<add> var x = ordinal();
<add> assert.isUndefined(x(0));
<add> assert.isUndefined(x(1));
<add> x.range(["foo", "bar"]);
<add> assert.equal(x(0), "foo");
<add> assert.equal(x(1), "bar");
<add> },
<add> "recycles values when exhausted": function(ordinal) {
<add> var x = ordinal().range(["a", "b", "c"]);
<add> assert.equal(x(0), "a");
<add> assert.equal(x(1), "b");
<add> assert.equal(x(2), "c");
<add> assert.equal(x(3), "a");
<add> assert.equal(x(4), "b");
<add> assert.equal(x(5), "c");
<add> assert.equal(x(2), "c");
<add> assert.equal(x(1), "b");
<add> assert.equal(x(0), "a");
<add> }
<ide> },
<del> "maps distinct domain values to discrete range values": function(ordinal) {
<add>
<add> "maps distinct values to discrete values": function(ordinal) {
<ide> var x = ordinal().range(["a", "b", "c"]);
<ide> assert.equal(x(0), "a");
<ide> assert.equal(x("0"), "a");
<ide> suite.addBatch({
<ide> assert.equal(x(2.0), "c");
<ide> assert.equal(x(new Number(2)), "c");
<ide> },
<del> "recycles range values when exhausted": function(ordinal) {
<del> var x = ordinal().range(["a", "b", "c"]);
<del> assert.equal(x(0), "a");
<del> assert.equal(x(1), "b");
<del> assert.equal(x(2), "c");
<del> assert.equal(x(3), "a");
<del> assert.equal(x(4), "b");
<del> assert.equal(x(5), "c");
<del> assert.equal(x(2), "c");
<del> assert.equal(x(1), "b");
<del> assert.equal(x(0), "a");
<del> },
<del> "computes discrete points in a continuous range": function(ordinal) {
<del> var x = ordinal().domain(["a", "b", "c"]).rangePoints([0, 120]);
<del> assert.deepEqual(x.range(), [0, 60, 120]);
<del> assert.equal(x.rangeBand(), 0);
<del> var x = ordinal().domain(["a", "b", "c"]).rangePoints([0, 120], 1);
<del> assert.deepEqual(x.range(), [20, 60, 100]);
<del> assert.equal(x.rangeBand(), 0);
<add>
<add> "rangePoints": {
<add> "computes discrete points in a continuous range": function(ordinal) {
<add> var x = ordinal().domain(["a", "b", "c"]).rangePoints([0, 120]);
<add> assert.deepEqual(x.range(), [0, 60, 120]);
<add> assert.equal(x.rangeBand(), 0);
<add> var x = ordinal().domain(["a", "b", "c"]).rangePoints([0, 120], 1);
<add> assert.deepEqual(x.range(), [20, 60, 100]);
<add> assert.equal(x.rangeBand(), 0);
<add> }
<ide> },
<del> "computes discrete bands in a continuous range": function(ordinal) {
<del> var x = ordinal().domain(["a", "b", "c"]).rangeBands([0, 120]);
<del> assert.deepEqual(x.range(), [0, 40, 80]);
<del> assert.equal(x.rangeBand(), 40);
<del> var x = ordinal().domain(["a", "b", "c"]).rangeBands([0, 120], .2);
<del> assert.deepEqual(x.range(), [7.5, 45, 82.5]);
<del> assert.equal(x.rangeBand(), 30);
<add>
<add> "rangeBands": {
<add> "computes discrete bands in a continuous range": function(ordinal) {
<add> var x = ordinal().domain(["a", "b", "c"]).rangeBands([0, 120]);
<add> assert.deepEqual(x.range(), [0, 40, 80]);
<add> assert.equal(x.rangeBand(), 40);
<add> var x = ordinal().domain(["a", "b", "c"]).rangeBands([0, 120], .2);
<add> assert.deepEqual(x.range(), [7.5, 45, 82.5]);
<add> assert.equal(x.rangeBand(), 30);
<add> },
<add> "setting domain recomputes range bands": function(ordinal) {
<add> var x = ordinal().rangeRoundBands([0, 100]).domain(["a", "b", "c"]);
<add> assert.deepEqual(x.range(), [1, 34, 67]);
<add> assert.equal(x.rangeBand(), 33);
<add> x.domain(["a", "b", "c", "d"]);
<add> assert.deepEqual(x.range(), [0, 25, 50, 75]);
<add> assert.equal(x.rangeBand(), 25);
<add> }
<ide> },
<del> "computes discrete rounded bands in a continuous range": function(ordinal) {
<del> var x = ordinal().domain(["a", "b", "c"]).rangeRoundBands([0, 100]);
<del> assert.deepEqual(x.range(), [1, 34, 67]);
<del> assert.equal(x.rangeBand(), 33);
<del> var x = ordinal().domain(["a", "b", "c"]).rangeRoundBands([0, 100], .2);
<del> assert.deepEqual(x.range(), [7, 38, 69]);
<del> assert.equal(x.rangeBand(), 25);
<add>
<add> "rangeRoundBands": {
<add> "computes discrete rounded bands in a continuous range": function(ordinal) {
<add> var x = ordinal().domain(["a", "b", "c"]).rangeRoundBands([0, 100]);
<add> assert.deepEqual(x.range(), [1, 34, 67]);
<add> assert.equal(x.rangeBand(), 33);
<add> var x = ordinal().domain(["a", "b", "c"]).rangeRoundBands([0, 100], .2);
<add> assert.deepEqual(x.range(), [7, 38, 69]);
<add> assert.equal(x.rangeBand(), 25);
<add> }
<ide> },
<del> "setting domain recomputes range bands": function(ordinal) {
<del> var x = ordinal().rangeRoundBands([0, 100]).domain(["a", "b", "c"]);
<del> assert.deepEqual(x.range(), [1, 34, 67]);
<del> assert.equal(x.rangeBand(), 33);
<del> x.domain(["a", "b", "c", "d"]);
<del> assert.deepEqual(x.range(), [0, 25, 50, 75]);
<del> assert.equal(x.rangeBand(), 25);
<add>
<add> "copy": {
<add> "changes to the domain are isolated": function(ordinal) {
<add> var x = ordinal().range(["foo", "bar"]), y = x.copy();
<add> x.domain([1, 2]);
<add> assert.deepEqual(y.domain(), []);
<add> assert.equal(x(1), "foo");
<add> assert.equal(y(1), "foo");
<add> y.domain([2, 3]);
<add> assert.equal(x(2), "bar");
<add> assert.equal(y(2), "foo");
<add> assert.deepEqual(x.domain(), ["1", "2"]);
<add> assert.deepEqual(y.domain(), ["2", "3"]);
<add> },
<add> "changes to the range are isolated": function(ordinal) {
<add> var x = ordinal().range(["foo", "bar"]), y = x.copy();
<add> x.range(["bar", "foo"]);
<add> assert.equal(x(1), "bar");
<add> assert.equal(y(1), "foo");
<add> assert.deepEqual(y.range(), ["foo", "bar"]);
<add> y.range(["foo", "baz"]);
<add> assert.equal(x(2), "foo");
<add> assert.equal(y(2), "baz");
<add> assert.deepEqual(x.range(), ["bar", "foo"]);
<add> assert.deepEqual(y.range(), ["foo", "baz"]);
<add> },
<add> "changes to the range type are isolated": function(ordinal) {
<add> var x = ordinal().domain([0, 1]).rangeBands([0, 1], .2), y = x.copy();
<add> x.rangePoints([1, 2]);
<add> assert.inDelta(x(0), 1, 1e-6);
<add> assert.inDelta(x(1), 2, 1e-6);
<add> assert.inDelta(x.rangeBand(), 0, 1e-6);
<add> assert.inDelta(y(0), 1/11, 1e-6);
<add> assert.inDelta(y(1), 6/11, 1e-6);
<add> assert.inDelta(y.rangeBand(), 4/11, 1e-6);
<add> y.rangeBands([0, 1]);
<add> assert.inDelta(x(0), 1, 1e-6);
<add> assert.inDelta(x(1), 2, 1e-6);
<add> assert.inDelta(x.rangeBand(), 0, 1e-6);
<add> assert.inDelta(y(0), 0, 1e-6);
<add> assert.inDelta(y(1), 1/2, 1e-6);
<add> assert.inDelta(y.rangeBand(), 1/2, 1e-6);
<add> }
<ide> }
<ide> }
<ide> });
<ide><path>test/scale/pow-test.js
<ide> suite.addBatch({
<ide> topic: function() {
<ide> return d3.scale.pow;
<ide> },
<del> "has the default domain [0, 1]": function(pow) {
<del> var x = pow();
<del> assert.deepEqual(x.domain(), [0, 1]);
<del> assert.inDelta(x(.5), .5, 1e-6);
<add>
<add> "domain": {
<add> "defaults to [0, 1]": function(pow) {
<add> var x = pow();
<add> assert.deepEqual(x.domain(), [0, 1]);
<add> assert.inDelta(x(.5), .5, 1e-6);
<add> },
<add> "coerces domain to numbers": function(pow) {
<add> var x = pow().domain([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<add> assert.equal(typeof x.domain()[0], "number");
<add> assert.equal(typeof x.domain()[1], "number");
<add> assert.inDelta(x(new Date(1989, 09, 20)), -.2, 1e-2);
<add> assert.inDelta(x(new Date(1990, 00, 01)), 0, 1e-2);
<add> assert.inDelta(x(new Date(1990, 02, 15)), .2, 1e-2);
<add> assert.inDelta(x(new Date(1990, 04, 27)), .4, 1e-2);
<add> assert.inDelta(x(new Date(1991, 00, 01)), 1, 1e-2);
<add> assert.inDelta(x(new Date(1991, 02, 15)), 1.2, 1e-2);
<add> var x = pow().domain(["0", "1"]);
<add> assert.equal(typeof x.domain()[0], "number");
<add> assert.equal(typeof x.domain()[1], "number");
<add> assert.inDelta(x(.5), .5, 1e-6);
<add> var x = pow().domain([new Number(0), new Number(1)]);
<add> assert.equal(typeof x.domain()[0], "number");
<add> assert.equal(typeof x.domain()[1], "number");
<add> assert.inDelta(x(.5), .5, 1e-6);
<add> },
<add> "can specify a polypower domain and range": function(pow) {
<add> var x = pow().domain([-10, 0, 100]).range(["red", "white", "green"]);
<add> assert.equal(x(-5), "rgb(255,128,128)");
<add> assert.equal(x(50), "rgb(128,192,128)");
<add> assert.equal(x(75), "rgb(64,160,64)");
<add> }
<ide> },
<del> "has the default range [0, 1]": function(pow) {
<del> var x = pow();
<del> assert.deepEqual(x.range(), [0, 1]);
<del> assert.inDelta(x.invert(.5), .5, 1e-6);
<add>
<add> "range": {
<add> "defaults to [0, 1]": function(pow) {
<add> var x = pow();
<add> assert.deepEqual(x.range(), [0, 1]);
<add> assert.inDelta(x.invert(.5), .5, 1e-6);
<add> },
<add> "does not coerce range values to numbers": function(pow) {
<add> var x = pow().range(["0", "2"]);
<add> assert.equal(typeof x.range()[0], "string");
<add> assert.equal(typeof x.range()[1], "string");
<add> },
<add> "coerces range values to number on invert": function(pow) {
<add> var x = pow().range(["0", "2"]);
<add> assert.inDelta(x.invert("1"), .5, 1e-6);
<add> var x = pow().range([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<add> assert.inDelta(x.invert(new Date(1990, 6, 2, 13)), .5, 1e-6);
<add> var x = pow().range(["#000", "#fff"]);
<add> assert.isNaN(x.invert("#999"));
<add> },
<add> "can specify range values as colors": function(pow) {
<add> var x = pow().range(["red", "blue"]);
<add> assert.equal(x(.5), "rgb(128,0,128)");
<add> var x = pow().range(["#ff0000", "#0000ff"]);
<add> assert.equal(x(.5), "rgb(128,0,128)");
<add> var x = pow().range(["#f00", "#00f"]);
<add> assert.equal(x(.5), "rgb(128,0,128)");
<add> var x = pow().range([d3.rgb(255,0,0), d3.hsl(240,1,.5)]);
<add> assert.equal(x(.5), "rgb(128,0,128)");
<add> var x = pow().range(["hsl(0,100%,50%)", "hsl(240,100%,50%)"]);
<add> assert.equal(x(.5), "rgb(128,0,128)");
<add> },
<add> "can specify range values as arrays or objects": function(pow) {
<add> var x = pow().range([{color: "red"}, {color: "blue"}]);
<add> assert.deepEqual(x(.5), {color: "rgb(128,0,128)"});
<add> var x = pow().range([["red"], ["blue"]]);
<add> assert.deepEqual(x(.5), ["rgb(128,0,128)"]);
<add> }
<ide> },
<del> "has the default exponent 1": function(pow) {
<del> var x = pow();
<del> assert.equal(x.exponent(), 1);
<add>
<add> "exponent": {
<add> "defaults to one": function(pow) {
<add> var x = pow();
<add> assert.equal(x.exponent(), 1);
<add> },
<add> "observes the specified exponent": function(pow) {
<add> var x = pow().exponent(.5).domain([1, 2]);
<add> assert.inDelta(x(1), 0, 1e-6);
<add> assert.inDelta(x(1.5), 0.5425821, 1e-6);
<add> assert.inDelta(x(2), 1, 1e-6);
<add> assert.equal(x.exponent(), .5);
<add> var x = pow().exponent(2).domain([1, 2]);
<add> assert.inDelta(x(1), 0, 1e-6);
<add> assert.inDelta(x(1.5), .41666667, 1e-6);
<add> assert.inDelta(x(2), 1, 1e-6);
<add> assert.equal(x.exponent(), 2);
<add> var x = pow().exponent(-1).domain([1, 2]);
<add> assert.inDelta(x(1), 0, 1e-6);
<add> assert.inDelta(x(1.5), .6666667, 1e-6);
<add> assert.inDelta(x(2), 1, 1e-6);
<add> assert.equal(x.exponent(), -1);
<add> },
<add> "changing the exponent does not change the domain or range": function(pow) {
<add> var x = pow().domain([1, 2]).range([3, 4]), f = d3.format(".6f");
<add> x.exponent(.5);
<add> assert.deepEqual(x.domain().map(f), [1, 2]);
<add> assert.deepEqual(x.range(), [3, 4]);
<add> x.exponent(2);
<add> assert.deepEqual(x.domain().map(f), [1, 2]);
<add> assert.deepEqual(x.range(), [3, 4]);
<add> x.exponent(-1);
<add> assert.deepEqual(x.domain().map(f), [1, 2]);
<add> assert.deepEqual(x.range(), [3, 4]);
<add> }
<ide> },
<del> "has the default interpolator d3.interpolate": function(pow) {
<del> var x = pow().range(["red", "blue"]);
<del> assert.equal(x.interpolate(), d3.interpolate);
<del> assert.equal(x(.5), "rgb(128,0,128)");
<add>
<add> "interpolate": {
<add> "defaults to d3.interpolate": function(pow) {
<add> var x = pow().range(["red", "blue"]);
<add> assert.equal(x.interpolate(), d3.interpolate);
<add> assert.equal(x(.5), "rgb(128,0,128)");
<add> },
<add> "can specify a custom interpolator": function(pow) {
<add> var x = pow().range(["red", "blue"]).interpolate(d3.interpolateHsl);
<add> assert.equal(x(.5), "#00ff00");
<add> }
<ide> },
<del> "does not clamp by default": function(pow) {
<del> var x = pow();
<del> assert.isFalse(x.clamp());
<del> assert.inDelta(x(-.5), -.5, 1e-6);
<del> assert.inDelta(x(1.5), 1.5, 1e-6);
<add>
<add> "clamp": {
<add> "does not clamp by default": function(pow) {
<add> var x = pow();
<add> assert.isFalse(x.clamp());
<add> assert.inDelta(x(-.5), -.5, 1e-6);
<add> assert.inDelta(x(1.5), 1.5, 1e-6);
<add> },
<add> "can clamp to the domain": function(pow) {
<add> var x = pow().clamp(true);
<add> assert.inDelta(x(-.5), 0, 1e-6);
<add> assert.inDelta(x(.5), .5, 1e-6);
<add> assert.inDelta(x(1.5), 1, 1e-6);
<add> var x = pow().domain([1, 0]).clamp(true);
<add> assert.inDelta(x(-.5), 1, 1e-6);
<add> assert.inDelta(x(.5), .5, 1e-6);
<add> assert.inDelta(x(1.5), 0, 1e-6);
<add> }
<ide> },
<add>
<ide> "maps a number to a number": function(pow) {
<ide> var x = pow().domain([1, 2]);
<ide> assert.inDelta(x(.5), -.5, 1e-6);
<ide> suite.addBatch({
<ide> assert.inDelta(x(2), 1, 1e-6);
<ide> assert.inDelta(x(2.5), 1.5, 1e-6);
<ide> },
<del> "observes the specified exponent": function(pow) {
<del> var x = pow().exponent(.5).domain([1, 2]);
<del> assert.inDelta(x(1), 0, 1e-6);
<del> assert.inDelta(x(1.5), 0.5425821, 1e-6);
<del> assert.inDelta(x(2), 1, 1e-6);
<del> var x = pow().exponent(2).domain([1, 2]);
<del> assert.inDelta(x(1), 0, 1e-6);
<del> assert.inDelta(x(1.5), .41666667, 1e-6);
<del> assert.inDelta(x(2), 1, 1e-6);
<del> var x = pow().exponent(-1).domain([1, 2]);
<del> assert.inDelta(x(1), 0, 1e-6);
<del> assert.inDelta(x(1.5), .6666667, 1e-6);
<del> assert.inDelta(x(2), 1, 1e-6);
<del> },
<del> "changing the exponent does not change the domain or range": function(pow) {
<del> var x = pow().domain([1, 2]).range([3, 4]), f = d3.format(".6f");
<del> x.exponent(.5);
<del> assert.deepEqual(x.domain().map(f), [1, 2]);
<del> assert.deepEqual(x.range(), [3, 4]);
<del> x.exponent(2);
<del> assert.deepEqual(x.domain().map(f), [1, 2]);
<del> assert.deepEqual(x.range(), [3, 4]);
<del> x.exponent(-1);
<del> assert.deepEqual(x.domain().map(f), [1, 2]);
<del> assert.deepEqual(x.range(), [3, 4]);
<del> },
<del> "coerces domain to numbers": function(pow) {
<del> var x = pow().domain([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<del> assert.equal(typeof x.domain()[0], "number");
<del> assert.equal(typeof x.domain()[1], "number");
<del> assert.inDelta(x(new Date(1989, 09, 20)), -.2, 1e-2);
<del> assert.inDelta(x(new Date(1990, 00, 01)), 0, 1e-2);
<del> assert.inDelta(x(new Date(1990, 02, 15)), .2, 1e-2);
<del> assert.inDelta(x(new Date(1990, 04, 27)), .4, 1e-2);
<del> assert.inDelta(x(new Date(1991, 00, 01)), 1, 1e-2);
<del> assert.inDelta(x(new Date(1991, 02, 15)), 1.2, 1e-2);
<del> var x = pow().domain(["0", "1"]);
<del> assert.equal(typeof x.domain()[0], "number");
<del> assert.equal(typeof x.domain()[1], "number");
<del> assert.inDelta(x(.5), .5, 1e-6);
<del> var x = pow().domain([new Number(0), new Number(1)]);
<del> assert.equal(typeof x.domain()[0], "number");
<del> assert.equal(typeof x.domain()[1], "number");
<del> assert.inDelta(x(.5), .5, 1e-6);
<del> },
<del> "does not coerce range to numbers": function(pow) {
<del> var x = pow().range(["0", "2"]);
<del> assert.equal(typeof x.range()[0], "string");
<del> assert.equal(typeof x.range()[1], "string");
<del> },
<del> "coerces range value to number on invert": function(pow) {
<del> var x = pow().range(["0", "2"]);
<del> assert.inDelta(x.invert("1"), .5, 1e-6);
<del> var x = pow().range([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<del> assert.inDelta(x.invert(new Date(1990, 6, 2, 13)), .5, 1e-6);
<del> var x = pow().range(["#000", "#fff"]);
<del> assert.isNaN(x.invert("#999"));
<del> },
<del> "can specify range values as colors": function(pow) {
<del> var x = pow().range(["red", "blue"]);
<del> assert.equal(x(.5), "rgb(128,0,128)");
<del> var x = pow().range(["#ff0000", "#0000ff"]);
<del> assert.equal(x(.5), "rgb(128,0,128)");
<del> var x = pow().range(["#f00", "#00f"]);
<del> assert.equal(x(.5), "rgb(128,0,128)");
<del> var x = pow().range([d3.rgb(255,0,0), d3.hsl(240,1,.5)]);
<del> assert.equal(x(.5), "rgb(128,0,128)");
<del> var x = pow().range(["hsl(0,100%,50%)", "hsl(240,100%,50%)"]);
<del> assert.equal(x(.5), "rgb(128,0,128)");
<del> },
<del> "can specify range values as arrays or objects": function(pow) {
<del> var x = pow().range([{color: "red"}, {color: "blue"}]);
<del> assert.deepEqual(x(.5), {color: "rgb(128,0,128)"});
<del> var x = pow().range([["red"], ["blue"]]);
<del> assert.deepEqual(x(.5), ["rgb(128,0,128)"]);
<del> },
<del> "can specify a custom interpolator": function(pow) {
<del> var x = pow().range(["red", "blue"]).interpolate(d3.interpolateHsl);
<del> assert.equal(x(.5), "#00ff00");
<del> },
<del> "can clamp to the domain": function(pow) {
<del> var x = pow().clamp(true);
<del> assert.inDelta(x(-.5), 0, 1e-6);
<del> assert.inDelta(x(.5), .5, 1e-6);
<del> assert.inDelta(x(1.5), 1, 1e-6);
<del> var x = pow().domain([1, 0]).clamp(true);
<del> assert.inDelta(x(-.5), 1, 1e-6);
<del> assert.inDelta(x(.5), .5, 1e-6);
<del> assert.inDelta(x(1.5), 0, 1e-6);
<del> },
<del> "can generate ticks of varying degree": function(pow) {
<del> var x = pow();
<del> assert.deepEqual(x.ticks(1).map(x.tickFormat(1)), [0, 1]);
<del> assert.deepEqual(x.ticks(2).map(x.tickFormat(2)), [0, .5, 1]);
<del> assert.deepEqual(x.ticks(5).map(x.tickFormat(5)), [0, .2, .4, .6, .8, 1]);
<del> assert.deepEqual(x.ticks(10).map(x.tickFormat(10)), [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1]);
<del> var x = pow().domain([1, 0]);
<del> assert.deepEqual(x.ticks(1).map(x.tickFormat(1)), [0, 1]);
<del> assert.deepEqual(x.ticks(2).map(x.tickFormat(2)), [0, .5, 1]);
<del> assert.deepEqual(x.ticks(5).map(x.tickFormat(5)), [0, .2, .4, .6, .8, 1]);
<del> assert.deepEqual(x.ticks(10).map(x.tickFormat(10)), [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1]);
<del> },
<del> "can nice the domain, extending it to round numbers": function(pow) {
<del> var x = pow().domain([1.1, 10.9]).nice();
<del> assert.deepEqual(x.domain(), [1, 11]);
<del> var x = pow().domain([10.9, 1.1]).nice();
<del> assert.deepEqual(x.domain(), [11, 1]);
<del> var x = pow().domain([.7, 11.001]).nice();
<del> assert.deepEqual(x.domain(), [0, 12]);
<del> var x = pow().domain([123.1, 6.7]).nice();
<del> assert.deepEqual(x.domain(), [130, 0]);
<del> var x = pow().domain([0, .49]).nice();
<del> assert.deepEqual(x.domain(), [0, .5]);
<del> },
<del> "can specify a polypower domain and range": function(pow) {
<del> var x = pow().domain([-10, 0, 100]).range(["red", "white", "green"]);
<del> assert.equal(x(-5), "rgb(255,128,128)");
<del> assert.equal(x(50), "rgb(128,192,128)");
<del> assert.equal(x(75), "rgb(64,160,64)");
<del> },
<del> "nicing a polypower domain only affects the extent": function(pow) {
<del> var x = pow().domain([1.1, 1, 2, 3, 10.9]).nice();
<del> assert.deepEqual(x.domain(), [1, 1, 2, 3, 11]);
<del> var x = pow().domain([123.1, 1, 2, 3, -.9]).nice();
<del> assert.deepEqual(x.domain(), [130, 1, 2, 3, -10]);
<del> }
<del> },
<del> "sqrt": {
<del> topic: function() {
<del> return d3.scale.sqrt;
<del> },
<del> "has the default domain [0, 1]": function(sqrt) {
<del> var x = sqrt();
<del> assert.deepEqual(x.domain(), [0, 1]);
<del> assert.inDelta(x(.5), 0.7071068, 1e-6);
<del> },
<del> "has the default range [0, 1]": function(sqrt) {
<del> var x = sqrt();
<del> assert.deepEqual(x.range(), [0, 1]);
<del> assert.inDelta(x.invert(.5), .25, 1e-6);
<del> },
<del> "has the default exponent .5": function(sqrt) {
<del> var x = sqrt();
<del> assert.equal(x.exponent(), .5);
<del> },
<del> "has the default interpolator d3.interpolate": function(sqrt) {
<del> var x = sqrt().range(["red", "blue"]);
<del> assert.equal(x.interpolate(), d3.interpolate);
<del> assert.equal(x(.5), "rgb(75,0,180)");
<del> },
<del> "does not clamp by default": function(sqrt) {
<del> var x = sqrt();
<del> assert.isFalse(x.clamp());
<del> assert.inDelta(x(-.5), -0.7071068, 1e-6);
<del> assert.inDelta(x(1.5), 1.22474487, 1e-6);
<del> },
<del> "maps a number to a number": function(sqrt) {
<del> var x = sqrt().domain([1, 2]);
<del> assert.inDelta(x(.5), -0.7071068, 1e-6);
<del> assert.inDelta(x(1), 0, 1e-6);
<del> assert.inDelta(x(1.5), 0.5425821, 1e-6);
<del> assert.inDelta(x(2), 1, 1e-6);
<del> assert.inDelta(x(2.5), 1.4029932, 1e-6);
<del> },
<del> "observes the specified exponent": function(sqrt) {
<del> var x = sqrt().exponent(.5).domain([1, 2]);
<del> assert.inDelta(x(1), 0, 1e-6);
<del> assert.inDelta(x(1.5), 0.5425821, 1e-6);
<del> assert.inDelta(x(2), 1, 1e-6);
<del> var x = sqrt().exponent(2).domain([1, 2]);
<del> assert.inDelta(x(1), 0, 1e-6);
<del> assert.inDelta(x(1.5), .41666667, 1e-6);
<del> assert.inDelta(x(2), 1, 1e-6);
<del> var x = sqrt().exponent(-1).domain([1, 2]);
<del> assert.inDelta(x(1), 0, 1e-6);
<del> assert.inDelta(x(1.5), .6666667, 1e-6);
<del> assert.inDelta(x(2), 1, 1e-6);
<del> },
<del> "changing the exponent does not change the domain or range": function(sqrt) {
<del> var x = sqrt().domain([1, 2]).range([3, 4]), f = d3.format(".6f");
<del> x.exponent(.5);
<del> assert.deepEqual(x.domain().map(f), [1, 2]);
<del> assert.deepEqual(x.range(), [3, 4]);
<del> x.exponent(2);
<del> assert.deepEqual(x.domain().map(f), [1, 2]);
<del> assert.deepEqual(x.range(), [3, 4]);
<del> x.exponent(-1);
<del> assert.deepEqual(x.domain().map(f), [1, 2]);
<del> assert.deepEqual(x.range(), [3, 4]);
<del> },
<del> "coerces domain to numbers": function(sqrt) {
<del> var x = sqrt().domain([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<del> assert.equal(typeof x.domain()[0], "number");
<del> assert.equal(typeof x.domain()[1], "number");
<del> assert.inDelta(x(new Date(1989, 09, 20)), -.2, 1e-2);
<del> assert.inDelta(x(new Date(1990, 00, 01)), 0, 1e-2);
<del> assert.inDelta(x(new Date(1990, 02, 15)), .2, 1e-2);
<del> assert.inDelta(x(new Date(1990, 04, 27)), .4, 1e-2);
<del> assert.inDelta(x(new Date(1991, 00, 01)), 1, 1e-2);
<del> assert.inDelta(x(new Date(1991, 02, 15)), 1.2, 1e-2);
<del> var x = sqrt().domain(["0", "1"]);
<del> assert.equal(typeof x.domain()[0], "number");
<del> assert.equal(typeof x.domain()[1], "number");
<del> assert.inDelta(x(.5), 0.7071068, 1e-6);
<del> var x = sqrt().domain([new Number(0), new Number(1)]);
<del> assert.equal(typeof x.domain()[0], "number");
<del> assert.equal(typeof x.domain()[1], "number");
<del> assert.inDelta(x(.5), 0.7071068, 1e-6);
<del> },
<del> "does not coerce range to numbers": function(sqrt) {
<del> var x = sqrt().range(["0", "2"]);
<del> assert.equal(typeof x.range()[0], "string");
<del> assert.equal(typeof x.range()[1], "string");
<del> },
<del> "coerces range value to number on invert": function(sqrt) {
<del> var x = sqrt().range(["0", "2"]);
<del> assert.inDelta(x.invert("1"), .25, 1e-6);
<del> var x = sqrt().range([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<del> assert.inDelta(x.invert(new Date(1990, 6, 2, 13)), .25, 1e-6);
<del> var x = sqrt().range(["#000", "#fff"]);
<del> assert.isNaN(x.invert("#999"));
<del> },
<del> "can specify range values as colors": function(sqrt) {
<del> var x = sqrt().range(["red", "blue"]);
<del> assert.equal(x(.25), "rgb(128,0,128)");
<del> var x = sqrt().range(["#ff0000", "#0000ff"]);
<del> assert.equal(x(.25), "rgb(128,0,128)");
<del> var x = sqrt().range(["#f00", "#00f"]);
<del> assert.equal(x(.25), "rgb(128,0,128)");
<del> var x = sqrt().range([d3.rgb(255,0,0), d3.hsl(240,1,.5)]);
<del> assert.equal(x(.25), "rgb(128,0,128)");
<del> var x = sqrt().range(["hsl(0,100%,50%)", "hsl(240,100%,50%)"]);
<del> assert.equal(x(.25), "rgb(128,0,128)");
<del> },
<del> "can specify range values as arrays or objects": function(sqrt) {
<del> var x = sqrt().range([{color: "red"}, {color: "blue"}]);
<del> assert.deepEqual(x(.25), {color: "rgb(128,0,128)"});
<del> var x = sqrt().range([["red"], ["blue"]]);
<del> assert.deepEqual(x(.25), ["rgb(128,0,128)"]);
<del> },
<del> "can specify a custom interpolator": function(sqrt) {
<del> var x = sqrt().range(["red", "blue"]).interpolate(d3.interpolateHsl);
<del> assert.equal(x(.25), "#00ff00");
<del> },
<del> "can clamp to the domain": function(sqrt) {
<del> var x = sqrt().clamp(true);
<del> assert.inDelta(x(-.5), 0, 1e-6);
<del> assert.inDelta(x(.25), .5, 1e-6);
<del> assert.inDelta(x(1.5), 1, 1e-6);
<del> var x = sqrt().domain([1, 0]).clamp(true);
<del> assert.inDelta(x(-.5), 1, 1e-6);
<del> assert.inDelta(x(.25), .5, 1e-6);
<del> assert.inDelta(x(1.5), 0, 1e-6);
<del> },
<del> "can generate ticks of varying degree": function(sqrt) {
<del> var x = sqrt();
<del> assert.deepEqual(x.ticks(1).map(x.tickFormat(1)), [0, 1]);
<del> assert.deepEqual(x.ticks(2).map(x.tickFormat(2)), [0, .5, 1]);
<del> assert.deepEqual(x.ticks(5).map(x.tickFormat(5)), [0, .2, .4, .6, .8, 1]);
<del> assert.deepEqual(x.ticks(10).map(x.tickFormat(10)), [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1]);
<del> var x = sqrt().domain([1, 0]);
<del> assert.deepEqual(x.ticks(1).map(x.tickFormat(1)), [0, 1]);
<del> assert.deepEqual(x.ticks(2).map(x.tickFormat(2)), [0, .5, 1]);
<del> assert.deepEqual(x.ticks(5).map(x.tickFormat(5)), [0, .2, .4, .6, .8, 1]);
<del> assert.deepEqual(x.ticks(10).map(x.tickFormat(10)), [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1]);
<del> },
<del> "can nice the domain, extending it to round numbers": function(sqrt) {
<del> var x = sqrt().domain([1.1, 10.9]).nice(), f = d3.format(".6f");
<del> assert.deepEqual(x.domain().map(f), [1, 11]);
<del> var x = sqrt().domain([10.9, 1.1]).nice();
<del> assert.deepEqual(x.domain().map(f), [11, 1]);
<del> var x = sqrt().domain([.7, 11.001]).nice();
<del> assert.deepEqual(x.domain().map(f), [0, 12]);
<del> var x = sqrt().domain([123.1, 6.7]).nice();
<del> assert.deepEqual(x.domain().map(f), [130, 0]);
<del> var x = sqrt().domain([0, .49]).nice();
<del> assert.deepEqual(x.domain().map(f), [0, .5]);
<add>
<add> "ticks": {
<add> "can generate ticks of varying degree": function(pow) {
<add> var x = pow();
<add> assert.deepEqual(x.ticks(1).map(x.tickFormat(1)), [0, 1]);
<add> assert.deepEqual(x.ticks(2).map(x.tickFormat(2)), [0, .5, 1]);
<add> assert.deepEqual(x.ticks(5).map(x.tickFormat(5)), [0, .2, .4, .6, .8, 1]);
<add> assert.deepEqual(x.ticks(10).map(x.tickFormat(10)), [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1]);
<add> var x = pow().domain([1, 0]);
<add> assert.deepEqual(x.ticks(1).map(x.tickFormat(1)), [0, 1]);
<add> assert.deepEqual(x.ticks(2).map(x.tickFormat(2)), [0, .5, 1]);
<add> assert.deepEqual(x.ticks(5).map(x.tickFormat(5)), [0, .2, .4, .6, .8, 1]);
<add> assert.deepEqual(x.ticks(10).map(x.tickFormat(10)), [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1]);
<add> }
<ide> },
<del> "can specify a polypower domain and range": function(sqrt) {
<del> var x = sqrt().domain([-10, 0, 100]).range(["red", "white", "green"]);
<del> assert.equal(x(-5), "rgb(255,75,75)");
<del> assert.equal(x(50), "rgb(75,165,75)");
<del> assert.equal(x(75), "rgb(34,145,34)");
<add>
<add> "nice": {
<add> "can nice the domain, extending it to round numbers": function(pow) {
<add> var x = pow().domain([1.1, 10.9]).nice();
<add> assert.deepEqual(x.domain(), [1, 11]);
<add> var x = pow().domain([10.9, 1.1]).nice();
<add> assert.deepEqual(x.domain(), [11, 1]);
<add> var x = pow().domain([.7, 11.001]).nice();
<add> assert.deepEqual(x.domain(), [0, 12]);
<add> var x = pow().domain([123.1, 6.7]).nice();
<add> assert.deepEqual(x.domain(), [130, 0]);
<add> var x = pow().domain([0, .49]).nice();
<add> assert.deepEqual(x.domain(), [0, .5]);
<add> },
<add> "nicing a polypower domain only affects the extent": function(pow) {
<add> var x = pow().domain([1.1, 1, 2, 3, 10.9]).nice();
<add> assert.deepEqual(x.domain(), [1, 1, 2, 3, 11]);
<add> var x = pow().domain([123.1, 1, 2, 3, -.9]).nice();
<add> assert.deepEqual(x.domain(), [130, 1, 2, 3, -10]);
<add> }
<ide> },
<del> "nicing a polypower domain only affects the extent": function(sqrt) {
<del> var x = sqrt().domain([1.1, 1, 2, 3, 10.9]).nice(), f = d3.format(".6f");
<del> assert.deepEqual(x.domain().map(f), [1, 1, 2, 3, 11]);
<del> var x = sqrt().domain([123.1, 1, 2, 3, -.9]).nice();
<del> assert.deepEqual(x.domain().map(f), [130, 1, 2, 3, "−10.000000"]);
<add>
<add> "copy": {
<add> "changes to the domain are isolated": function(pow) {
<add> var x = pow(), y = x.copy();
<add> x.domain([1, 2]);
<add> assert.deepEqual(y.domain(), [0, 1]);
<add> assert.equal(x(1), 0);
<add> assert.equal(y(1), 1);
<add> y.domain([2, 3]);
<add> assert.equal(x(2), 1);
<add> assert.equal(y(2), 0);
<add> assert.deepEqual(x.domain(), [1, 2]);
<add> assert.deepEqual(y.domain(), [2, 3]);
<add> },
<add> "changes to the range are isolated": function(pow) {
<add> var x = pow(), y = x.copy();
<add> x.range([1, 2]);
<add> assert.equal(x.invert(1), 0);
<add> assert.equal(y.invert(1), 1);
<add> assert.deepEqual(y.range(), [0, 1]);
<add> y.range([2, 3]);
<add> assert.equal(x.invert(2), 1);
<add> assert.equal(y.invert(2), 0);
<add> assert.deepEqual(x.range(), [1, 2]);
<add> assert.deepEqual(y.range(), [2, 3]);
<add> },
<add> "changes to the exponent are isolated": function(pow) {
<add> var x = pow().exponent(2), y = x.copy();
<add> x.exponent(.5);
<add> assert.inDelta(x(.5), Math.SQRT1_2, 1e-6);
<add> assert.inDelta(y(.5), 0.25, 1e-6);
<add> assert.equal(x.exponent(), .5);
<add> assert.equal(y.exponent(), 2);
<add> y.exponent(3);
<add> assert.inDelta(x(.5), Math.SQRT1_2, 1e-6);
<add> assert.inDelta(y(.5), 0.125, 1e-6);
<add> assert.equal(x.exponent(), .5);
<add> assert.equal(y.exponent(), 3);
<add> },
<add> "changes to the interpolator are isolated": function(pow) {
<add> var x = pow().range(["red", "blue"]), y = x.copy();
<add> x.interpolate(d3.interpolateHsl);
<add> assert.equal(x(0.5), "#00ff00");
<add> assert.equal(y(0.5), "rgb(128,0,128)");
<add> assert.equal(y.interpolate(), d3.interpolate);
<add> },
<add> "changes to clamping are isolated": function(pow) {
<add> var x = pow().clamp(true), y = x.copy();
<add> x.clamp(false);
<add> assert.equal(x(2), 2);
<add> assert.equal(y(2), 1);
<add> assert.isTrue(y.clamp());
<add> y.clamp(false);
<add> assert.equal(x(2), 2);
<add> assert.equal(y(2), 2);
<add> assert.isFalse(x.clamp());
<add> }
<ide> }
<ide> }
<ide> });
<ide><path>test/scale/sqrt-test.js
<add>require("../env");
<add>require("../../d3");
<add>
<add>var vows = require("vows"),
<add> assert = require("assert");
<add>
<add>var suite = vows.describe("d3.scale.sqrt");
<add>
<add>suite.addBatch({
<add> "sqrt": {
<add> topic: function() {
<add> return d3.scale.sqrt;
<add> },
<add>
<add> "domain": {
<add> "defaults to [0, 1]": function(sqrt) {
<add> var x = sqrt();
<add> assert.deepEqual(x.domain(), [0, 1]);
<add> assert.inDelta(x(.5), 0.7071068, 1e-6);
<add> },
<add> "coerces domain to numbers": function(sqrt) {
<add> var x = sqrt().domain([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<add> assert.equal(typeof x.domain()[0], "number");
<add> assert.equal(typeof x.domain()[1], "number");
<add> assert.inDelta(x(new Date(1989, 09, 20)), -.2, 1e-2);
<add> assert.inDelta(x(new Date(1990, 00, 01)), 0, 1e-2);
<add> assert.inDelta(x(new Date(1990, 02, 15)), .2, 1e-2);
<add> assert.inDelta(x(new Date(1990, 04, 27)), .4, 1e-2);
<add> assert.inDelta(x(new Date(1991, 00, 01)), 1, 1e-2);
<add> assert.inDelta(x(new Date(1991, 02, 15)), 1.2, 1e-2);
<add> var x = sqrt().domain(["0", "1"]);
<add> assert.equal(typeof x.domain()[0], "number");
<add> assert.equal(typeof x.domain()[1], "number");
<add> assert.inDelta(x(.5), 0.7071068, 1e-6);
<add> var x = sqrt().domain([new Number(0), new Number(1)]);
<add> assert.equal(typeof x.domain()[0], "number");
<add> assert.equal(typeof x.domain()[1], "number");
<add> assert.inDelta(x(.5), 0.7071068, 1e-6);
<add> },
<add> "can specify a polypower domain and range": function(sqrt) {
<add> var x = sqrt().domain([-10, 0, 100]).range(["red", "white", "green"]);
<add> assert.equal(x(-5), "rgb(255,75,75)");
<add> assert.equal(x(50), "rgb(75,165,75)");
<add> assert.equal(x(75), "rgb(34,145,34)");
<add> }
<add> },
<add>
<add> "range": {
<add> "defaults to [0, 1]": function(sqrt) {
<add> var x = sqrt();
<add> assert.deepEqual(x.range(), [0, 1]);
<add> assert.inDelta(x.invert(.5), .25, 1e-6);
<add> },
<add> "does not coerce range to numbers": function(sqrt) {
<add> var x = sqrt().range(["0", "2"]);
<add> assert.equal(typeof x.range()[0], "string");
<add> assert.equal(typeof x.range()[1], "string");
<add> },
<add> "coerces range value to number on invert": function(sqrt) {
<add> var x = sqrt().range(["0", "2"]);
<add> assert.inDelta(x.invert("1"), .25, 1e-6);
<add> var x = sqrt().range([new Date(1990, 0, 1), new Date(1991, 0, 1)]);
<add> assert.inDelta(x.invert(new Date(1990, 6, 2, 13)), .25, 1e-6);
<add> var x = sqrt().range(["#000", "#fff"]);
<add> assert.isNaN(x.invert("#999"));
<add> },
<add> "can specify range values as colors": function(sqrt) {
<add> var x = sqrt().range(["red", "blue"]);
<add> assert.equal(x(.25), "rgb(128,0,128)");
<add> var x = sqrt().range(["#ff0000", "#0000ff"]);
<add> assert.equal(x(.25), "rgb(128,0,128)");
<add> var x = sqrt().range(["#f00", "#00f"]);
<add> assert.equal(x(.25), "rgb(128,0,128)");
<add> var x = sqrt().range([d3.rgb(255,0,0), d3.hsl(240,1,.5)]);
<add> assert.equal(x(.25), "rgb(128,0,128)");
<add> var x = sqrt().range(["hsl(0,100%,50%)", "hsl(240,100%,50%)"]);
<add> assert.equal(x(.25), "rgb(128,0,128)");
<add> },
<add> "can specify range values as arrays or objects": function(sqrt) {
<add> var x = sqrt().range([{color: "red"}, {color: "blue"}]);
<add> assert.deepEqual(x(.25), {color: "rgb(128,0,128)"});
<add> var x = sqrt().range([["red"], ["blue"]]);
<add> assert.deepEqual(x(.25), ["rgb(128,0,128)"]);
<add> }
<add> },
<add>
<add> "exponent": {
<add> "defaults to .5": function(sqrt) {
<add> var x = sqrt();
<add> assert.equal(x.exponent(), .5);
<add> },
<add> "observes the specified exponent": function(sqrt) {
<add> var x = sqrt().exponent(.5).domain([1, 2]);
<add> assert.inDelta(x(1), 0, 1e-6);
<add> assert.inDelta(x(1.5), 0.5425821, 1e-6);
<add> assert.inDelta(x(2), 1, 1e-6);
<add> var x = sqrt().exponent(2).domain([1, 2]);
<add> assert.inDelta(x(1), 0, 1e-6);
<add> assert.inDelta(x(1.5), .41666667, 1e-6);
<add> assert.inDelta(x(2), 1, 1e-6);
<add> var x = sqrt().exponent(-1).domain([1, 2]);
<add> assert.inDelta(x(1), 0, 1e-6);
<add> assert.inDelta(x(1.5), .6666667, 1e-6);
<add> assert.inDelta(x(2), 1, 1e-6);
<add> },
<add> "changing the exponent does not change the domain or range": function(sqrt) {
<add> var x = sqrt().domain([1, 2]).range([3, 4]), f = d3.format(".6f");
<add> x.exponent(.5);
<add> assert.deepEqual(x.domain().map(f), [1, 2]);
<add> assert.deepEqual(x.range(), [3, 4]);
<add> x.exponent(2);
<add> assert.deepEqual(x.domain().map(f), [1, 2]);
<add> assert.deepEqual(x.range(), [3, 4]);
<add> x.exponent(-1);
<add> assert.deepEqual(x.domain().map(f), [1, 2]);
<add> assert.deepEqual(x.range(), [3, 4]);
<add> }
<add> },
<add>
<add> "interpolate": {
<add> "defaults to d3.interpolate": function(sqrt) {
<add> var x = sqrt().range(["red", "blue"]);
<add> assert.equal(x.interpolate(), d3.interpolate);
<add> assert.equal(x(.5), "rgb(75,0,180)");
<add> },
<add> "can specify a custom interpolator": function(sqrt) {
<add> var x = sqrt().range(["red", "blue"]).interpolate(d3.interpolateHsl);
<add> assert.equal(x(.25), "#00ff00");
<add> }
<add> },
<add>
<add> "clamp": {
<add> "defaults to false": function(sqrt) {
<add> var x = sqrt();
<add> assert.isFalse(x.clamp());
<add> assert.inDelta(x(-.5), -0.7071068, 1e-6);
<add> assert.inDelta(x(1.5), 1.22474487, 1e-6);
<add> },
<add> "can clamp to the domain": function(sqrt) {
<add> var x = sqrt().clamp(true);
<add> assert.inDelta(x(-.5), 0, 1e-6);
<add> assert.inDelta(x(.25), .5, 1e-6);
<add> assert.inDelta(x(1.5), 1, 1e-6);
<add> var x = sqrt().domain([1, 0]).clamp(true);
<add> assert.inDelta(x(-.5), 1, 1e-6);
<add> assert.inDelta(x(.25), .5, 1e-6);
<add> assert.inDelta(x(1.5), 0, 1e-6);
<add> }
<add> },
<add>
<add> "maps a number to a number": function(sqrt) {
<add> var x = sqrt().domain([1, 2]);
<add> assert.inDelta(x(.5), -0.7071068, 1e-6);
<add> assert.inDelta(x(1), 0, 1e-6);
<add> assert.inDelta(x(1.5), 0.5425821, 1e-6);
<add> assert.inDelta(x(2), 1, 1e-6);
<add> assert.inDelta(x(2.5), 1.4029932, 1e-6);
<add> },
<add>
<add> "ticks": {
<add> "can generate ticks of varying degree": function(sqrt) {
<add> var x = sqrt();
<add> assert.deepEqual(x.ticks(1).map(x.tickFormat(1)), [0, 1]);
<add> assert.deepEqual(x.ticks(2).map(x.tickFormat(2)), [0, .5, 1]);
<add> assert.deepEqual(x.ticks(5).map(x.tickFormat(5)), [0, .2, .4, .6, .8, 1]);
<add> assert.deepEqual(x.ticks(10).map(x.tickFormat(10)), [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1]);
<add> var x = sqrt().domain([1, 0]);
<add> assert.deepEqual(x.ticks(1).map(x.tickFormat(1)), [0, 1]);
<add> assert.deepEqual(x.ticks(2).map(x.tickFormat(2)), [0, .5, 1]);
<add> assert.deepEqual(x.ticks(5).map(x.tickFormat(5)), [0, .2, .4, .6, .8, 1]);
<add> assert.deepEqual(x.ticks(10).map(x.tickFormat(10)), [0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1]);
<add> }
<add> },
<add>
<add> "nice": {
<add> "can nice the domain, extending it to round numbers": function(sqrt) {
<add> var x = sqrt().domain([1.1, 10.9]).nice(), f = d3.format(".6f");
<add> assert.deepEqual(x.domain().map(f), [1, 11]);
<add> var x = sqrt().domain([10.9, 1.1]).nice();
<add> assert.deepEqual(x.domain().map(f), [11, 1]);
<add> var x = sqrt().domain([.7, 11.001]).nice();
<add> assert.deepEqual(x.domain().map(f), [0, 12]);
<add> var x = sqrt().domain([123.1, 6.7]).nice();
<add> assert.deepEqual(x.domain().map(f), [130, 0]);
<add> var x = sqrt().domain([0, .49]).nice();
<add> assert.deepEqual(x.domain().map(f), [0, .5]);
<add> },
<add> "nicing a polypower domain only affects the extent": function(sqrt) {
<add> var x = sqrt().domain([1.1, 1, 2, 3, 10.9]).nice(), f = d3.format(".6f");
<add> assert.deepEqual(x.domain().map(f), [1, 1, 2, 3, 11]);
<add> var x = sqrt().domain([123.1, 1, 2, 3, -.9]).nice();
<add> assert.deepEqual(x.domain().map(f), [130, 1, 2, 3, "−10.000000"]);
<add> }
<add> },
<add>
<add> "copy": {
<add> "changes to the domain are isolated": function(sqrt) {
<add> var x = sqrt(), y = x.copy();
<add> x.domain([1, 2]);
<add> assert.deepEqual(y.domain(), [0, 1]);
<add> assert.equal(x(1), 0);
<add> assert.equal(y(1), 1);
<add> y.domain([2, 3]);
<add> assert.equal(x(2), 1);
<add> assert.equal(y(2), 0);
<add> assert.inDelta(x.domain(), [1, 2], 1e-6);
<add> assert.inDelta(y.domain(), [2, 3], 1e-6);
<add> },
<add> "changes to the range are isolated": function(sqrt) {
<add> var x = sqrt(), y = x.copy();
<add> x.range([1, 2]);
<add> assert.equal(x.invert(1), 0);
<add> assert.equal(y.invert(1), 1);
<add> assert.deepEqual(y.range(), [0, 1]);
<add> y.range([2, 3]);
<add> assert.equal(x.invert(2), 1);
<add> assert.equal(y.invert(2), 0);
<add> assert.deepEqual(x.range(), [1, 2]);
<add> assert.deepEqual(y.range(), [2, 3]);
<add> },
<add> "changes to the exponent are isolated": function(sqrt) {
<add> var x = sqrt().exponent(2), y = x.copy();
<add> x.exponent(.5);
<add> assert.inDelta(x(.5), Math.SQRT1_2, 1e-6);
<add> assert.inDelta(y(.5), 0.25, 1e-6);
<add> assert.equal(x.exponent(), .5);
<add> assert.equal(y.exponent(), 2);
<add> y.exponent(3);
<add> assert.inDelta(x(.5), Math.SQRT1_2, 1e-6);
<add> assert.inDelta(y(.5), 0.125, 1e-6);
<add> assert.equal(x.exponent(), .5);
<add> assert.equal(y.exponent(), 3);
<add> },
<add> "changes to the interpolator are isolated": function(sqrt) {
<add> var x = sqrt().range(["red", "blue"]), y = x.copy();
<add> x.interpolate(d3.interpolateHsl);
<add> assert.equal(x(0.5), "#00ffd3");
<add> assert.equal(y(0.5), "rgb(75,0,180)");
<add> assert.equal(y.interpolate(), d3.interpolate);
<add> },
<add> "changes to clamping are isolated": function(sqrt) {
<add> var x = sqrt().clamp(true), y = x.copy();
<add> x.clamp(false);
<add> assert.equal(x(2), Math.SQRT2);
<add> assert.equal(y(2), 1);
<add> assert.isTrue(y.clamp());
<add> y.clamp(false);
<add> assert.equal(x(2), Math.SQRT2);
<add> assert.equal(y(2), Math.SQRT2);
<add> assert.isFalse(x.clamp());
<add> }
<add> }
<add> }
<add>});
<add>
<add>suite.export(module); | 10 |
Ruby | Ruby | improve xcode and clt config reporting | 5ce1caa1f3679244ed120e3f091001c5afabcf74 | <ide><path>Library/Homebrew/cmd/--config.rb
<ide> def clang_build
<ide> @clang_build ||= MacOS.clang_build_version
<ide> end
<ide>
<del> def describe_xcode
<del> @describe_xcode ||= begin
<del> default_prefix = case MacOS.version
<del> when 10.5, 10.6 then '/Developer'
<del> else '/Applications/Xcode.app/Contents/Developer'
<del> end
<del>
<del> guess = '(guessed)' unless MacOS::Xcode.installed?
<del> prefix = if MacOS::Xcode.installed?
<del> "=> #{MacOS::Xcode.prefix}" unless MacOS::Xcode.prefix.to_s == default_prefix
<del> end
<del>
<del> [MacOS::Xcode.version, guess, prefix].compact.join(' ')
<add> def xcode
<add> if instance_variable_defined?(:@xcode)
<add> @xcode
<add> elsif MacOS::Xcode.installed?
<add> @xcode = MacOS::Xcode.version
<add> @xcode += " => #{MacOS::Xcode.prefix}" unless MacOS::Xcode.default_prefix?
<add> @xcode
<ide> end
<ide> end
<ide>
<del> def describe_clt
<del> @describe_clt ||= if MacOS::CLT.installed? then MacOS::CLT.version else 'N/A' end
<add> def clt
<add> if instance_variable_defined?(:@clt)
<add> @clt
<add> elsif MacOS::CLT.installed? && MacOS::Xcode.version.to_f >= 4.3
<add> @clt = MacOS::CLT.version
<add> end
<ide> end
<ide>
<ide> def head
<ide> def dump_build_config
<ide> puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.to_s != "#{HOMEBREW_PREFIX}/Cellar"
<ide> puts hardware
<ide> puts "OS X: #{MACOS_FULL_VERSION}-#{kernel}"
<del> puts "Xcode: #{describe_xcode}"
<del> puts "CLT: #{describe_clt}" if MacOS::Xcode.version.to_f >= 4.3
<add> puts "Xcode: #{xcode}" if xcode
<add> puts "CLT: #{clt}" if clt
<ide> puts "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby:\n #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}" if RUBY_VERSION.to_f != 1.8
<ide>
<ide> unless MacOS.compilers_standard?
<ide> def dump_verbose_config
<ide> puts "HOMEBREW_CELLAR: #{HOMEBREW_CELLAR}"
<ide> puts hardware
<ide> puts "OS X: #{MACOS_FULL_VERSION}-#{kernel}"
<del> puts "Xcode: #{describe_xcode}"
<del> puts "CLT: #{describe_clt}\n" if MacOS::Xcode.version.to_f >= 4.3
<add> puts "Xcode: #{xcode}" if xcode
<add> puts "CLT: #{clt}" if clt
<ide> puts "GCC-4.0: build #{gcc_40}" if gcc_40
<ide> puts "GCC-4.2: build #{gcc_42}" if gcc_42
<ide> puts "LLVM-GCC: #{llvm ? "build #{llvm}" : "N/A"}"
<ide> def dump_c1
<ide> print MACOS_FULL_VERSION
<ide> print "-#{kernel}" if MacOS.version < :lion
<ide> print ' '
<del> if MacOS::Xcode.version > "4.3"
<del> print MacOS::Xcode.prefix unless MacOS::Xcode.prefix.to_s =~ %r{^/Applications/Xcode.app}
<del> else
<del> print MacOS::Xcode.prefix unless MacOS::Xcode.prefix.to_s =~ %r{^/Developer}
<del> end
<add> print MacOS::Xcode.prefix unless MacOS::Xcode.default_prefix?
<ide> print "#{MacOS::Xcode.version}"
<ide> print "-noclt" unless MacOS::CLT.installed?
<ide> print " clang-#{clang_build} llvm-#{llvm} "
<ide><path>Library/Homebrew/macos/xcode.rb
<ide> def provides_autotools?
<ide> def provides_gcc?
<ide> version.to_f < 4.3
<ide> end
<add>
<add> def default_prefix?
<add> if version.to_f < 4.3
<add> %r{^/Developer} === prefix
<add> else
<add> %r{^/Applications/Xcode.app} === prefix
<add> end
<add> end
<ide> end
<ide>
<ide> module MacOS::CLT extend self | 2 |
Text | Text | synchronize argument names for appendfile() | a00f76c360a223464f330b8a19612c8a0991f6c8 | <ide><path>doc/api/fs.md
<ide> try {
<ide> }
<ide> ```
<ide>
<del>## fs.appendFile(file, data[, options], callback)
<add>## fs.appendFile(path, data[, options], callback)
<ide> <!-- YAML
<ide> added: v0.6.7
<ide> changes:
<ide> changes:
<ide> description: The `file` parameter can be a file descriptor now.
<ide> -->
<ide>
<del>* `file` {string|Buffer|URL|number} filename or file descriptor
<add>* `path` {string|Buffer|URL|number} filename or file descriptor
<ide> * `data` {string|Buffer}
<ide> * `options` {Object|string}
<ide> * `encoding` {string|null} **Default:** `'utf8'`
<ide> If `options` is a string, then it specifies the encoding. Example:
<ide> fs.appendFile('message.txt', 'data to append', 'utf8', callback);
<ide> ```
<ide>
<del>The `file` may be specified as a numeric file descriptor that has been opened
<add>The `path` may be specified as a numeric file descriptor that has been opened
<ide> for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will
<ide> not be closed automatically.
<ide>
<ide> fs.open('message.txt', 'a', (err, fd) => {
<ide> });
<ide> ```
<ide>
<del>## fs.appendFileSync(file, data[, options])
<add>## fs.appendFileSync(path, data[, options])
<ide> <!-- YAML
<ide> added: v0.6.7
<ide> changes:
<ide> changes:
<ide> description: The `file` parameter can be a file descriptor now.
<ide> -->
<ide>
<del>* `file` {string|Buffer|URL|number} filename or file descriptor
<add>* `path` {string|Buffer|URL|number} filename or file descriptor
<ide> * `data` {string|Buffer}
<ide> * `options` {Object|string}
<ide> * `encoding` {string|null} **Default:** `'utf8'`
<ide> If `options` is a string, then it specifies the encoding. Example:
<ide> fs.appendFileSync('message.txt', 'data to append', 'utf8');
<ide> ```
<ide>
<del>The `file` may be specified as a numeric file descriptor that has been opened
<add>The `path` may be specified as a numeric file descriptor that has been opened
<ide> for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will
<ide> not be closed automatically.
<ide>
<ide> condition, since other processes may change the file's state between the two
<ide> calls. Instead, user code should open/read/write the file directly and handle
<ide> the error raised if the file is not accessible.
<ide>
<del>### fsPromises.appendFile(file, data[, options])
<add>### fsPromises.appendFile(path, data[, options])
<ide> <!-- YAML
<ide> added: v10.0.0
<ide> -->
<ide>
<del>* `file` {string|Buffer|URL|FileHandle} filename or `FileHandle`
<add>* `path` {string|Buffer|URL|FileHandle} filename or `FileHandle`
<ide> * `data` {string|Buffer}
<ide> * `options` {Object|string}
<ide> * `encoding` {string|null} **Default:** `'utf8'`
<ide> resolved with no arguments upon success.
<ide>
<ide> If `options` is a string, then it specifies the encoding.
<ide>
<del>The `file` may be specified as a `FileHandle` that has been opened
<add>The `path` may be specified as a `FileHandle` that has been opened
<ide> for appending (using `fsPromises.open()`).
<ide>
<ide> ### fsPromises.chmod(path, mode) | 1 |
Text | Text | rewrite documentation for insecure registries | 5937663a08d9e7ddc9347c4fc33a506d3d596ccd | <ide><path>docs/sources/reference/commandline/cli.md
<ide> expect an integer, and they can only be specified once.
<ide> -g, --graph="/var/lib/docker" Path to use as the root of the Docker runtime
<ide> -H, --host=[] The socket(s) to bind to in daemon mode or connect to in client mode, specified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.
<ide> --icc=true Enable inter-container communication
<del> --insecure-registry=[] Enable insecure communication with specified registries (no certificate verification for HTTPS and enable HTTP fallback) (ex: localhost:5000 or 10.20.0.0/16)
<add> --insecure-registry=[] Enable insecure communication with specified registries (disables certificate verification for HTTPS and enables HTTP fallback) (e.g., localhost:5000 or 10.20.0.0/16)
<ide> --ip=0.0.0.0 Default IP address to use when binding container ports
<ide> --ip-forward=true Enable net.ipv4.ip_forward
<ide> --ip-masq=true Enable IP masquerading for bridge's IP range
<ide> To set the DNS server for all Docker containers, use
<ide> To set the DNS search domain for all Docker containers, use
<ide> `docker -d --dns-search example.com`.
<ide>
<add>### Insecure registries
<add>
<add>Docker considers a private registry either secure or insecure.
<add>In the rest of this section, *registry* is used for *private registry*, and `myregistry:5000`
<add>is a placeholder example for a private registry.
<add>
<add>A secure registry uses TLS and a copy of its CA certificate is placed on the Docker host at
<add>`/etc/docker/certs.d/myregistry:5000/ca.crt`.
<add>An insecure registry is either not using TLS (i.e., listening on plain text HTTP), or is using
<add>TLS with a CA certificate not known by the Docker daemon. The latter can happen when the
<add>certificate was not found under `/etc/docker/certs.d/myregistry:5000/`, or if the certificate
<add>verification failed (i.e., wrong CA).
<add>
<add>By default, Docker assumes all, but local (see local registries below), registries are secure.
<add>Communicating with an insecure registry is not possible if Docker assumes that registry is secure.
<add>In order to communicate with an insecure registry, the Docker daemon requires `--insecure-registry`
<add>in one of the following two forms:
<add>
<add>* `--insecure-registry myregistry:5000` tells the Docker daemon that myregistry:5000 should be considered insecure.
<add>* `--insecure-registry 10.1.0.0/16` tells the Docker daemon that all registries whose domain resolve to an IP address is part
<add>of the subnet described by the CIDR syntax, should be considered insecure.
<add>
<add>The flag can be used multiple times to allow multiple registries to be marked as insecure.
<add>
<add>If an insecure registry is not marked as insecure, `docker pull`, `docker push`, and `docker search`
<add>will result in an error message prompting the user to either secure or pass the `--insecure-registry`
<add>flag to the Docker daemon as described above.
<add>
<add>Local registries, whose IP address falls in the 127.0.0.0/8 range, are automatically marked as insecure
<add>as of Docker 1.3.2. It is not recommended to rely on this, as it may change in the future.
<add>
<add>
<ide> ### Miscellaneous options
<ide>
<ide> IP masquerading uses address translation to allow containers without a public IP to talk
<ide> to other machines on the Internet. This may interfere with some network topologies and
<ide> can be disabled with --ip-masq=false.
<ide>
<del>
<del>By default, Docker will assume all registries are secured via TLS with certificate verification
<del>enabled. Prior versions of Docker used an auto fallback if a registry did not support TLS
<del>(or if the TLS connection failed). This introduced the opportunity for Man In The Middle (MITM)
<del>attacks, so as of Docker 1.3.1, the user must now specify the `--insecure-registry` daemon flag
<del>for each insecure registry. An insecure registry is either not using TLS (i.e. plain text HTTP),
<del>or is using TLS with a CA certificate not known by the Docker daemon (i.e. certification
<del>verification disabled). For example, if there is a registry listening for HTTP at 127.0.0.1:5000,
<del>as of Docker 1.3.1 you are required to specify `--insecure-registry 127.0.0.1:5000` when starting
<del>the Docker daemon.
<del>
<del>
<ide> Docker supports softlinks for the Docker data directory
<ide> (`/var/lib/docker`) and for `/var/lib/docker/tmp`. The `DOCKER_TMPDIR` and the data directory can be set like this:
<ide> | 1 |
Go | Go | remove grpc logging to stderr | b0280c37a08a77871947b1045073601deb601eaa | <ide><path>libcontainerd/remote_linux.go
<ide> package libcontainerd
<ide> import (
<ide> "fmt"
<ide> "io"
<add> "io/ioutil"
<add> "log"
<ide> "net"
<ide> "os"
<ide> "os/exec"
<ide> import (
<ide> "github.com/docker/docker/utils"
<ide> "golang.org/x/net/context"
<ide> "google.golang.org/grpc"
<add> "google.golang.org/grpc/grpclog"
<ide> )
<ide>
<ide> const (
<ide> func New(stateDir string, options ...RemoteOption) (_ Remote, err error) {
<ide> }
<ide> }
<ide>
<add> // don't output the grpc reconnect logging
<add> grpclog.SetLogger(log.New(ioutil.Discard, "", log.LstdFlags))
<ide> dialOpts := append([]grpc.DialOption{grpc.WithInsecure()},
<ide> grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
<ide> return net.DialTimeout("unix", addr, timeout) | 1 |
PHP | PHP | add missing parent calls | 6699ced02e46ec4adc418d8a570aabc70aa03c9e | <ide><path>tests/TestCase/Database/TypeTest.php
<ide> public function setUp() {
<ide> * @return void
<ide> */
<ide> public function tearDown() {
<add> parent::tearDown();
<add>
<ide> Type::map($this->_originalMap);
<ide> }
<ide>
<ide><path>tests/TestCase/Model/Behavior/CounterCacheBehaviorTest.php
<ide> public function setUp() {
<ide> * @return void
<ide> */
<ide> public function tearDown() {
<add> parent::tearDown();
<add>
<ide> unset($this->user, $this->post);
<ide> TableRegistry::clear();
<ide> }
<ide><path>tests/TestCase/ORM/QueryRegressionTest.php
<ide> class QueryRegressionTest extends TestCase {
<ide> * @return void
<ide> */
<ide> public function tearDown() {
<add> parent::tearDown();
<add>
<ide> TableRegistry::clear();
<ide> }
<ide>
<ide><path>tests/TestCase/Routing/Filter/AssetDispatcherTest.php
<ide> class AssetDispatcherTest extends TestCase {
<ide> * @return void
<ide> */
<ide> public function tearDown() {
<add> parent::tearDown();
<add>
<ide> Configure::write('Dispatcher.filters', array());
<ide> }
<ide>
<ide><path>tests/TestCase/Utility/ViewVarsTraitTest.php
<ide> class ViewVarsTraitTest extends TestCase {
<ide> * @return void
<ide> */
<ide> public function setUp() {
<add> parent::setUp();
<add>
<ide> $this->subject = $this->getObjectForTrait('Cake\Utility\ViewVarsTrait');
<ide> }
<ide> | 5 |
Javascript | Javascript | add if statement | 2caeea0f4d9bada8dc59fb6785361253a67b695c | <ide><path>lib/web/JsonpMainTemplate.runtime.js
<ide> module.exports = function() {
<ide> var script = document.createElement("script");
<ide> script.charset = "utf-8";
<ide> script.src = $require$.p + $hotChunkFilename$;
<del> script.crossOrigin = $crossOriginLoading$;
<add> if ($crossOriginLoading$) script.crossOrigin = $crossOriginLoading$;
<ide> head.appendChild(script);
<ide> }
<ide> | 1 |
Javascript | Javascript | fix deep imports from external packages | f96f8bb74d776c5fc0349a5745b7ee4ec9a3c615 | <ide><path>packages/ember-glimmer/tests/integration/components/contextual-components-test.js
<ide> import { Component } from '../../utils/helpers';
<ide> import { applyMixins, strip } from '../../utils/abstract-test-case';
<ide> import { moduleFor, RenderingTest } from '../../utils/test-case';
<ide> import { isEmpty } from 'ember-metal';
<del>import { A as emberA } from 'ember-runtime/mixins/array';
<add>import { A as emberA } from 'ember-runtime';
<ide>
<ide> moduleFor(
<ide> 'Components test: contextual components',
<ide><path>packages/ember-glimmer/tests/integration/components/curly-components-test.js
<ide> /* globals EmberDev */
<ide> import { set, get, observer, on, computed, run } from 'ember-metal';
<ide> import { Object as EmberObject, A as emberA, inject, Service } from 'ember-runtime';
<del>import { jQueryDisabled } from 'ember-views/system/jquery';
<add>import { jQueryDisabled } from 'ember-views';
<ide> import { ENV } from 'ember-environment';
<ide> import { Component, compile, htmlSafe } from '../../utils/helpers';
<ide> import { strip } from '../../utils/abstract-test-case';
<ide><path>packages/ember-glimmer/tests/integration/components/dynamic-components-test.js
<ide> import { set, computed } from 'ember-metal';
<del>import { jQueryDisabled } from 'ember-views/system/jquery';
<add>import { jQueryDisabled } from 'ember-views';
<ide> import { Component } from '../../utils/helpers';
<ide> import { strip } from '../../utils/abstract-test-case';
<ide> import { moduleFor, RenderingTest } from '../../utils/test-case'; | 3 |
Text | Text | update props guide to include a working example | e6143c7cf5a7357d12e0ea8c1dc5a206bee08d43 | <ide><path>guide/english/react/props/index.md
<ide> title: Props
<ide> ---
<ide> ### What are the props?
<del>Props (short for properties) are the data or functions passed into a component. They are immutable (read-only).
<ide>\ No newline at end of file
<add>
<add>Props (short for properties) are the data or functions passed into a component. They are immutable (read-only).
<add>
<add>To illustrate how props are used in components, see the following example:
<add>
<add>```javascript
<add>const props = {
<add> name: "john",
<add> age: 33,
<add> country: "Canada"
<add>};
<add>
<add>const PropTest = (props) => {
<add> return(
<add> <div
<add> name={props.name}
<add> age={props.age}
<add> country={props.country}>
<add> <ul>
<add> <li>name={props.name}</li>
<add> <li>age={props.age}</li>
<add> <li>country={props.country}</li>
<add> </ul>
<add> </div>
<add> );
<add>};
<add>
<add>ReactDOM.render(
<add> <div>
<add> <PropTest {...props}/>
<add> </div>
<add> , mountNode
<add>);
<add>```
<add>The props are created in the props constant object and then used as inputs in the component and then passed and rendered in the ReactDOM. | 1 |
Python | Python | fix the skipping | c014d1f0c64a318ef288ab8dca47aa3f29052540 | <ide><path>pytorch_transformers/tests/modeling_tf_auto_test.py
<ide>
<ide> from pytorch_transformers import is_tf_available
<ide>
<del>if is_tf_available():
<add># if is_tf_available():
<add>if False:
<ide> from pytorch_transformers import (AutoConfig, BertConfig,
<ide> TFAutoModel, TFBertModel,
<ide> TFAutoModelWithLMHead, TFBertForMaskedLM,
<ide><path>pytorch_transformers/tests/modeling_tf_bert_test.py
<ide>
<ide> from pytorch_transformers import BertConfig, is_tf_available
<ide>
<del>if False and is_tf_available():
<add>if is_tf_available():
<ide> import tensorflow as tf
<ide> from pytorch_transformers.modeling_tf_bert import (TFBertModel, TFBertForMaskedLM,
<ide> TFBertForNextSentencePrediction, | 2 |
Java | Java | polish servletserverhttprequest change | 9e16cbda4c128e827ac30b2b9771ea4c3c362986 | <ide><path>spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java
<ide> /*
<del> * Copyright 2002-2015 the original author or authors.
<add> * Copyright 2002-2016 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> public HttpMethod getMethod() {
<ide> public URI getURI() {
<ide> try {
<ide> StringBuffer url = this.servletRequest.getRequestURL();
<del> String queryStr = this.servletRequest.getQueryString();
<del> if (StringUtils.hasText(queryStr)) {
<del> url.append('?').append(queryStr);
<add> String query = this.servletRequest.getQueryString();
<add> if (StringUtils.hasText(query)) {
<add> url.append('?').append(query);
<ide> }
<ide> return new URI(url.toString());
<ide> }
<ide><path>spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java
<ide> /*
<del> * Copyright 2002-2014 the original author or authors.
<add> * Copyright 2002-2016 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> public void getMethod() throws Exception {
<ide>
<ide> @Test
<ide> public void getURI() throws Exception {
<del> URI uri = new URI("https://example.com/%E4%B8%AD%E6%96%87?redirect=https%3A%2F%2Fgithub.com%2Fspring-projects%2Fspring-framework");
<add> URI uri = new URI("http://example.com/path?query");
<add> mockRequest.setServerName(uri.getHost());
<add> mockRequest.setServerPort(uri.getPort());
<add> mockRequest.setRequestURI(uri.getPath());
<add> mockRequest.setQueryString(uri.getQuery());
<add> assertEquals("Invalid uri", uri, request.getURI());
<add> }
<add>
<add> // SPR-13876
<add>
<add> @Test
<add> public void getUriWithEncoding() throws Exception {
<add> URI uri = new URI("https://example.com/%E4%B8%AD%E6%96%87" +
<add> "?redirect=https%3A%2F%2Fgithub.com%2Fspring-projects%2Fspring-framework");
<ide> mockRequest.setScheme(uri.getScheme());
<ide> mockRequest.setServerName(uri.getHost());
<ide> mockRequest.setServerPort(uri.getPort());
<del> // NOTE: should use getRawPath() instead of getPath() is decoded, while HttpServletRequest.setRequestURI() is encoded
<ide> mockRequest.setRequestURI(uri.getRawPath());
<del> // NOTE: should use getRawQuery() instead of getQuery() is decoded, while HttpServletRequest.getQueryString() is encoded
<ide> mockRequest.setQueryString(uri.getRawQuery());
<ide> assertEquals("Invalid uri", uri, request.getURI());
<ide> }
<ide><path>spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java
<ide> /*
<del> * Copyright 2002-2015 the original author or authors.
<add> * Copyright 2002-2016 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide><path>spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/HttpSendingTransportHandlerTests.java
<ide> /*
<del> * Copyright 2002-2015 the original author or authors.
<add> * Copyright 2002-2016 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License. | 4 |
Go | Go | optimize some wrong usage and spelling | 94cefa21459a0c620e5a9c2da04df6d3a43dae17 | <ide><path>api/types/client.go
<ide> type ImageBuildOptions struct {
<ide> SessionID string
<ide>
<ide> // TODO @jhowardmsft LCOW Support: This will require extending to include
<del> // `Platform string`, but is ommited for now as it's hard-coded temporarily
<add> // `Platform string`, but is omitted for now as it's hard-coded temporarily
<ide> // to avoid API changes.
<ide> }
<ide>
<ide><path>daemon/attach.go
<ide> func (daemon *Daemon) containerAttach(c *container.Container, cfg *stream.Attach
<ide> // Wait for the container to stop before returning.
<ide> waitChan := c.Wait(context.Background(), container.WaitConditionNotRunning)
<ide> defer func() {
<del> _ = <-waitChan // Ignore returned exit code.
<add> <-waitChan // Ignore returned exit code.
<ide> }()
<ide> }
<ide>
<ide><path>daemon/daemon.go
<ide> func (daemon *Daemon) shutdownContainer(c *container.Container) error {
<ide>
<ide> // Wait without timeout for the container to exit.
<ide> // Ignore the result.
<del> _ = <-c.Wait(context.Background(), container.WaitConditionNotRunning)
<add> <-c.Wait(context.Background(), container.WaitConditionNotRunning)
<ide> return nil
<ide> }
<ide>
<ide><path>daemon/graphdriver/graphtest/testutil.go
<ide> func checkFile(drv graphdriver.Driver, layer, filename string, content []byte) e
<ide> return err
<ide> }
<ide>
<del> if bytes.Compare(fileContent, content) != 0 {
<add> if !bytes.Equal(fileContent, content) {
<ide> return fmt.Errorf("mismatched file content %v, expecting %v", fileContent, content)
<ide> }
<ide>
<ide> func checkManyFiles(drv graphdriver.Driver, layer string, count int, seed int64)
<ide>
<ide> content := randomContent(64, seed+int64(i+j))
<ide>
<del> if bytes.Compare(fileContent, content) != 0 {
<add> if !bytes.Equal(fileContent, content) {
<ide> return fmt.Errorf("mismatched file content %v, expecting %v", fileContent, content)
<ide> }
<ide> }
<ide> func checkManyLayers(drv graphdriver.Driver, layer string, count int) error {
<ide> return err
<ide> }
<ide>
<del> if bytes.Compare(layerIDBytes, []byte(layer)) != 0 {
<add> if !bytes.Equal(layerIDBytes, []byte(layer)) {
<ide> return fmt.Errorf("mismatched file content %v, expecting %v", layerIDBytes, []byte(layer))
<ide> }
<ide>
<ide> func checkManyLayers(drv graphdriver.Driver, layer string, count int) error {
<ide> if err != nil {
<ide> return err
<ide> }
<del> if bytes.Compare(thisLayerIDBytes, layerIDBytes) != 0 {
<add> if !bytes.Equal(thisLayerIDBytes, layerIDBytes) {
<ide> return fmt.Errorf("mismatched file content %v, expecting %v", thisLayerIDBytes, layerIDBytes)
<ide> }
<ide> layerIDBytes, err = ioutil.ReadFile(path.Join(layerDir, "parent-id"))
<ide><path>daemon/graphdriver/lcow/lcow.go
<ide> //
<ide> // * lcow.sandboxsize - Specifies a custom sandbox size in GB for starting a container
<ide> // -- Possible values: >= default sandbox size (opengcs defined, currently 20)
<del>// -- Default if ommitted: 20
<add>// -- Default if omitted: 20
<ide> //
<ide> // The following options are read by opengcs:
<ide> //
<ide> // * lcow.kirdpath - Specifies a custom path to a kernel/initrd pair
<ide> // -- Possible values: Any local path that is not a mapped drive
<del>// -- Default if ommitted: %ProgramFiles%\Linux Containers
<add>// -- Default if omitted: %ProgramFiles%\Linux Containers
<ide> //
<ide> // * lcow.kernel - Specifies a custom kernel file located in the `lcow.kirdpath` path
<ide> // -- Possible values: Any valid filename
<del>// -- Default if ommitted: bootx64.efi
<add>// -- Default if omitted: bootx64.efi
<ide> //
<ide> // * lcow.initrd - Specifies a custom initrd file located in the `lcow.kirdpath` path
<ide> // -- Possible values: Any valid filename
<del>// -- Default if ommitted: initrd.img
<add>// -- Default if omitted: initrd.img
<ide> //
<ide> // * lcow.bootparameters - Specifies additional boot parameters for booting in kernel+initrd mode
<ide> // -- Possible values: Any valid linux kernel boot options
<del>// -- Default if ommitted: <nil>
<add>// -- Default if omitted: <nil>
<ide> //
<ide> // * lcow.vhdx - Specifies a custom vhdx file to boot (instead of a kernel+initrd)
<ide> // -- Possible values: Any valid filename
<del>// -- Default if ommitted: uvm.vhdx under `lcow.kirdpath`
<add>// -- Default if omitted: uvm.vhdx under `lcow.kirdpath`
<ide> //
<ide> // * lcow.timeout - Specifies a timeout for utility VM operations in seconds
<ide> // -- Possible values: >=0
<del>// -- Default if ommitted: 300
<add>// -- Default if omitted: 300
<ide>
<ide> // TODO: Grab logs from SVM at terminate or errors
<ide>
<ide> func (d *Driver) Diff(id, parent string) (io.ReadCloser, error) {
<ide> ci.Unlock()
<ide>
<ide> // Start the SVM with a mapped virtual disk. Note that if the SVM is
<del> // already runing and we are in global mode, this will be
<add> // already running and we are in global mode, this will be
<ide> // hot-added.
<ide> mvd := &hcsshim.MappedVirtualDisk{
<ide> HostPath: ci.hostPath,
<ide><path>daemon/kill.go
<ide> func (daemon *Daemon) Kill(container *containerpkg.Container) error {
<ide>
<ide> // Wait for exit with no timeout.
<ide> // Ignore returned status.
<del> _ = <-container.Wait(context.Background(), containerpkg.WaitConditionNotRunning)
<add> <-container.Wait(context.Background(), containerpkg.WaitConditionNotRunning)
<ide>
<ide> return nil
<ide> }
<ide><path>daemon/stop.go
<ide> func (daemon *Daemon) containerStop(container *containerpkg.Container, seconds i
<ide> // 3. If it doesn't, then send SIGKILL
<ide> if err := daemon.Kill(container); err != nil {
<ide> // Wait without a timeout, ignore result.
<del> _ = <-container.Wait(context.Background(), containerpkg.WaitConditionNotRunning)
<add> <-container.Wait(context.Background(), containerpkg.WaitConditionNotRunning)
<ide> logrus.Warn(err) // Don't return error because we only care that container is stopped, not what function stopped it
<ide> }
<ide> }
<ide><path>hack/integration-cli-on-swarm/agent/master/call.go
<ide> func executeTests(funkerName string, testChunks [][]string) error {
<ide> }
<ide> log.Printf("Finished chunk %d [%d/%d] with %d test filters in %s, code=%d.",
<ide> chunkID, passed+failed, len(testChunks), len(tests),
<del> time.Now().Sub(chunkBegin), result.Code)
<add> time.Since(chunkBegin), result.Code)
<ide> }
<ide> }(chunkID, tests)
<ide> }
<ide> wg.Wait()
<ide> // TODO: print actual tests rather than chunks
<ide> log.Printf("Executed %d chunks in %s. PASS: %d, FAIL: %d.",
<del> len(testChunks), time.Now().Sub(begin), passed, failed)
<add> len(testChunks), time.Since(begin), passed, failed)
<ide> if failed > 0 {
<ide> return fmt.Errorf("%d chunks failed", failed)
<ide> }
<ide> func executeTestChunk(funkerName string, args types.Args) (types.Result, error)
<ide>
<ide> func executeTestChunkWithRetry(funkerName string, args types.Args) (types.Result, error) {
<ide> begin := time.Now()
<del> for i := 0; time.Now().Sub(begin) < funkerRetryTimeout; i++ {
<add> for i := 0; time.Since(begin) < funkerRetryTimeout; i++ {
<ide> result, err := executeTestChunk(funkerName, args)
<ide> if err == nil {
<ide> log.Printf("executeTestChunk(%q, %d) returned code %d in trial %d", funkerName, args.ChunkID, result.Code, i)
<ide><path>hack/integration-cli-on-swarm/agent/worker/worker.go
<ide> func handle(workerImageDigest string, executor testChunkExecutor) error {
<ide> RawLog: rawLog,
<ide> }
<ide> }
<del> elapsed := time.Now().Sub(begin)
<add> elapsed := time.Since(begin)
<ide> log.Printf("Finished chunk %d, code=%d, elapsed=%v", args.ChunkID, code, elapsed)
<ide> return types.Result{
<ide> ChunkID: args.ChunkID,
<ide><path>integration-cli/docker_cli_cp_utils_test.go
<ide> func runDockerCp(c *check.C, src, dst string, params []string) (err error) {
<ide>
<ide> args := []string{"cp"}
<ide>
<del> for _, param := range params {
<del> args = append(args, param)
<del> }
<add> args = append(args, params...)
<ide>
<ide> args = append(args, src, dst)
<ide>
<ide><path>integration-cli/docker_cli_events_test.go
<ide> func (s *DockerSuite) TestEventsTimestampFormats(c *check.C) {
<ide> // List of available time formats to --since
<ide> unixTs := func(t time.Time) string { return fmt.Sprintf("%v", t.Unix()) }
<ide> rfc3339 := func(t time.Time) string { return t.Format(time.RFC3339) }
<del> duration := func(t time.Time) string { return time.Now().Sub(t).String() }
<add> duration := func(t time.Time) string { return time.Since(t).String() }
<ide>
<ide> // --since=$start must contain only the 'untag' event
<ide> for _, f := range []func(time.Time) string{unixTs, rfc3339, duration} {
<ide><path>integration-cli/fixtures/plugin/plugin.go
<ide> import (
<ide> "golang.org/x/net/context"
<ide> )
<ide>
<del>// CreateOpt is is passed used to change the defualt plugin config before
<add>// CreateOpt is is passed used to change the default plugin config before
<ide> // creating it
<ide> type CreateOpt func(*Config)
<ide>
<ide><path>pkg/devicemapper/devmapper_log.go
<ide> import (
<ide> )
<ide>
<ide> // DevmapperLogger defines methods required to register as a callback for
<del>// logging events recieved from devicemapper. Note that devicemapper will send
<add>// logging events received from devicemapper. Note that devicemapper will send
<ide> // *all* logs regardless to callbacks (including debug logs) so it's
<ide> // recommended to not spam the console with the outputs.
<ide> type DevmapperLogger interface { | 13 |
Javascript | Javascript | add node_path support | b38c05bc95a4443c1947e5cfe42d7af004259ab6 | <ide><path>server/build/webpack.js
<ide> export default async function getBaseWebpackConfig (dir, {dev = false, isServer
<ide> }
<ide> }
<ide>
<add> // Support for NODE_PATH
<add> const nodePathList = (process.env.NODE_PATH || '')
<add> .split(process.platform === 'win32' ? ';' : ':')
<add> .filter((p) => !!p)
<add>
<ide> let totalPages
<ide>
<ide> let webpackConfig = {
<ide> export default async function getBaseWebpackConfig (dir, {dev = false, isServer
<ide> extensions: ['.js', '.jsx', '.json'],
<ide> modules: [
<ide> nextNodeModulesDir,
<del> 'node_modules'
<add> 'node_modules',
<add> ...nodePathList // Support for NODE_PATH environment variable
<ide> ],
<ide> alias: {
<ide> next: nextDir,
<ide> export default async function getBaseWebpackConfig (dir, {dev = false, isServer
<ide> modules: [
<ide> nextNodeModulesDir,
<ide> 'node_modules',
<del> path.join(__dirname, 'loaders')
<add> path.join(__dirname, 'loaders'),
<add> ...nodePathList // Support for NODE_PATH environment variable
<ide> ]
<ide> },
<ide> module: { | 1 |
Javascript | Javascript | remove map/set from rn open source | 022470ce62186ffb1a471a3a92c7bfdd579c824a | <ide><path>Libraries/Core/InitializeCore.js
<ide> const start = Date.now();
<ide>
<ide> require('./setUpGlobals');
<del>require('./polyfillES6Collections');
<ide> require('./setUpSystrace');
<ide> require('./setUpErrorHandling');
<ide> require('./polyfillPromise');
<ide><path>Libraries/Core/__tests__/MapAndSetPolyfills-test.js
<del>/**
<del> * Copyright (c) Facebook, Inc. and its affiliates.
<del> *
<del> * This source code is licensed under the MIT license found in the
<del> * LICENSE file in the root directory of this source tree.
<del> *
<del> * @format
<del> * @emails oncall+react_native
<del> */
<del>'use strict';
<del>
<del>// Save these methods so that we can restore them afterward.
<del>const {freeze, seal, preventExtensions} = Object;
<del>
<del>function setup() {
<del> jest.setMock('../../vendor/core/_shouldPolyfillES6Collection', () => true);
<del>}
<del>
<del>function cleanup() {
<del> Object.assign(Object, {freeze, seal, preventExtensions});
<del>}
<del>
<del>describe('Map polyfill', () => {
<del> setup();
<del>
<del> const Map = require('../../vendor/core/Map');
<del>
<del> it('is not native', () => {
<del> const getCode = Function.prototype.toString.call(Map.prototype.get);
<del> expect(getCode).not.toContain('[native code]');
<del> expect(getCode).toContain('getIndex');
<del> });
<del>
<del> it('should tolerate non-extensible object keys', () => {
<del> const map = new Map();
<del> const key = Object.create(null);
<del> Object.freeze(key);
<del> map.set(key, key);
<del> expect(map.size).toBe(1);
<del> expect(map.has(key)).toBe(true);
<del> map.delete(key);
<del> expect(map.size).toBe(0);
<del> expect(map.has(key)).toBe(false);
<del> });
<del>
<del> it('should not get confused by prototypal inheritance', () => {
<del> const map = new Map();
<del> const proto = Object.create(null);
<del> const base = Object.create(proto);
<del> map.set(proto, proto);
<del> expect(map.size).toBe(1);
<del> expect(map.has(proto)).toBe(true);
<del> expect(map.has(base)).toBe(false);
<del> map.set(base, base);
<del> expect(map.size).toBe(2);
<del> expect(map.get(proto)).toBe(proto);
<del> expect(map.get(base)).toBe(base);
<del> });
<del>
<del> afterAll(cleanup);
<del>});
<del>
<del>describe('Set polyfill', () => {
<del> setup();
<del>
<del> const Set = require('../../vendor/core/Set');
<del>
<del> it('is not native', () => {
<del> const addCode = Function.prototype.toString.call(Set.prototype.add);
<del> expect(addCode).not.toContain('[native code]');
<del> });
<del>
<del> it('should tolerate non-extensible object elements', () => {
<del> const set = new Set();
<del> const elem = Object.create(null);
<del> Object.freeze(elem);
<del> set.add(elem);
<del> expect(set.size).toBe(1);
<del> expect(set.has(elem)).toBe(true);
<del> set.add(elem);
<del> expect(set.size).toBe(1);
<del> set.delete(elem);
<del> expect(set.size).toBe(0);
<del> expect(set.has(elem)).toBe(false);
<del> });
<del>
<del> it('should not get confused by prototypal inheritance', () => {
<del> const set = new Set();
<del> const proto = Object.create(null);
<del> const base = Object.create(proto);
<del> set.add(proto);
<del> expect(set.size).toBe(1);
<del> expect(set.has(proto)).toBe(true);
<del> expect(set.has(base)).toBe(false);
<del> set.add(base);
<del> expect(set.size).toBe(2);
<del> expect(set.has(proto)).toBe(true);
<del> expect(set.has(base)).toBe(true);
<del> });
<del>
<del> afterAll(cleanup);
<del>});
<ide><path>Libraries/Core/polyfillES6Collections.js
<del>/**
<del> * Copyright (c) Facebook, Inc. and its affiliates.
<del> *
<del> * This source code is licensed under the MIT license found in the
<del> * LICENSE file in the root directory of this source tree.
<del> *
<del> * @flow strict-local
<del> * @format
<del> */
<del>'use strict';
<del>
<del>const {polyfillGlobal} = require('../Utilities/PolyfillFunctions');
<del>
<del>/**
<del> * Polyfill ES6 collections (Map and Set).
<del> * If you don't need these polyfills, don't use InitializeCore; just directly
<del> * require the modules you need from InitializeCore for setup.
<del> */
<del>const _shouldPolyfillCollection = require('../vendor/core/_shouldPolyfillES6Collection');
<del>if (_shouldPolyfillCollection('Map')) {
<del> // $FlowFixMe: even in strict-local mode Flow expects Map to be Flow-typed
<del> polyfillGlobal('Map', () => require('../vendor/core/Map'));
<del>}
<del>if (_shouldPolyfillCollection('Set')) {
<del> // $FlowFixMe: even in strict-local mode Flow expects Set to be Flow-typed
<del> polyfillGlobal('Set', () => require('../vendor/core/Set'));
<del>}
<ide><path>Libraries/vendor/core/Map.js
<del>/**
<del> * Copyright (c) Facebook, Inc. and its affiliates.
<del> *
<del> * This source code is licensed under the MIT license found in the
<del> * LICENSE file in the root directory of this source tree.
<del> *
<del> * @format
<del> * @preventMunge
<del> * @typechecks
<del> */
<del>
<del>/* eslint-disable no-extend-native, no-shadow-restricted-names */
<del>
<del>'use strict';
<del>
<del>const _shouldPolyfillES6Collection = require('./_shouldPolyfillES6Collection');
<del>const guid = require('./guid');
<del>const toIterator = require('./toIterator');
<del>
<del>module.exports = (function(global, undefined) {
<del> // Since our implementation is spec-compliant for the most part we can safely
<del> // delegate to a built-in version if exists and is implemented correctly.
<del> // Firefox had gotten a few implementation details wrong across different
<del> // versions so we guard against that.
<del> if (!_shouldPolyfillES6Collection('Map')) {
<del> return global.Map;
<del> }
<del>
<del> const hasOwn = Object.prototype.hasOwnProperty;
<del>
<del> /**
<del> * == ES6 Map Collection ==
<del> *
<del> * This module is meant to implement a Map collection as described in chapter
<del> * 23.1 of the ES6 specification.
<del> *
<del> * Map objects are collections of key/value pairs where both the keys and
<del> * values may be arbitrary ECMAScript language values. A distinct key value
<del> * may only occur in one key/value pair within the Map's collection.
<del> *
<del> * https://people.mozilla.org/~jorendorff/es6-draft.html#sec-map-objects
<del> *
<del> * There only two -- rather small -- deviations from the spec:
<del> *
<del> * 1. The use of untagged frozen objects as keys.
<del> * We decided not to allow and simply throw an error, because this
<del> * implementation of Map works by tagging objects used as Map keys
<del> * with a secret hash property for fast access to the object's place
<del> * in the internal _mapData array. However, to limit the impact of
<del> * this spec deviation, Libraries/Core/InitializeCore.js also wraps
<del> * Object.freeze, Object.seal, and Object.preventExtensions so that
<del> * they tag objects before making them non-extensible, by inserting
<del> * each object into a Map and then immediately removing it.
<del> *
<del> * 2. The `size` property on a map object is a regular property and not a
<del> * computed property on the prototype as described by the spec.
<del> * The reason being is that we simply want to support ES3 environments
<del> * which doesn't implement computed properties.
<del> *
<del> * == Usage ==
<del> *
<del> * var map = new Map(iterable);
<del> *
<del> * map.set(key, value);
<del> * map.get(key); // value
<del> * map.has(key); // true
<del> * map.delete(key); // true
<del> *
<del> * var iterator = map.keys();
<del> * iterator.next(); // {value: key, done: false}
<del> *
<del> * var iterator = map.values();
<del> * iterator.next(); // {value: value, done: false}
<del> *
<del> * var iterator = map.entries();
<del> * iterator.next(); // {value: [key, value], done: false}
<del> *
<del> * map.forEach(function(value, key){ this === thisArg }, thisArg);
<del> *
<del> * map.clear(); // resets map.
<del> */
<del>
<del> /**
<del> * Constants
<del> */
<del>
<del> // Kinds of map iterations 23.1.5.3
<del> const KIND_KEY = 'key';
<del> const KIND_VALUE = 'value';
<del> const KIND_KEY_VALUE = 'key+value';
<del>
<del> // In older browsers we can't create a null-prototype object so we have to
<del> // defend against key collisions with built-in methods.
<del> const KEY_PREFIX = '$map_';
<del>
<del> // This property will be used as the internal size variable to disallow
<del> // writing and to issue warnings for writings in development.
<del> let SECRET_SIZE_PROP;
<del> if (__DEV__) {
<del> SECRET_SIZE_PROP = '$size' + guid();
<del> }
<del>
<del> class Map {
<del> /**
<del> * 23.1.1.1
<del> * Takes an `iterable` which is basically any object that implements a
<del> * Symbol.iterator (@@iterator) method. The iterable is expected to be a
<del> * collection of pairs. Each pair is a key/value pair that will be used
<del> * to instantiate the map.
<del> *
<del> * @param {*} iterable
<del> */
<del> constructor(iterable) {
<del> if (!isObject(this)) {
<del> throw new TypeError('Wrong map object type.');
<del> }
<del>
<del> initMap(this);
<del>
<del> if (iterable != null) {
<del> const it = toIterator(iterable);
<del> let next;
<del> while (!(next = it.next()).done) {
<del> if (!isObject(next.value)) {
<del> throw new TypeError('Expected iterable items to be pair objects.');
<del> }
<del> this.set(next.value[0], next.value[1]);
<del> }
<del> }
<del> }
<del>
<del> /**
<del> * 23.1.3.1
<del> * Clears the map from all keys and values.
<del> */
<del> clear() {
<del> initMap(this);
<del> }
<del>
<del> /**
<del> * 23.1.3.7
<del> * Check if a key exists in the collection.
<del> *
<del> * @param {*} key
<del> * @return {boolean}
<del> */
<del> has(key) {
<del> const index = getIndex(this, key);
<del> return !!(index != null && this._mapData[index]);
<del> }
<del>
<del> /**
<del> * 23.1.3.9
<del> * Adds a key/value pair to the collection.
<del> *
<del> * @param {*} key
<del> * @param {*} value
<del> * @return {map}
<del> */
<del> set(key, value) {
<del> let index = getIndex(this, key);
<del>
<del> if (index != null && this._mapData[index]) {
<del> this._mapData[index][1] = value;
<del> } else {
<del> index = this._mapData.push([key, value]) - 1;
<del> setIndex(this, key, index);
<del> if (__DEV__) {
<del> this[SECRET_SIZE_PROP] += 1;
<del> } else {
<del> this.size += 1;
<del> }
<del> }
<del>
<del> return this;
<del> }
<del>
<del> /**
<del> * 23.1.3.6
<del> * Gets a value associated with a key in the collection.
<del> *
<del> * @param {*} key
<del> * @return {*}
<del> */
<del> get(key) {
<del> const index = getIndex(this, key);
<del> if (index == null) {
<del> return undefined;
<del> } else {
<del> return this._mapData[index][1];
<del> }
<del> }
<del>
<del> /**
<del> * 23.1.3.3
<del> * Delete a key/value from the collection.
<del> *
<del> * @param {*} key
<del> * @return {boolean} Whether the key was found and deleted.
<del> */
<del> delete(key) {
<del> const index = getIndex(this, key);
<del> if (index != null && this._mapData[index]) {
<del> setIndex(this, key, undefined);
<del> this._mapData[index] = undefined;
<del> if (__DEV__) {
<del> this[SECRET_SIZE_PROP] -= 1;
<del> } else {
<del> this.size -= 1;
<del> }
<del> return true;
<del> } else {
<del> return false;
<del> }
<del> }
<del>
<del> /**
<del> * 23.1.3.4
<del> * Returns an iterator over the key/value pairs (in the form of an Array) in
<del> * the collection.
<del> *
<del> * @return {MapIterator}
<del> */
<del> entries() {
<del> return new MapIterator(this, KIND_KEY_VALUE);
<del> }
<del>
<del> /**
<del> * 23.1.3.8
<del> * Returns an iterator over the keys in the collection.
<del> *
<del> * @return {MapIterator}
<del> */
<del> keys() {
<del> return new MapIterator(this, KIND_KEY);
<del> }
<del>
<del> /**
<del> * 23.1.3.11
<del> * Returns an iterator over the values pairs in the collection.
<del> *
<del> * @return {MapIterator}
<del> */
<del> values() {
<del> return new MapIterator(this, KIND_VALUE);
<del> }
<del>
<del> /**
<del> * 23.1.3.5
<del> * Iterates over the key/value pairs in the collection calling `callback`
<del> * with [value, key, map]. An optional `thisArg` can be passed to set the
<del> * context when `callback` is called.
<del> *
<del> * @param {function} callback
<del> * @param {?object} thisArg
<del> */
<del> forEach(callback, thisArg) {
<del> if (typeof callback !== 'function') {
<del> throw new TypeError('Callback must be callable.');
<del> }
<del>
<del> const boundCallback = callback.bind(thisArg || undefined);
<del> const mapData = this._mapData;
<del>
<del> // Note that `mapData.length` should be computed on each iteration to
<del> // support iterating over new items in the map that were added after the
<del> // start of the iteration.
<del> for (let i = 0; i < mapData.length; i++) {
<del> const entry = mapData[i];
<del> if (entry != null) {
<del> boundCallback(entry[1], entry[0], this);
<del> }
<del> }
<del> }
<del> }
<del>
<del> // 23.1.3.12
<del> Map.prototype[toIterator.ITERATOR_SYMBOL] = Map.prototype.entries;
<del>
<del> class MapIterator {
<del> /**
<del> * 23.1.5.1
<del> * Create a `MapIterator` for a given `map`. While this class is private it
<del> * will create objects that will be passed around publicily.
<del> *
<del> * @param {map} map
<del> * @param {string} kind
<del> */
<del> constructor(map, kind) {
<del> if (!(isObject(map) && map._mapData)) {
<del> throw new TypeError('Object is not a map.');
<del> }
<del>
<del> if ([KIND_KEY, KIND_KEY_VALUE, KIND_VALUE].indexOf(kind) === -1) {
<del> throw new Error('Invalid iteration kind.');
<del> }
<del>
<del> this._map = map;
<del> this._nextIndex = 0;
<del> this._kind = kind;
<del> }
<del>
<del> /**
<del> * 23.1.5.2.1
<del> * Get the next iteration.
<del> *
<del> * @return {object}
<del> */
<del> next() {
<del> if (!this instanceof Map) {
<del> throw new TypeError('Expected to be called on a MapIterator.');
<del> }
<del>
<del> const map = this._map;
<del> let index = this._nextIndex;
<del> const kind = this._kind;
<del>
<del> if (map == null) {
<del> return createIterResultObject(undefined, true);
<del> }
<del>
<del> const entries = map._mapData;
<del>
<del> while (index < entries.length) {
<del> const record = entries[index];
<del>
<del> index += 1;
<del> this._nextIndex = index;
<del>
<del> if (record) {
<del> if (kind === KIND_KEY) {
<del> return createIterResultObject(record[0], false);
<del> } else if (kind === KIND_VALUE) {
<del> return createIterResultObject(record[1], false);
<del> } else if (kind) {
<del> return createIterResultObject(record, false);
<del> }
<del> }
<del> }
<del>
<del> this._map = undefined;
<del>
<del> return createIterResultObject(undefined, true);
<del> }
<del> }
<del>
<del> // We can put this in the class definition once we have computed props
<del> // transform.
<del> // 23.1.5.2.2
<del> MapIterator.prototype[toIterator.ITERATOR_SYMBOL] = function() {
<del> return this;
<del> };
<del>
<del> /**
<del> * Helper Functions.
<del> */
<del>
<del> /**
<del> * Return an index to map.[[MapData]] array for a given Key.
<del> *
<del> * @param {map} map
<del> * @param {*} key
<del> * @return {?number}
<del> */
<del> function getIndex(map, key) {
<del> if (isObject(key)) {
<del> const hash = getHash(key);
<del> return map._objectIndex[hash];
<del> } else {
<del> const prefixedKey = KEY_PREFIX + key;
<del> if (typeof key === 'string') {
<del> return map._stringIndex[prefixedKey];
<del> } else {
<del> return map._otherIndex[prefixedKey];
<del> }
<del> }
<del> }
<del>
<del> /**
<del> * Setup an index that refer to the key's location in map.[[MapData]].
<del> *
<del> * @param {map} map
<del> * @param {*} key
<del> */
<del> function setIndex(map, key, index) {
<del> const shouldDelete = index == null;
<del>
<del> if (isObject(key)) {
<del> const hash = getHash(key);
<del> if (shouldDelete) {
<del> delete map._objectIndex[hash];
<del> } else {
<del> map._objectIndex[hash] = index;
<del> }
<del> } else {
<del> const prefixedKey = KEY_PREFIX + key;
<del> if (typeof key === 'string') {
<del> if (shouldDelete) {
<del> delete map._stringIndex[prefixedKey];
<del> } else {
<del> map._stringIndex[prefixedKey] = index;
<del> }
<del> } else {
<del> if (shouldDelete) {
<del> delete map._otherIndex[prefixedKey];
<del> } else {
<del> map._otherIndex[prefixedKey] = index;
<del> }
<del> }
<del> }
<del> }
<del>
<del> /**
<del> * Instantiate a map with internal slots.
<del> *
<del> * @param {map} map
<del> */
<del> function initMap(map) {
<del> // Data structure design inspired by Traceur's Map implementation.
<del> // We maintain an internal array for all the entries. The array is needed
<del> // to remember order. However, to have a reasonable HashMap performance
<del> // i.e. O(1) for insertion, deletion, and retrieval. We maintain indices
<del> // in objects for fast look ups. Indices are split up according to data
<del> // types to avoid collisions.
<del> map._mapData = [];
<del>
<del> // Object index maps from an object "hash" to index. The hash being a unique
<del> // property of our choosing that we associate with the object. Association
<del> // is done by ways of keeping a non-enumerable property on the object.
<del> // Ideally these would be `Object.create(null)` objects but since we're
<del> // trying to support ES3 we'll have to guard against collisions using
<del> // prefixes on the keys rather than rely on null prototype objects.
<del> map._objectIndex = {};
<del>
<del> // String index maps from strings to index.
<del> map._stringIndex = {};
<del>
<del> // Numbers, booleans, undefined, and null.
<del> map._otherIndex = {};
<del>
<del> // Unfortunately we have to support ES3 and cannot have `Map.prototype.size`
<del> // be a getter method but just a regular method. The biggest problem with
<del> // this is safety. Clients can change the size property easily and possibly
<del> // without noticing (e.g. `if (map.size = 1) {..}` kind of typo). What we
<del> // can do to mitigate use getters and setters in development to disallow
<del> // and issue a warning for changing the `size` property.
<del> if (__DEV__) {
<del> if (isES5) {
<del> // If the `SECRET_SIZE_PROP` property is already defined then we're not
<del> // in the first call to `initMap` (e.g. coming from `map.clear()`) so
<del> // all we need to do is reset the size without defining the properties.
<del> if (hasOwn.call(map, SECRET_SIZE_PROP)) {
<del> map[SECRET_SIZE_PROP] = 0;
<del> } else {
<del> Object.defineProperty(map, SECRET_SIZE_PROP, {
<del> value: 0,
<del> writable: true,
<del> });
<del> Object.defineProperty(map, 'size', {
<del> set: v => {
<del> console.error(
<del> 'PLEASE FIX ME: You are changing the map size property which ' +
<del> 'should not be writable and will break in production.',
<del> );
<del> throw new Error('The map size property is not writable.');
<del> },
<del> get: () => map[SECRET_SIZE_PROP],
<del> });
<del> }
<del>
<del> // NOTE: Early return to implement immutable `.size` in DEV.
<del> return;
<del> }
<del> }
<del>
<del> // This is a diviation from the spec. `size` should be a getter on
<del> // `Map.prototype`. However, we have to support IE8.
<del> map.size = 0;
<del> }
<del>
<del> /**
<del> * Check if something is an object.
<del> *
<del> * @param {*} o
<del> * @return {boolean}
<del> */
<del> function isObject(o) {
<del> return o != null && (typeof o === 'object' || typeof o === 'function');
<del> }
<del>
<del> /**
<del> * Create an iteration object.
<del> *
<del> * @param {*} value
<del> * @param {boolean} done
<del> * @return {object}
<del> */
<del> function createIterResultObject(value, done) {
<del> return {value, done};
<del> }
<del>
<del> // Are we in a legit ES5 environment. Spoiler alert: that doesn't include IE8.
<del> const isES5 = (function() {
<del> try {
<del> Object.defineProperty({}, 'x', {});
<del> return true;
<del> } catch (e) {
<del> return false;
<del> }
<del> })();
<del>
<del> /**
<del> * Check if an object can be extended.
<del> *
<del> * @param {object|array|function|regexp} o
<del> * @return {boolean}
<del> */
<del> function isExtensible(o) {
<del> if (!isES5) {
<del> return true;
<del> } else {
<del> return Object.isExtensible(o);
<del> }
<del> }
<del>
<del> const getHash = (function() {
<del> const propIsEnumerable = Object.prototype.propertyIsEnumerable;
<del> const hashProperty = '__MAP_POLYFILL_INTERNAL_HASH__';
<del> let hashCounter = 0;
<del>
<del> const nonExtensibleObjects = [];
<del> const nonExtensibleHashes = [];
<del>
<del> /**
<del> * Get the "hash" associated with an object.
<del> *
<del> * @param {object|array|function|regexp} o
<del> * @return {number}
<del> */
<del> return function getHash(o) {
<del> if (hasOwn.call(o, hashProperty)) {
<del> return o[hashProperty];
<del> }
<del>
<del> if (!isES5) {
<del> if (
<del> hasOwn.call(o, 'propertyIsEnumerable') &&
<del> hasOwn.call(o.propertyIsEnumerable, hashProperty)
<del> ) {
<del> return o.propertyIsEnumerable[hashProperty];
<del> }
<del> }
<del>
<del> if (isExtensible(o)) {
<del> if (isES5) {
<del> Object.defineProperty(o, hashProperty, {
<del> enumerable: false,
<del> writable: false,
<del> configurable: false,
<del> value: ++hashCounter,
<del> });
<del> return hashCounter;
<del> }
<del>
<del> if (o.propertyIsEnumerable) {
<del> // Since we can't define a non-enumerable property on the object
<del> // we'll hijack one of the less-used non-enumerable properties to
<del> // save our hash on it. Additionally, since this is a function it
<del> // will not show up in `JSON.stringify` which is what we want.
<del> o.propertyIsEnumerable = function() {
<del> return propIsEnumerable.apply(this, arguments);
<del> };
<del> return (o.propertyIsEnumerable[hashProperty] = ++hashCounter);
<del> }
<del> }
<del>
<del> // If the object is not extensible, fall back to storing it in an
<del> // array and using Array.prototype.indexOf to find it.
<del> let index = nonExtensibleObjects.indexOf(o);
<del> if (index < 0) {
<del> index = nonExtensibleObjects.length;
<del> nonExtensibleObjects[index] = o;
<del> nonExtensibleHashes[index] = ++hashCounter;
<del> }
<del> return nonExtensibleHashes[index];
<del> };
<del> })();
<del>
<del> return Map;
<del>})(Function('return this')()); // eslint-disable-line no-new-func
<ide><path>Libraries/vendor/core/Set.js
<del>/**
<del> * Copyright (c) Facebook, Inc. and its affiliates.
<del> *
<del> * This source code is licensed under the MIT license found in the
<del> * LICENSE file in the root directory of this source tree.
<del> *
<del> * @format
<del> * @preventMunge
<del> * @typechecks
<del> */
<del>
<del>/* eslint-disable no-extend-native */
<del>
<del>'use strict';
<del>
<del>const Map = require('./Map');
<del>
<del>const _shouldPolyfillES6Collection = require('./_shouldPolyfillES6Collection');
<del>const toIterator = require('./toIterator');
<del>
<del>module.exports = (function(global) {
<del> // Since our implementation is spec-compliant for the most part we can safely
<del> // delegate to a built-in version if exists and is implemented correctly.
<del> // Firefox had gotten a few implementation details wrong across different
<del> // versions so we guard against that.
<del> // These checks are adapted from es6-shim https://fburl.com/34437854
<del> if (!_shouldPolyfillES6Collection('Set')) {
<del> return global.Set;
<del> }
<del>
<del> /**
<del> * == ES6 Set Collection ==
<del> *
<del> * This module is meant to implement a Set collection as described in chapter
<del> * 23.2 of the ES6 specification.
<del> *
<del> * Set objects are collections of unique values. Where values can be any
<del> * JavaScript value.
<del> * https://people.mozilla.org/~jorendorff/es6-draft.html#sec-map-objects
<del> *
<del> * There only two -- rather small -- diviations from the spec:
<del> *
<del> * 1. The use of frozen objects as keys. @see Map module for more on this.
<del> *
<del> * 2. The `size` property on a map object is a regular property and not a
<del> * computed property on the prototype as described by the spec.
<del> * The reason being is that we simply want to support ES3 environments
<del> * which doesn't implement computed properties.
<del> *
<del> * == Usage ==
<del> *
<del> * var set = new set(iterable);
<del> *
<del> * set.set(value);
<del> * set.has(value); // true
<del> * set.delete(value); // true
<del> *
<del> * var iterator = set.keys();
<del> * iterator.next(); // {value: value, done: false}
<del> *
<del> * var iterator = set.values();
<del> * iterator.next(); // {value: value, done: false}
<del> *
<del> * var iterator = set.entries();
<del> * iterator.next(); // {value: [value, value], done: false}
<del> *
<del> * set.forEach(function(value, value){ this === thisArg }, thisArg);
<del> *
<del> * set.clear(); // resets set.
<del> */
<del>
<del> class Set {
<del> /**
<del> * 23.2.1.1
<del> *
<del> * Takes an optional `iterable` (which is basically any object that
<del> * implements a Symbol.iterator (@@iterator) method). That is a collection
<del> * of values used to instantiate the set.
<del> *
<del> * @param {*} iterable
<del> */
<del> constructor(iterable) {
<del> if (
<del> this == null ||
<del> (typeof this !== 'object' && typeof this !== 'function')
<del> ) {
<del> throw new TypeError('Wrong set object type.');
<del> }
<del>
<del> initSet(this);
<del>
<del> if (iterable != null) {
<del> const it = toIterator(iterable);
<del> let next;
<del> while (!(next = it.next()).done) {
<del> this.add(next.value);
<del> }
<del> }
<del> }
<del>
<del> /**
<del> * 23.2.3.1
<del> *
<del> * If it doesn't already exist in the collection a `value` is added.
<del> *
<del> * @param {*} value
<del> * @return {set}
<del> */
<del> add(value) {
<del> this._map.set(value, value);
<del> this.size = this._map.size;
<del> return this;
<del> }
<del>
<del> /**
<del> * 23.2.3.2
<del> *
<del> * Clears the set.
<del> */
<del> clear() {
<del> initSet(this);
<del> }
<del>
<del> /**
<del> * 23.2.3.4
<del> *
<del> * Deletes a `value` from the collection if it exists.
<del> * Returns true if the value was found and deleted and false otherwise.
<del> *
<del> * @param {*} value
<del> * @return {boolean}
<del> */
<del> delete(value) {
<del> const ret = this._map.delete(value);
<del> this.size = this._map.size;
<del> return ret;
<del> }
<del>
<del> /**
<del> * 23.2.3.5
<del> *
<del> * Returns an iterator over a collection of [value, value] tuples.
<del> */
<del> entries() {
<del> return this._map.entries();
<del> }
<del>
<del> /**
<del> * 23.2.3.6
<del> *
<del> * Iterate over the collection calling `callback` with (value, value, set).
<del> *
<del> * @param {function} callback
<del> */
<del> forEach(callback) {
<del> const thisArg = arguments[1];
<del> const it = this._map.keys();
<del> let next;
<del> while (!(next = it.next()).done) {
<del> callback.call(thisArg, next.value, next.value, this);
<del> }
<del> }
<del>
<del> /**
<del> * 23.2.3.7
<del> *
<del> * Iterate over the collection calling `callback` with (value, value, set).
<del> *
<del> * @param {*} value
<del> * @return {boolean}
<del> */
<del> has(value) {
<del> return this._map.has(value);
<del> }
<del>
<del> /**
<del> * 23.2.3.7
<del> *
<del> * Returns an iterator over the colleciton of values.
<del> */
<del> values() {
<del> return this._map.values();
<del> }
<del> }
<del>
<del> // 23.2.3.11
<del> Set.prototype[toIterator.ITERATOR_SYMBOL] = Set.prototype.values;
<del>
<del> // 23.2.3.7
<del> Set.prototype.keys = Set.prototype.values;
<del>
<del> function initSet(set) {
<del> set._map = new Map();
<del> set.size = set._map.size;
<del> }
<del>
<del> return Set;
<del>})(Function('return this')()); // eslint-disable-line no-new-func
<ide><path>Libraries/vendor/core/_shouldPolyfillES6Collection.js
<del>/**
<del> * Copyright (c) Facebook, Inc. and its affiliates.
<del> *
<del> * This source code is licensed under the MIT license found in the
<del> * LICENSE file in the root directory of this source tree.
<del> *
<del> * @format
<del> * @preventMunge
<del> * @flow strict
<del> */
<del>
<del>'use strict';
<del>
<del>/**
<del> * Checks whether a collection name (e.g. "Map" or "Set") has a native polyfill
<del> * that is safe to be used.
<del> */
<del>function _shouldActuallyPolyfillES6Collection(collectionName: string): boolean {
<del> const Collection = global[collectionName];
<del> if (Collection == null) {
<del> return true;
<del> }
<del>
<del> // The iterator protocol depends on `Symbol.iterator`. If a collection is
<del> // implemented, but `Symbol` is not, it's going to break iteration because
<del> // we'll be using custom "@@iterator" instead, which is not implemented on
<del> // native collections.
<del> if (typeof global.Symbol !== 'function') {
<del> return true;
<del> }
<del>
<del> const proto = Collection.prototype;
<del>
<del> // These checks are adapted from es6-shim: https://fburl.com/34437854
<del> // NOTE: `isCallableWithoutNew` and `!supportsSubclassing` are not checked
<del> // because they make debugging with "break on exceptions" difficult.
<del> return (
<del> Collection == null ||
<del> typeof Collection !== 'function' ||
<del> typeof proto.clear !== 'function' ||
<del> new Collection().size !== 0 ||
<del> typeof proto.keys !== 'function' ||
<del> typeof proto.forEach !== 'function'
<del> );
<del>}
<del>
<del>const cache: {[name: string]: boolean} = {};
<del>
<del>/**
<del> * Checks whether a collection name (e.g. "Map" or "Set") has a native polyfill
<del> * that is safe to be used and caches this result.
<del> * Make sure to make a first call to this function before a corresponding
<del> * property on global was overriden in any way.
<del> */
<del>function _shouldPolyfillES6Collection(collectionName: string) {
<del> let result = cache[collectionName];
<del> if (result !== undefined) {
<del> return result;
<del> }
<del>
<del> result = _shouldActuallyPolyfillES6Collection(collectionName);
<del> cache[collectionName] = result;
<del> return result;
<del>}
<del>
<del>module.exports = _shouldPolyfillES6Collection;
<ide><path>flow/Map.js
<del>/**
<del> * Copyright (c) Facebook, Inc. and its affiliates.
<del> *
<del> * This source code is licensed under the MIT license found in the
<del> * LICENSE file in the root directory of this source tree.
<del> *
<del> * @flow strict
<del> * @format
<del> */
<del>
<del>// These annotations are copy/pasted from the built-in Flow definitions for
<del>// Native Map.
<del>
<del>declare module 'Map' {
<del> // Use the name "MapPolyfill" so that we don't get confusing error
<del> // messages about "Using Map instead of Map".
<del> declare class MapPolyfill<K, V> {
<del> @@iterator(): Iterator<[K, V]>;
<del> constructor<Key, Value>(_: void): MapPolyfill<Key, Value>;
<del> constructor<Key, Value>(_: null): MapPolyfill<Key, Value>;
<del> constructor<Key, Value>(
<del> iterable: Iterable<[Key, Value]>,
<del> ): MapPolyfill<Key, Value>;
<del> clear(): void;
<del> delete(key: K): boolean;
<del> entries(): Iterator<[K, V]>;
<del> forEach(
<del> callbackfn: (value: V, index: K, map: MapPolyfill<K, V>) => mixed,
<del> thisArg?: any,
<del> ): void;
<del> get(key: K): V | void;
<del> has(key: K): boolean;
<del> keys(): Iterator<K>;
<del> set(key: K, value: V): MapPolyfill<K, V>;
<del> size: number;
<del> values(): Iterator<V>;
<del> }
<del>
<del> declare module.exports: typeof MapPolyfill;
<del>}
<ide><path>flow/Set.js
<del>/**
<del> * Copyright (c) Facebook, Inc. and its affiliates.
<del> *
<del> * This source code is licensed under the MIT license found in the
<del> * LICENSE file in the root directory of this source tree.
<del> *
<del> * @flow strict
<del> * @nolint
<del> * @format
<del> */
<del>
<del>// These annotations are copy/pasted from the built-in Flow definitions for
<del>// Native Set.
<del>
<del>declare module 'Set' {
<del> // Use the name "SetPolyfill" so that we don't get confusing error
<del> // messages about "Using Set instead of Set".
<del> declare class SetPolyfill<T> {
<del> @@iterator(): Iterator<T>;
<del> constructor(iterable: ?Iterable<T>): void;
<del> add(value: T): SetPolyfill<T>;
<del> clear(): void;
<del> delete(value: T): boolean;
<del> entries(): Iterator<[T, T]>;
<del> forEach(
<del> callbackfn: (value: T, index: T, set: SetPolyfill<T>) => mixed,
<del> thisArg?: any,
<del> ): void;
<del> has(value: T): boolean;
<del> keys(): Iterator<T>;
<del> size: number;
<del> values(): Iterator<T>;
<del> }
<del>
<del> declare module.exports: typeof SetPolyfill;
<del>} | 8 |
Javascript | Javascript | add stroke and other text rendering modes | 2719e8eadc007cdd5d6eb2b90a9db52a85741e57 | <ide><path>src/canvas.js
<ide> // <canvas> contexts store most of the state we need natively.
<ide> // However, PDF needs a bit more state, which we store here.
<ide>
<add>var TextRenderingMode = {
<add> FILL: 0,
<add> STROKE: 1,
<add> FILL_STROKE: 2,
<add> INVISIBLE: 3,
<add> FILL_ADD_TO_PATH: 4,
<add> STROKE_ADD_TO_PATH: 5,
<add> FILL_STROKE_ADD_TO_PATH: 6,
<add> ADD_TO_PATH: 7
<add>};
<add>
<ide> var CanvasExtraState = (function canvasExtraState() {
<ide> function constructor(old) {
<ide> // Are soft masks and alpha values shapes or opacities?
<ide> var CanvasExtraState = (function canvasExtraState() {
<ide> this.charSpacing = 0;
<ide> this.wordSpacing = 0;
<ide> this.textHScale = 1;
<del> this.textRenderingMode = 0;
<add> this.textRenderingMode = TextRenderingMode.FILL;
<ide> // Color spaces
<ide> this.fillColorSpace = new DeviceGrayCS();
<ide> this.fillColorSpaceObj = null;
<ide> var CanvasGraphics = (function canvasGraphics() {
<ide> this.ctx.font = rule;
<ide> },
<ide> setTextRenderingMode: function canvasGraphicsSetTextRenderingMode(mode) {
<del> if (mode != 0 && mode != 3)
<add> if (mode >= TextRenderingMode.FILL_ADD_TO_PATH)
<ide> TODO('unsupported text rendering mode: ' + mode);
<ide> this.current.textRenderingMode = mode;
<ide> },
<ide> var CanvasGraphics = (function canvasGraphics() {
<ide> var charWidth = glyph.width * fontSize * 0.001 + charSpacing;
<ide>
<ide> switch (textRenderingMode) {
<del> default: // unsupported rendering mode
<del> case 0: // fill
<add> default: // other unsupported rendering modes
<add> case TextRenderingMode.FILL:
<add> case TextRenderingMode.FILL_ADD_TO_PATH:
<ide> ctx.fillText(char, width, 0);
<ide> break;
<del> case 3: // invisible
<add> case TextRenderingMode.STROKE:
<add> case TextRenderingMode.STROKE_ADD_TO_PATH:
<add> ctx.strokeText(char, width, 0);
<add> break;
<add> case TextRenderingMode.FILL_STROKE:
<add> case TextRenderingMode.FILL_STROKE_ADD_TO_PATH:
<add> ctx.fillText(char, width, 0);
<add> ctx.strokeText(char, width, 0);
<add> break;
<add> case TextRenderingMode.INVISIBLE:
<add> break;
<ide> }
<ide>
<ide> width += charWidth; | 1 |
Text | Text | add changes for 1.5.0-rc.2 | 5a3504abdce38b9ebb01b1f5a6e45e675ae4488c | <ide><path>CHANGELOG.md
<add><a name="1.5.0-rc.2"></a>
<add># 1.5.0-rc.2 controller-requisition (2016-01-28)
<add>
<add>## Deprecation Warning
<add>
<add>- The `ngTouch` module's `ngClick` directive has been deprecated and disabled by default. See the breaking
<add>changes section for more information
<add>
<add>## Bug Fixes
<add>
<add>- **$compile:**
<add> - properly denormalize templates when only one of the start/end symbols is different
<add> ([8348365d](https://github.com/angular/angular.js/commit/8348365df9b9e2d4c9c8d5211e3424d4b9a29767),
<add> [#13848](https://github.com/angular/angular.js/issues/13848))
<add> - handle boolean attributes in `@` bindings
<add> ([db5e0ffe](https://github.com/angular/angular.js/commit/db5e0ffe124ac588f01ef0fe79efebfa72f5eec7),
<add> [#13767](https://github.com/angular/angular.js/issues/13767), [#13769](https://github.com/angular/angular.js/issues/13769))
<add>- **$parse:** Preserve expensive checks when runnning $eval inside an expression
<add> ([acfda102](https://github.com/angular/angular.js/commit/acfda1022d23ecaea34bbc8931588a0715b3ab03))
<add>- **dateFilter:** follow the CLDR on pattern escape sequences
<add> ([1ab4e444](https://github.com/angular/angular.js/commit/1ab4e44443716c33cd857dcb1098d20580dbb0cc),
<add> [#12839](https://github.com/angular/angular.js/issues/12839))
<add>- **ngAnimate:**
<add> - cancel fallback timeout when animation ends normally
<add> ([e9c406b2](https://github.com/angular/angular.js/commit/e9c406b2464614c9784f7324d8910180c81c38a7),
<add> [#13787](https://github.com/angular/angular.js/issues/13787))
<add> - correctly handle `$animate.pin()` host elements
<add> ([7700e2df](https://github.com/angular/angular.js/commit/7700e2df096cf50dfdf84841cab7e2d24d2eb96d),
<add> [#13783](https://github.com/angular/angular.js/issues/13783))
<add> - properly cancel-out previously running class-based animations
<add> ([20b8ece4](https://github.com/angular/angular.js/commit/20b8ece444408a64ac69f7b5d45ddb3af0c418a0),
<add> [#10156](https://github.com/angular/angular.js/issues/10156), [#13822](https://github.com/angular/angular.js/issues/13822))
<add> - ensure that animate promises resolve when the document is hidden
<add> ([52ea4110](https://github.com/angular/angular.js/commit/52ea4110d33b7de2845a698913682a03365aa074))
<add> - do not trigger animations if the document is hidden
<add> ([a3a7afd3](https://github.com/angular/angular.js/commit/a3a7afd3aa70d981b0210088df53fa2cf68d3a3d),
<add> [#12842](https://github.com/angular/angular.js/issues/12842), [#13776](https://github.com/angular/angular.js/issues/13776))
<add>- **ngSanitize:** Blacklist the attribute `usemap`
<add> ([234053fc](https://github.com/angular/angular.js/commit/234053fc9ad90e0d05be7e8359c6af66be94c094))
<add>- **ngTouch:** deprecate ngClick and disable it by default
<add> ([0dfc1dfe](https://github.com/angular/angular.js/commit/0dfc1dfebf26af7f951f301c4e3848ac46f05d7f),
<add> [#4030](https://github.com/angular/angular.js/issues/4030), [#5307](https://github.com/angular/angular.js/issues/5307), [#6001](https://github.com/angular/angular.js/issues/6001), [#6432](https://github.com/angular/angular.js/issues/6432), [#7231](https://github.com/angular/angular.js/issues/7231), [#11358](https://github.com/angular/angular.js/issues/11358), [#12082](https://github.com/angular/angular.js/issues/12082), [#12153](https://github.com/angular/angular.js/issues/12153), [#12392](https://github.com/angular/angular.js/issues/12392), [#12545](https://github.com/angular/angular.js/issues/12545), [#12867](https://github.com/angular/angular.js/issues/12867), [#13213](https://github.com/angular/angular.js/issues/13213), [#13558](https://github.com/angular/angular.js/issues/13558), [#3296](https://github.com/angular/angular.js/issues/3296), [#3347](https://github.com/angular/angular.js/issues/3347), [#3447](https://github.com/angular/angular.js/issues/3447), [#3999](https://github.com/angular/angular.js/issues/3999), [#4428](https://github.com/angular/angular.js/issues/4428), [#6251](https://github.com/angular/angular.js/issues/6251), [#6330](https://github.com/angular/angular.js/issues/6330), [#7134](https://github.com/angular/angular.js/issues/7134), [#7935](https://github.com/angular/angular.js/issues/7935), [#9724](https://github.com/angular/angular.js/issues/9724), [#9744](https://github.com/angular/angular.js/issues/9744), [#9872](https://github.com/angular/angular.js/issues/9872), [#10211](https://github.com/angular/angular.js/issues/10211), [#10366](https://github.com/angular/angular.js/issues/10366), [#10918](https://github.com/angular/angular.js/issues/10918), [#11197](https://github.com/angular/angular.js/issues/11197), [#11261](https://github.com/angular/angular.js/issues/11261), [#11342](https://github.com/angular/angular.js/issues/11342), [#11577](https://github.com/angular/angular.js/issues/11577), [#12150](https://github.com/angular/angular.js/issues/12150), [#12317](https://github.com/angular/angular.js/issues/12317), [#12455](https://github.com/angular/angular.js/issues/12455), [#12734](https://github.com/angular/angular.js/issues/12734), [#13122](https://github.com/angular/angular.js/issues/13122), [#13272](https://github.com/angular/angular.js/issues/13272), [#13447](https://github.com/angular/angular.js/issues/13447))
<add>
<add>
<add>## Features
<add>
<add>- **$compile:**
<add> - allow required controllers to be bound to the directive controller
<add> ([56c3666f](https://github.com/angular/angular.js/commit/56c3666fe50955aa7d1c1b6159626f1c1cb34637),
<add> [#6040](https://github.com/angular/angular.js/issues/6040), [#5893](https://github.com/angular/angular.js/issues/5893), [#13763](https://github.com/angular/angular.js/issues/13763))
<add> - allow directive definition property `require` to be an object
<add> ([cd21216f](https://github.com/angular/angular.js/commit/cd21216ff7eb6d81fc9aa1d1ef994c3d8e046394),
<add> [#8401](https://github.com/angular/angular.js/issues/8401), [#13763](https://github.com/angular/angular.js/issues/13763))
<add> - call `$ngOnInit` on directive controllers after all sibling controllers have been constructed
<add> ([3ffdf380](https://github.com/angular/angular.js/commit/3ffdf380c522cbf15a4ce5a8b08d21d40d5f8859),
<add> [#13763](https://github.com/angular/angular.js/issues/13763))
<add>- **$locale:** include original locale ID in `$locale`
<add> ([63492a02](https://github.com/angular/angular.js/commit/63492a02614a33a50cc28f9fdd73bae731352dd5),
<add> [#13390](https://github.com/angular/angular.js/issues/13390))
<add>- **$resource:** add support for timeout in cancellable actions
<add> ([d641901b](https://github.com/angular/angular.js/commit/d641901be6887cdd93dc678eb514366eb759d21e),
<add> [#13824](https://github.com/angular/angular.js/issues/13824))
<add>
<add>
<add>## Performance Improvements
<add>
<add>- **$compile:** avoid needless overhead when wrapping text nodes
<add> ([92e4801d](https://github.com/angular/angular.js/commit/92e4801d88fbe9b7ef719fd3d0175d85420e1cc4))
<add>- **ngAnimate:** speed up `areAnimationsAllowed` check
<add> ([683bd92f](https://github.com/angular/angular.js/commit/683bd92f56990bf1bfeabf619d997716909ebf6b))
<add>
<add>
<add>## Breaking Changes
<add>
<add>- **ngTouch:** due to [0dfc1dfe](https://github.com/angular/angular.js/commit/0dfc1dfebf26af7f951f301c4e3848ac46f05d7f),
<add>
<add>
<add>The `ngClick` override directive from the `ngTouch` module is **deprecated and disabled by default**.
<add>This means that on touch-based devices, users might now experience a 300ms delay before a click event is fired.
<add>
<add>If you rely on this directive, you can still enable it with the `$touchProvider.ngClickOverrideEnabled()`method:
<add>
<add>```js
<add>angular.module('myApp').config(function($touchProvider) {
<add> $touchProvider.ngClickOverrideEnabled(true);
<add>});
<add>```
<add>
<add>Going forward, we recommend using [FastClick](https://github.com/ftlabs/fastclick) or perhaps one of the [Angular
<add>3rd party touch-related modules](http://ngmodules.org/tags/touch) that provide similar functionality.
<add>
<add>Also note that modern browsers already remove the 300ms delay under some circumstances:
<add>- Chrome and Firefox for Android remove the 300ms delay when the well-known `<meta name="viewport" content="width=device-width">` is set
<add>- Internet Explorer removes the delay when `touch-action` css property is set to `none` or `manipulation`
<add>- Since iOs 8, Safari removes the delay on so-called "slow taps"
<add>
<add>See this [article by Telerik](http://developer.telerik.com/featured/300-ms-click-delay-ios-8/) for more info on the topic.
<add>
<add>**Note that this change does not affect the `ngSwipe` directive.**
<add>
<add>
<ide> <a name="1.4.9"></a>
<ide> # 1.4.9 implicit-superannuation (2016-01-21)
<ide> | 1 |
PHP | PHP | remove conditionals for composer installation | c153f8548ee7c218b0e5db11817cd97f669c3f34 | <ide><path>App/Config/bootstrap.php
<ide> */
<ide> namespace App\Config;
<ide>
<del>if (file_exists(dirname(__DIR__) . 'vendor/autoload.php')) {
<del> require dirname(__DIR__) . 'vendor/autoload.php';
<add>if (!file_exists(dirname(__DIR__) . 'vendor/autoload.php')) {
<add> die('Could not find vendor/autoload.php. You need to install dependencies with composer first.');
<ide> }
<add>require dirname(__DIR__) . 'vendor/autoload.php';
<ide>
<ide> /**
<ide> * Configure paths required to find CakePHP + general filepath
<ide><path>App/Config/paths.php
<ide> /**
<ide> * The absolute path to the "cake" directory, WITHOUT a trailing DS.
<ide> *
<del> * Attempt to use composer's vendor directories. If that fails,
<del> * assume the standard lib/Cake path.
<add> * CakePHP should always be installed with composer, so look there.
<ide> */
<del>if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
<del> define('CAKE_CORE_INCLUDE_PATH', dirname(__DIR__) . '/vendor/cakephp/cakephp');
<del>} else {
<del> define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
<del>}
<add>define('CAKE_CORE_INCLUDE_PATH', dirname(__DIR__) . '/vendor/cakephp/cakephp');
<ide>
<ide> /**
<ide> * Path to the cake directory. | 2 |
PHP | PHP | add docs and simplify getshell() | c871aa3cc2fd8ef68630ce7bd3ec933d3ed17333 | <ide><path>src/Console/CommandRunner.php
<ide> public function run(array $argv, ConsoleIo $io = null)
<ide> "Unknown root command{$command}. Was expecting `{$this->root}`."
<ide> );
<ide> }
<del> $io = $io ?: new ConsoleIo();
<del>
<ide> // Remove the root executable segment
<ide> array_shift($argv);
<ide>
<del> $shell = $this->getShell($io, $commands, $argv);
<add> $io = $io ?: new ConsoleIo();
<add> $shell = $this->getShell($io, $commands, array_shift($argv));
<ide>
<del> // Remove the command name segment
<del> array_shift($argv);
<ide> try {
<ide> $shell->initialize();
<ide> $result = $shell->runCommand($argv, true);
<ide> public function run(array $argv, ConsoleIo $io = null)
<ide> }
<ide>
<ide> /**
<del> * Get the shell instance for the argv list.
<add> * Get the shell instance for a given command name
<ide> *
<add> * @param \Cake\Console\ConsoleIo $io The io wrapper for the created shell class.
<add> * @param \Cake\Console\CommandCollection $commands The command collection to find the shell in.
<add> * @param string $name The command name to find
<ide> * @return \Cake\Console\Shell
<ide> */
<del> protected function getShell(ConsoleIo $io, CommandCollection $commands, array $argv)
<add> protected function getShell(ConsoleIo $io, CommandCollection $commands, $name)
<ide> {
<del> $command = array_shift($argv);
<del> if (!$commands->has($command)) {
<add> if (!$commands->has($name)) {
<ide> throw new RuntimeException(
<del> "Unknown command `{$this->root} {$command}`." .
<add> "Unknown command `{$this->root} {$name}`." .
<ide> " Run `{$this->root} --help` to get the list of valid commands."
<ide> );
<ide> }
<del> $classOrInstance = $commands->get($command);
<add> $classOrInstance = $commands->get($name);
<ide> if (is_string($classOrInstance)) {
<ide> return new $classOrInstance($io);
<ide> } | 1 |
Text | Text | update broken link | f81ab35f821bab706401e71972a985774faf4717 | <ide><path>docs/redux-toolkit/overview.md
<ide> This is good in some cases, because it gives you flexibility, but that flexibili
<ide> - "I have to add a lot of packages to get Redux to do anything useful"
<ide> - "Redux requires too much boilerplate code"
<ide>
<del>We can't solve every use case, but in the spirit of [`create-react-app`](https://github.com/facebook/create-react-app) and [`apollo-boost`](https://dev-blog.apollodata.com/zero-config-graphql-state-management-27b1f1b3c2c3), we can provide an official recommended set of tools that handle the most common use cases and reduce the need to make extra decisions.
<add>We can't solve every use case, but in the spirit of [`create-react-app`](https://github.com/facebook/create-react-app) and [`apollo-boost`](https://www.apollographql.com/blog/announcement/frontend/zero-config-graphql-state-management/), we can provide an official recommended set of tools that handle the most common use cases and reduce the need to make extra decisions.
<ide>
<ide> ## Why You Should Use Redux Toolkit
<ide> | 1 |
Javascript | Javascript | fix typo in 'greetingbox' directive | b35e7447912dbf7791c9243033600a2830895975 | <ide><path>src/ngAnimate/module.js
<ide> * imagine we have a greeting box that shows and hides itself when the data changes
<ide> *
<ide> * ```html
<del> * <greeing-box active="onOrOff">Hi there</greeting-box>
<add> * <greeting-box active="onOrOff">Hi there</greeting-box>
<ide> * ```
<ide> *
<ide> * ```js | 1 |
Text | Text | add teletype highlights from the past week | 12dae6da82a4abdf6bbd4014193c9c321144f69a | <ide><path>docs/focus/2018-04-16.md
<ide> - Completed, merged, and shipped "Create pull request" [atom/github#1376](https://github.com/atom/github/pull/1376), which I used to open this pull request :wink:
<ide> - Updated to Enzyme 3 [atom/github#1386](https://github.com/atom/github/pull/1386) which paves the way for us to upgrade React.
<ide> - Teletype
<add> - Fixed an issue that could occur when attempting to join a portal that no longer exists while also trying to share a portal ([atom/teletype#357](https://github.com/atom/teletypeissues/atom/teletype/357))
<add> - Fixed an issue that could occur when existing portal participants are performing actions while a new participant is joining ([atom/teletype#360](https://github.com/atom/teletypeissues/atom/teletype/360))
<add> - Fixed an issue that prevented mouse clicks from placing the cursor on certain lines while participating in a portal ([atom/teletype#362](https://github.com/atom/teletypeissues/atom/teletype/362))
<add> - Published [Teletype 0.12.2](https://github.com/atom/teletype/releases/tag/v0.12.2) with the above improvements
<ide> - Xray
<ide> - Reactor Duty
<ide> | 1 |
PHP | PHP | use mixed return type | 426c1a17a39aced4f8a763b10acbb1b10a5eac28 | <ide><path>src/Illuminate/Mail/Mailer.php
<ide> public function plain($view, array $data, $callback)
<ide> * @param string|array $view
<ide> * @param array $data
<ide> * @param \Closure|string $callback
<del> * @return void
<add> * @return mixed
<ide> */
<ide> public function send($view, array $data, $callback)
<ide> { | 1 |
Text | Text | fix incorrect alias for systemd docs | 50dba638455954161215bd2b30c924cf61446eee | <ide><path>docs/admin/systemd.md
<ide> <!--[metadata]>
<ide> +++
<del>aliases = ["/engine/reference/logging/systemd/"]
<add>aliases = ["/engine/articles/systemd/"]
<ide> title = "Control and configure Docker with systemd"
<ide> description = "Controlling and configuring Docker using systemd"
<ide> keywords = ["docker, daemon, systemd, configuration"] | 1 |
Javascript | Javascript | add infrastructurelog hook to mulitcompiler | 98148b61c6b3ec8a12dc7a6a5679ac5ff3805a3a | <ide><path>lib/MultiCompiler.js
<ide> module.exports = class MultiCompiler extends Tapable {
<ide> invalid: new MultiHook(compilers.map(c => c.hooks.invalid)),
<ide> run: new MultiHook(compilers.map(c => c.hooks.run)),
<ide> watchClose: new SyncHook([]),
<del> watchRun: new MultiHook(compilers.map(c => c.hooks.watchRun))
<add> watchRun: new MultiHook(compilers.map(c => c.hooks.watchRun)),
<add> infrastructureLog: new MultiHook(
<add> compilers.map(c => c.hooks.infrastructureLog)
<add> )
<ide> };
<ide> if (!Array.isArray(compilers)) {
<ide> compilers = Object.keys(compilers).map(name => { | 1 |
Javascript | Javascript | fix error handling bug in stream.pipe() | 2b91256c6185fbcaaa5fc49a3a541e5ed0ec0e75 | <ide><path>lib/stream.js
<ide> Stream.prototype.pipe = function(dest, options) {
<ide> // don't leave dangling pipes when there are errors.
<ide> function onerror(er) {
<ide> cleanup();
<del> if (this.listeners('error').length === 1) {
<add> if (this.listeners('error').length === 0) {
<ide> throw er; // Unhandled stream error in pipe.
<ide> }
<ide> }
<ide><path>test/simple/test-stream-pipe-error-handling.js
<add>// Copyright Joyent, Inc. and other Node contributors.
<add>//
<add>// Permission is hereby granted, free of charge, to any person obtaining a
<add>// copy of this software and associated documentation files (the
<add>// "Software"), to deal in the Software without restriction, including
<add>// without limitation the rights to use, copy, modify, merge, publish,
<add>// distribute, sublicense, and/or sell copies of the Software, and to permit
<add>// persons to whom the Software is furnished to do so, subject to the
<add>// following conditions:
<add>//
<add>// The above copyright notice and this permission notice shall be included
<add>// in all copies or substantial portions of the Software.
<add>//
<add>// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
<add>// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
<add>// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
<add>// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
<add>// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
<add>// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
<add>// USE OR OTHER DEALINGS IN THE SOFTWARE.
<add>
<add>var common = require('../common');
<add>var assert = require('assert');
<add>var Stream = require('stream').Stream;
<add>
<add>(function testErrorListenerCatches() {
<add> var source = new Stream();
<add> var dest = new Stream();
<add>
<add> source.pipe(dest);
<add>
<add> var gotErr = null;
<add> source.on('error', function(err) {
<add> gotErr = err;
<add> });
<add>
<add> var err = new Error('This stream turned into bacon.');
<add> source.emit('error', err);
<add> assert.strictEqual(gotErr, err);
<add>})();
<add>
<add>(function testErrorWithoutListenerThrows() {
<add> var source = new Stream();
<add> var dest = new Stream();
<add>
<add> source.pipe(dest);
<add>
<add> var err = new Error('This stream turned into bacon.');
<add>
<add> var gotErr = null;
<add> try {
<add> source.emit('error', err);
<add> } catch (e) {
<add> gotErr = e;
<add> }
<add>
<add> assert.strictEqual(gotErr, err);
<add>})(); | 2 |
Text | Text | add rails 5.0 release notes | 3fd2e43b20709c6b67f8ff2b255b8a5e28395111 | <ide><path>guides/source/5_0_release_notes.md
<add>**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.**
<add>
<add>Ruby on Rails 5.0 Release Notes
<add>===============================
<add>
<add>Highlights in Rails 5.0:
<add>
<add>* Ruby 2.2.2+ required
<add>* ActionCable
<add>* API Mode
<add>* Exclusive use of `rails` CLI over Rake
<add>* Sprockets 3
<add>* Turbolinks 5
<add>
<add>These release notes cover only the major changes. To learn about various bug
<add>fixes and changes, please refer to the change logs or check out the [list of
<add>commits](https://github.com/rails/rails/commits/5-0-stable) in the main Rails
<add>repository on GitHub.
<add>
<add>--------------------------------------------------------------------------------
<add>
<add>Upgrading to Rails 5.0
<add>----------------------
<add>
<add>If you're upgrading an existing application, it's a great idea to have good test coverage before going in. You should also first upgrade to Rails 4.2 in case you haven't and make sure your application still runs as expected before attempting an update to Rails 5.0. A list of things to watch out for when upgrading is available in the [Upgrading Ruby on Rails](upgrading_ruby_on_rails.html#upgrading-from-rails-4-2-to-rails-5-0) guide.
<add>
<add>
<add>Creating a Rails 5.0 application
<add>--------------------------------
<add>
<add>```
<add> You should have the 'rails' RubyGem installed
<add>$ rails new myapp
<add>$ cd myapp
<add>```
<add>
<add>### Living on the Edge
<add>
<add>`Bundler` and `Gemfile` makes freezing your Rails application easy as pie with the new dedicated `bundle` command. If you want to bundle straight from the Git repository, you can pass the `--edge` flag:
<add>
<add>```
<add>$ rails new myapp --edge
<add>```
<add>
<add>If you have a local checkout of the Rails repository and want to generate an application using that, you can pass the `--dev` flag:
<add>
<add>```
<add>$ ruby /path/to/rails/railties/bin/rails new myapp --dev
<add>```
<add>
<add>Major Features
<add>--------------
<add>
<add>### Upgrade
<add>
<add>* **Ruby 2.2.2** ([commit](https://github.com/rails/rails/commit/d3b098b8289ffaa8486f526dc53204123ed581f3)) - Ruby 2.2.2+ required
<add>* **Rails API** ([commit](https://github.com/rails/rails/pull/19832)) - Rails API is merged directly into Rails
<add>* **Make ActionController::Parameters not inherited from Hash** ([Pull Request](https://github.com/rails/rails/pull/20868))
<add>* **Sprockets 3 is out** ([Upgrading Guide](https://github.com/rails/sprockets/blob/master/UPGRADING.md))
<add>
<add>### General
<add>
<add>* **Remove debugger supprt** ([commit](https://github.com/rails/rails/commit/93559da4826546d07014f8cfa399b64b4a143127)) - Debugger doesn't work with Ruby 2.2, so it is incompatible with Rails 5.0.
<add>* **Deprecated returning `false` as a way to halt ActiveRecord callback chains.** ([Pull Request](https://github.com/rails/rails/pull/17227)) - The recommended way is to `throw(:abort)`.
<add>
<add>### Security
<add>
<add>* Removal of `deep_munge` ([commit](https://github.com/rails/rails/commit/52cf1a71b393486435fab4386a8663b146608996)) - Now that we have encoding strategies, we can just walk the params hash
<add>once to encode as HashWithIndifferentAccess, and remove nils.
<add>
<add>Extraction of features to gems
<add>---------------------------
<add>
<add>In Rails 5.0, several features have been extracted into gems. You can simply add the extracted gems to your `Gemfile` to bring the functionality back.
<add>
<add>* XML Serialization ([Github](https://github.com/rails/activemodel-serializers-xml), [Pull Request](https://github.com/rails/rails/pull/21161))
<add>
<add>Action Cable
<add>-------------
<add>
<add>Please refer to the [Changelog](https://github.com/rails/rails/blob/5-0-stable/actioncable/CHANGELOG.md) for detailed changes.
<add>
<add>### Notable changes
<add>* Initial public release, and merger into Rails ([Pull Request](https://github.com/rails/rails/pull/22586))
<add>
<add>### Deprecations
<add>
<add>Action Mailer
<add>-------------
<add>
<add>Please refer to the [Changelog](https://github.com/rails/rails/blob/5-0-stable/actionmailer/CHANGELOG.md) for detailed changes.
<add>
<add>### Notable changes
<add>
<add>### Deprecations
<add>
<add>Action Pack
<add>-----------
<add>
<add>Please refer to the [Changelog](https://github.com/rails/rails/blob/5-0-stable/actionpack/CHANGELOG.md) for detailed changes.
<add>
<add>### Notable changes
<add>
<add>### Deprecations
<add>
<add>Action View
<add>-------------
<add>
<add>Please refer to the [Changelog](https://github.com/rails/rails/blob/5-0-stable/actionview/CHANGELOG.md) for detailed changes.
<add>
<add>### Notable Changes
<add>* Support explicit definition of resouce name for collection caching ([Pull Request](https://github.com/rails/rails/pull/20781))
<add>* Make `disable_with` default in `submit_tag` ([Pull Request](https://github.com/rails/rails/pull/21135))
<add>
<add>### Deprecations
<add>
<add>Active Job
<add>-----------
<add>
<add>Please refer to the [Changelog](https://github.com/rails/rails/blob/5-0-stable/activejob/CHANGELOG.md) for detailed changes.
<add>
<add>### Notable changes
<add>
<add>### Deprecations
<add>
<add>Active Model
<add>------------
<add>
<add>Please refer to the [Changelog](https://github.com/rails/rails/blob/5-0-stable/activemodel/CHANGELOG.md) for detailed changes.
<add>
<add>### Notable changes
<add>* Validate multiple contexts on `valid?` and `invalid?` at once ([Pull Request](https://github.com/rails/rails/pull/21069))
<add>
<add>### Deprecations
<add>
<add>* Deprecated returning `false` as a way to halt ActiveModel and ActiveModel::Valdiations callback chains. The recommended way is to `throw(:abort)`. ([Pull Request](https://github.com/rails/rails/pull/17227))
<add>
<add>Active Record
<add>-------------
<add>
<add>Please refer to the [Changelog](https://github.com/rails/rails/blob/5-0-stable/activerecord/CHANGELOG.md) for detailed changes.
<add>
<add>### Notable changes
<add>
<add>* Add a `foreign_key` option to `references` while creating the table ([commit](https://github.com/rails/rails/commit/99a6f9e60ea55924b44f894a16f8de0162cf2702))
<add>* New attributes API ([commit](https://github.com/rails/rails/commit/8c752c7ac739d5a86d4136ab1e9d0142c4041e58))
<add>* Add `:enum_prefix`/`:enum_suffix` option to `enum` definition. ([Pull Request](https://github.com/rails/rails/pull/19813))
<add>* Add #cache_key to ActiveRecord::Relation ([Pull Request](https://github.com/rails/rails/pull/20884))
<add>* Add `ActiveRecord::Relation#outer_joins` ([Pull Request](https://github.com/rails/rails/pull/12071))
<add>* Require `belongs_to` by default ([Pull Request](https://github.com/rails/rails/pull/18937)) - Deprecate `required` option in favor of `optional` for `belongs_to`
<add>
<add>### Deprecations
<add>
<add>* Deprecated returning `false` as a way to halt ActiveRecord callback chains. The recommended way is to `throw(:abort)`. ([Pull Request](https://github.com/rails/rails/pull/17227))
<add>* Synchronize behavior of `#tables` ([Pull Request](https://github.com/rails/rails/pull/21601))
<add> * Deprecate `connection.tables` on the SQLite3 and MySQL adapters.
<add> * Deprecate passing arguments to `#tables` - the `#tables` method of some adapters (mysql2, sqlite3) would return both tables and views while others (postgresql) just return tables. To make their behavior consistent, `#tables` will return only tables in the future.
<add> * Deprecate `table_exists?` - The `#table_exists?` method would check both tables and views. To make their behavior consistent with `#tables`, `#table_exists?` will check only tables in the future.
<add>
<add>Active Support
<add>--------------
<add>
<add>Please refer to the [Changelog](https://github.com/rails/rails/blob/5-0-stable/activesupport/CHANGELOG.md) for detailed changes.
<add>
<add>### Notable changes
<add>
<add>* New config option `config.active_support.halt_callback_chains_on_return_false` to specify whether ActiveRecord, ActiveModel and ActiveModel::Validations callback chains can be halted by returning `false` in a 'before' callback. ([Pull Request](https://github.com/rails/rails/pull/17227))
<add>
<add>### Deprecations
<add>
<add>* Replace `ActiveSupport::Concurrency::Latch` with `Concurrent::CountDownLatch` from concurrent-ruby ([Pull Request](https://github.com/rails/rails/pull/20866))
<add>
<add>Railties
<add>--------
<add>
<add>Please refer to the [Changelog](https://github.com/rails/rails/blob/5-0-stable/railties/CHANGELOG.md) for detailed changes.
<add>
<add>### Notable changes
<add>
<add>* **Remove ContentLength middleware from defaults** ([Commit](https://github.com/rails/rails/commit/56903585a099ab67a7acfaaef0a02db8fe80c450)) - ContentLength is not part of the rack SPEC since [rack/rack@86ddc7a](https://github.com/rack/rack/commit/86ddc7a6ec68d7b6951c2dbd07947c4254e8bc0d). If you would like to use it, just add it as a middleware in your config.
<add>* **Begin work on Rails test runner** ([Pull Request](https://github.com/rails/rails/pull/19216)) - Work has begun on a test runner that's built right into Rails. This pull requests lays the foundations for the runner.
<add>
<add>### Deprecations
<add>
<add>Credits
<add>-------
<add>
<add>See the [full list of contributors to Rails](http://contributors.rubyonrails.org/) for the many people who spent many hours making Rails, the stable and robust framework it is. Kudos to all of them. | 1 |
PHP | PHP | clarify deprecation for public access | ec32a90434d9316e5c32b385334ad49fbee22690 | <ide><path>src/Event/Event.php
<ide> class Event implements EventInterface
<ide> /**
<ide> * Property used to retain the result value of the event listeners
<ide> *
<add> * Note: Public access is deprecated, use setResult() and getResult() instead.
<add> *
<ide> * @var mixed
<ide> */
<ide> public $result; | 1 |
Python | Python | add missing signature from nditer docstring | 7a8843a82661d1dab157f0300c7e89ca709c5fe6 | <ide><path>numpy/core/_add_newdocs.py
<ide>
<ide> add_newdoc('numpy.core', 'nditer',
<ide> """
<add> nditer(op, flags=None, op_flags=None, op_dtypes=None, order='K', casting='safe', op_axes=None, itershape=(), buffersize=0)
<add>
<ide> Efficient multi-dimensional iterator object to iterate over arrays.
<ide> To get started using this object, see the
<ide> :ref:`introductory guide to array iteration <arrays.nditer>`. | 1 |
Text | Text | change "pila completa" for "full stack" | 3e09317015853df8e183cd9511f4a0e360a42b96 | <ide><path>guide/spanish/certifications/index.md
<ide> Hay seis certificados freeCodeCamp:
<ide>
<ide> Cada currículo certificado debe tomar aproximadamente 300 horas para completarse e incluye 5 proyectos requeridos, mientras que otros desafíos son opcionales.
<ide>
<del>### El certificado de desarrollo de pila completa
<add>### El certificado de desarrollo Full Stack
<ide>
<del>Una vez que se hayan [completado](https://guide.freecodecamp.org/meta/free-code-camp-full-stack-development-certification/) los seis certificados, se emitirá [el Certificado del programa de desarrollo de pila completa](https://guide.freecodecamp.org/meta/free-code-camp-full-stack-development-certification/) freeCodeCamp. Esta distinción final significa la finalización de aproximadamente 1,800 horas de codificación con la exposición a una amplia gama de herramientas de desarrollo web.
<add>Una vez que se hayan [completado](https://guide.freecodecamp.org/meta/free-code-camp-full-stack-development-certification/) los seis certificados, se emitirá [el Certificado del programa de desarrollo Full Stack](https://guide.freecodecamp.org/meta/free-code-camp-full-stack-development-certification/) freeCodeCamp. Esta distinción final significa la finalización de aproximadamente 1,800 horas de codificación con la exposición a una amplia gama de herramientas de desarrollo web.
<ide>
<ide> Para obtener más información sobre freeCodeCamp, visite [about.freecodecamp.org](https://about.freecodecamp.org/) .
<ide>
<ide> Para obtener más información sobre el nuevo programa de certificación, consulte la publicación del foro [aquí](https://www.freecodecamp.org/forum/t/freecodecamps-new-certificates-heres-how-were-rolling-them-out/141618) .
<ide>
<ide> ### Certificación de desarrollador de Android asociado
<ide>
<del>Una excelente manera de probar las habilidades de Android y certificar eso por nada menos que Google. El enlace a la certificación y sus detalles están [aquí](https://developers.google.com/training/certification/) .
<ide>\ No newline at end of file
<add>Una excelente manera de probar las habilidades de Android y certificar eso por nada menos que Google. El enlace a la certificación y sus detalles están [aquí](https://developers.google.com/training/certification/) . | 1 |
Ruby | Ruby | move mpio and msgpack-rpc to boneyard | 108339ae0fedcf3428d1040f5562eeff38b1d9c5 | <ide><path>Library/Homebrew/tap_migrations.rb
<ide> "lmutil" => "homebrew/binary",
<ide> "mlkit" => "homebrew/boneyard",
<ide> "mlton" => "homebrew/boneyard",
<add> "mpio" => "homebrew/boneyard",
<add> "msgpack-rpc" => "homebrew/boneyard",
<ide> "mydumper" => "homebrew/boneyard",
<ide> "nlopt" => "homebrew/science",
<ide> "octave" => "homebrew/science", | 1 |
Go | Go | fix race when killing the daemon | b845ff355a3342ee3fee99196d22194706763182 | <ide><path>container.go
<ide> func (container *Container) monitor(callback execdriver.StartCallback) error {
<ide> utils.Errorf("Error running container: %s", err)
<ide> }
<ide>
<del> container.State.SetStopped(exitCode)
<del>
<del> // FIXME: there is a race condition here which causes this to fail during the unit tests.
<del> // If another goroutine was waiting for Wait() to return before removing the container's root
<del> // from the filesystem... At this point it may already have done so.
<del> // This is because State.setStopped() has already been called, and has caused Wait()
<del> // to return.
<del> // FIXME: why are we serializing running state to disk in the first place?
<del> //log.Printf("%s: Failed to dump configuration to the disk: %s", container.ID, err)
<del> if err := container.ToDisk(); err != nil {
<del> utils.Errorf("Error dumping container state to disk: %s\n", err)
<add> if container.runtime.srv.IsRunning() {
<add> container.State.SetStopped(exitCode)
<add>
<add> // FIXME: there is a race condition here which causes this to fail during the unit tests.
<add> // If another goroutine was waiting for Wait() to return before removing the container's root
<add> // from the filesystem... At this point it may already have done so.
<add> // This is because State.setStopped() has already been called, and has caused Wait()
<add> // to return.
<add> // FIXME: why are we serializing running state to disk in the first place?
<add> //log.Printf("%s: Failed to dump configuration to the disk: %s", container.ID, err)
<add> if err := container.ToDisk(); err != nil {
<add> utils.Errorf("Error dumping container state to disk: %s\n", err)
<add> }
<ide> }
<ide>
<ide> // Cleanup
<ide><path>server.go
<ide> import (
<ide> "time"
<ide> )
<ide>
<del>func (srv *Server) Close() error {
<del> return srv.runtime.Close()
<del>}
<del>
<ide> // jobInitApi runs the remote api server `srv` as a daemon,
<ide> // Only one api server can run at the same time - this is enforced by a pidfile.
<ide> // The signals SIGINT, SIGQUIT and SIGTERM are intercepted for cleanup.
<ide> func NewServer(eng *engine.Engine, config *DaemonConfig) (*Server, error) {
<ide> pushingPool: make(map[string]chan struct{}),
<ide> events: make([]utils.JSONMessage, 0, 64), //only keeps the 64 last events
<ide> listeners: make(map[string]chan utils.JSONMessage),
<add> running: true,
<ide> }
<ide> runtime.srv = srv
<ide> return srv, nil
<ide> func (srv *Server) GetEvents() []utils.JSONMessage {
<ide> return srv.events
<ide> }
<ide>
<add>func (srv *Server) SetRunning(status bool) {
<add> srv.Lock()
<add> defer srv.Unlock()
<add>
<add> srv.running = status
<add>}
<add>
<add>func (srv *Server) IsRunning() bool {
<add> srv.RLock()
<add> defer srv.RUnlock()
<add> return srv.running
<add>}
<add>
<add>func (srv *Server) Close() error {
<add> srv.SetRunning(false)
<add> return srv.runtime.Close()
<add>}
<add>
<ide> type Server struct {
<ide> sync.RWMutex
<ide> runtime *Runtime
<ide> type Server struct {
<ide> events []utils.JSONMessage
<ide> listeners map[string]chan utils.JSONMessage
<ide> Eng *engine.Engine
<add> running bool
<ide> } | 2 |
PHP | PHP | fix bug in old input check | f0639fda45fc2874986fe409d944dde21d42c6f3 | <ide><path>src/Illuminate/Foundation/Testing/TestResponse.php
<ide> public function assertSessionHasInput($key, $value = null)
<ide>
<ide> if (is_null($value)) {
<ide> PHPUnit::assertTrue(
<del> $this->session()->getOldInput($key),
<add> $this->session()->hasOldInput($key),
<ide> "Session is missing expected key [{$key}]."
<ide> );
<ide> } elseif ($value instanceof Closure) { | 1 |
PHP | PHP | add indexsql method to sqliteschema | b2b9f29a6e7a8b25a0f8f6c28d70efc0c974b551 | <ide><path>lib/Cake/Database/Schema/SqliteSchema.php
<ide> public function columnSql(Table $table, $name) {
<ide> */
<ide> public function indexSql(Table $table, $name) {
<ide> $data = $table->index($name);
<add> $out = 'CONSTRAINT ';
<add> $out .= $this->_driver->quoteIdentifier($name);
<add> if ($data['type'] === Table::INDEX_PRIMARY) {
<add> $out .= ' PRIMARY KEY';
<add> }
<add> if ($data['type'] === Table::INDEX_UNIQUE) {
<add> $out .= ' UNIQUE';
<add> }
<add> $columns = array_map(
<add> [$this->_driver, 'quoteIdentifier'],
<add> $data['columns']
<add> );
<add> return $out . ' (' . implode(', ', $columns) . ')';
<ide> }
<ide>
<ide> /**
<ide><path>lib/Cake/Test/TestCase/Database/Schema/SqliteSchemaTest.php
<ide> public function testColumnSql($name, $data, $expected) {
<ide> $this->assertEquals($expected, $schema->columnSql($table, $name));
<ide> }
<ide>
<add>/**
<add> * Provide data for testing indexSql
<add> *
<add> * @return array
<add> */
<add> public static function indexSqlProvider() {
<add> return [
<add> [
<add> 'primary',
<add> ['type' => 'primary', 'columns' => ['title']],
<add> 'CONSTRAINT "primary" PRIMARY KEY ("title")'
<add> ],
<add> [
<add> 'unique_idx',
<add> ['type' => 'unique', 'columns' => ['title', 'author_id']],
<add> 'CONSTRAINT "unique_idx" UNIQUE ("title", "author_id")'
<add> ],
<add> ];
<add> }
<add>
<add>/**
<add> * Test the indexSql method.
<add> *
<add> * @dataProvider indexSqlProvider
<add> */
<add> public function testIndexSql($name, $data, $expected) {
<add> $driver = $this->_getMockedDriver();
<add> $schema = new SqliteSchema($driver);
<add>
<add> $table = (new Table('articles'))->addColumn('title', [
<add> 'type' => 'string',
<add> 'length' => 255
<add> ])->addColumn('author_id', [
<add> 'type' => 'integer',
<add> ])->addIndex($name, $data);
<add>
<add> $this->assertEquals($expected, $schema->indexSql($table, $name));
<add> }
<add>
<ide> /**
<ide> * Get a schema instance with a mocked driver/pdo instances
<ide> * | 2 |
Javascript | Javascript | change reactversion from cjs to es module | 4469700bb60ffd62caf112e47bcfa51afdd40e47 | <ide><path>packages/shared/ReactVersion.js
<ide> * LICENSE file in the root directory of this source tree.
<ide> */
<ide>
<del>'use strict';
<del>
<ide> // TODO: this is special because it gets imported during build.
<del>module.exports = '16.13.0';
<add>export default '16.13.0';
<ide><path>scripts/release/publish-commands/update-stable-version-numbers.js
<ide> const run = async ({cwd, packages, skipPackages, tags}) => {
<ide> const sourceReactVersion = readFileSync(
<ide> sourceReactVersionPath,
<ide> 'utf8'
<del> ).replace(/module\.exports = '[^']+';/, `module.exports = '${version}';`);
<add> ).replace(/export default '[^']+';/, `export default '${version}';`);
<ide> writeFileSync(sourceReactVersionPath, sourceReactVersion);
<ide> }
<ide> };
<ide><path>scripts/release/utils.js
<ide> const updateVersionsForNext = async (cwd, reactVersion, version) => {
<ide> const sourceReactVersion = readFileSync(
<ide> sourceReactVersionPath,
<ide> 'utf8'
<del> ).replace(
<del> /module\.exports = '[^']+';/,
<del> `module.exports = '${reactVersion}';`
<del> );
<add> ).replace(/export default '[^']+';/, `export default '${reactVersion}';`);
<ide> writeFileSync(sourceReactVersionPath, sourceReactVersion);
<ide>
<ide> // Update the root package.json.
<ide><path>scripts/tasks/version-check.js
<ide>
<ide> 'use strict';
<ide>
<del>const reactVersion = require('../../package.json').version;
<add>const fs = require('fs');
<add>const ReactVersionSrc = fs.readFileSync(
<add> require.resolve('../../packages/shared/ReactVersion')
<add>);
<add>const reactVersion = /export default '([^']+)';/.exec(ReactVersionSrc)[1];
<add>
<ide> const versions = {
<ide> 'packages/react/package.json': require('../../packages/react/package.json')
<ide> .version,
<ide> 'packages/react-dom/package.json': require('../../packages/react-dom/package.json')
<ide> .version,
<ide> 'packages/react-test-renderer/package.json': require('../../packages/react-test-renderer/package.json')
<ide> .version,
<del> 'packages/shared/ReactVersion.js': require('../../packages/shared/ReactVersion'),
<add> 'packages/shared/ReactVersion.js': reactVersion,
<ide> };
<ide>
<ide> let allVersionsMatch = true; | 4 |
Javascript | Javascript | remove $ from property names | b69c6cba6e60475e38a186b4f2e735983946bbed | <ide><path>fonts.js
<ide> var FontShape = (function FontShape() {
<ide> var italic = this.italic ? 'italic' : 'normal';
<ide> this.fontFallback = this.serif ? 'serif' : 'sans-serif';
<ide>
<del> this.$name1 = italic + ' ' + bold + ' ';
<del> this.$name2 = 'px "' + name + '", "';
<add> this.namePart1 = italic + ' ' + bold + ' ';
<add> this.namePart2 = 'px "' + name + '", "';
<ide>
<ide> this.supported = Object.keys(this.encoding).length != 0;
<ide>
<ide> var FontShape = (function FontShape() {
<ide> constructor.prototype = {
<ide> getRule: function fonts_getRule(size, fallback) {
<ide> fallback = fallback || this.fontFallback;
<del> return this.$name1 + size + this.$name2 + fallback + '"';
<add> return this.namePart1 + size + this.namePart2 + fallback + '"';
<ide> },
<ide>
<ide> charsToUnicode: function fonts_chars2Unicode(chars) {
<ide><path>worker.js
<ide> var Promise = (function() {
<ide> // If you build a promise and pass in some data it's already resolved.
<ide> if (data != null) {
<ide> this.isResolved = true;
<del> this.$data = data;
<add> this._data = data;
<ide> this.hasData = true;
<ide> } else {
<ide> this.isResolved = false;
<del> this.$data = EMPTY_PROMISE;
<add> this._data = EMPTY_PROMISE;
<ide> }
<ide> this.callbacks = [];
<ide> };
<ide> var Promise = (function() {
<ide> if (data === undefined) {
<ide> return;
<ide> }
<del> if (this.$data !== EMPTY_PROMISE) {
<add> if (this._data !== EMPTY_PROMISE) {
<ide> throw "Promise " + this.name + ": Cannot set the data of a promise twice";
<ide> }
<del> this.$data = data;
<add> this._data = data;
<ide> this.hasData = true;
<ide>
<del> if (this.$onDataCallback) {
<del> this.$onDataCallback(data);
<add> if (this.onDataCallback) {
<add> this.onDataCallback(data);
<ide> }
<ide> },
<ide>
<ide> get data() {
<del> if (this.$data === EMPTY_PROMISE) {
<add> if (this._data === EMPTY_PROMISE) {
<ide> throw "Promise " + this.name + ": Cannot get data that isn't set";
<ide> }
<del> return this.$data;
<add> return this._data;
<ide> },
<ide>
<ide> onData: function(callback) {
<del> if (this.$data !== EMPTY_PROMISE) {
<del> callback(this.$data);
<add> if (this._data !== EMPTY_PROMISE) {
<add> callback(this._data);
<ide> } else {
<del> this.$onDataCallback = callback;
<add> this.onDataCallback = callback;
<ide> }
<ide> },
<ide> | 2 |
Javascript | Javascript | make diff nicer | d7364020770df94f7da56dfea8f536e6080075cc | <ide><path>src/xhr/xhr.js
<ide> import "../core/identity";
<ide> import "../core/rebind";
<ide> import "../event/dispatch";
<ide>
<del>
<ide> d3.xhr = function(url, mimeType, callback) {
<ide> return d3_xhr(url, mimeType, d3_identity, callback);
<ide> };
<ide> function d3_xhr(url, mimeType, response, callback) {
<ide>
<ide> if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType, mimeType = null;
<ide> return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback));
<del>}
<add>};
<ide>
<ide> function d3_xhr_fixCallback(callback) {
<ide> return callback.length === 1
<ide> ? function(error, request) { callback(error == null ? request : null); }
<ide> : callback;
<del>}
<ide>\ No newline at end of file
<add>} | 1 |
PHP | PHP | fix coding standards | e8494a576ac2feaba17810b7fb8ed11e887e2a09 | <ide><path>tests/TestCase/Utility/HashTest.php
<ide> public function testMergeVariadic()
<ide> {
<ide> $result = Hash::merge(
<ide> ['hkuc' => ['lion']],
<del> ['hkuc' =>'lion']
<add> ['hkuc' => 'lion']
<ide> );
<ide> $expected = ['hkuc' => 'lion'];
<ide> $this->assertEquals($expected, $result); | 1 |
Javascript | Javascript | expose agent in http and https client | 8d37f80f4b582a55d229521cce83670b60300ec0 | <ide><path>lib/http.js
<ide> function getAgent(host, port) {
<ide> exports.getAgent = getAgent;
<ide>
<ide>
<del>exports._requestFromAgent = function(agent, options, cb) {
<del> var req = agent.appendMessage(options);
<add>exports._requestFromAgent = function(options, cb) {
<add> var req = options.agent.appendMessage(options);
<add> req.agent = options.agent;
<ide> if (cb) req.once('response', cb);
<ide> return req;
<ide> };
<ide>
<ide>
<ide> exports.request = function(options, cb) {
<del> var agent = getAgent(options.host, options.port);
<del> return exports._requestFromAgent(agent, options, cb);
<add> if (options.agent === undefined) {
<add> options.agent = getAgent(options.host, options.port);
<add> } else if (options.agent === false) {
<add> options.agent = new Agent(options.host, options.port);
<add> }
<add> return exports._requestFromAgent(options, cb);
<ide> };
<ide>
<ide>
<ide><path>lib/https.js
<ide> exports.getAgent = getAgent;
<ide>
<ide>
<ide> exports.request = function(options, cb) {
<del> var agent = getAgent(options);
<del> return http._requestFromAgent(agent, options, cb);
<add> if (options.agent === undefined) {
<add> options.agent = getAgent(options);
<add> } else if (options.agent === false) {
<add> options.agent = new Agent(options);
<add> }
<add> return http._requestFromAgent(options, cb);
<ide> };
<ide>
<ide> | 2 |
Java | Java | add option to decode from a databuffer | a912d8de1ea26cd071342f919eb0c6bad4945062 | <ide><path>spring-core/src/main/java/org/springframework/core/codec/AbstractDataBufferDecoder.java
<ide> * @since 5.0
<ide> * @param <T> the element type
<ide> */
<add>@SuppressWarnings("deprecation")
<ide> public abstract class AbstractDataBufferDecoder<T> extends AbstractDecoder<T> {
<ide>
<ide>
<ide> public Mono<T> decodeToMono(Publisher<DataBuffer> input, ResolvableType elementT
<ide>
<ide> /**
<ide> * How to decode a {@code DataBuffer} to the target element type.
<add> * @deprecated as of 5.2, please implement
<add> * {@link #decode(DataBuffer, ResolvableType, MimeType, Map)} instead
<ide> */
<del> protected abstract T decodeDataBuffer(DataBuffer buffer, ResolvableType elementType,
<del> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints);
<add> @Deprecated
<add> protected T decodeDataBuffer(DataBuffer buffer, ResolvableType elementType,
<add> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
<add>
<add> return decode(buffer, elementType, mimeType, hints);
<add> }
<ide>
<ide> }
<ide><path>spring-core/src/main/java/org/springframework/core/codec/ByteArrayDecoder.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2019 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType
<ide> }
<ide>
<ide> @Override
<del> protected byte[] decodeDataBuffer(DataBuffer dataBuffer, ResolvableType elementType,
<add> public byte[] decode(DataBuffer dataBuffer, ResolvableType elementType,
<ide> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
<ide>
<ide> byte[] result = new byte[dataBuffer.readableByteCount()];
<ide><path>spring-core/src/main/java/org/springframework/core/codec/ByteBufferDecoder.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2019 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType
<ide> }
<ide>
<ide> @Override
<del> protected ByteBuffer decodeDataBuffer(DataBuffer dataBuffer, ResolvableType elementType,
<add> public ByteBuffer decode(DataBuffer dataBuffer, ResolvableType elementType,
<ide> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
<ide>
<ide> int byteCount = dataBuffer.readableByteCount();
<ide><path>spring-core/src/main/java/org/springframework/core/codec/DataBufferDecoder.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2019 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> public Flux<DataBuffer> decode(Publisher<DataBuffer> input, ResolvableType eleme
<ide> }
<ide>
<ide> @Override
<del> protected DataBuffer decodeDataBuffer(DataBuffer buffer, ResolvableType elementType,
<add> public DataBuffer decode(DataBuffer buffer, ResolvableType elementType,
<ide> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
<ide>
<ide> if (logger.isDebugEnabled()) {
<ide><path>spring-core/src/main/java/org/springframework/core/codec/Decoder.java
<ide> import org.reactivestreams.Publisher;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<add>import reactor.core.publisher.MonoProcessor;
<ide>
<ide> import org.springframework.core.ResolvableType;
<ide> import org.springframework.core.io.buffer.DataBuffer;
<ide> import org.springframework.lang.Nullable;
<add>import org.springframework.util.Assert;
<ide> import org.springframework.util.MimeType;
<ide>
<ide> /**
<ide> Flux<T> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType,
<ide> Mono<T> decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementType,
<ide> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints);
<ide>
<add> /**
<add> * Decode a data buffer to an Object of type T. This is useful when the input
<add> * stream consists of discrete messages (or events) and the content for each
<add> * can be decoded on its own.
<add> * @param buffer the {@code DataBuffer} to decode
<add> * @param targetType the expected output type
<add> * @param mimeType the MIME type associated with the data
<add> * @param hints additional information about how to do encode
<add> * @return the decoded value, possibly {@code null}
<add> * @since 5.2
<add> */
<add> @SuppressWarnings("ConstantConditions")
<add> default T decode(DataBuffer buffer, ResolvableType targetType,
<add> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) throws DecodingException {
<add>
<add> MonoProcessor<T> processor = MonoProcessor.create();
<add> decodeToMono(Mono.just(buffer), targetType, mimeType, hints).subscribeWith(processor);
<add>
<add> Assert.state(processor.isTerminated(), "DataBuffer decoding should have completed.");
<add> Throwable ex = processor.getError();
<add> if (ex != null) {
<add> throw (ex instanceof CodecException ? (CodecException) ex :
<add> new DecodingException("Failed to decode: " + ex.getMessage(), ex));
<add> }
<add> return processor.peek();
<add> }
<add>
<ide> /**
<ide> * Return the list of MIME types this decoder supports.
<ide> */
<ide><path>spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java
<ide> public Flux<Resource> decode(Publisher<DataBuffer> inputStream, ResolvableType e
<ide> }
<ide>
<ide> @Override
<del> protected Resource decodeDataBuffer(DataBuffer dataBuffer, ResolvableType elementType,
<add> public Resource decode(DataBuffer dataBuffer, ResolvableType elementType,
<ide> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
<ide>
<ide> byte[] bytes = new byte[dataBuffer.readableByteCount()];
<ide><path>spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java
<ide> private static DataBuffer joinUntilEndFrame(List<DataBuffer> dataBuffers) {
<ide> }
<ide>
<ide> @Override
<del> protected String decodeDataBuffer(DataBuffer dataBuffer, ResolvableType elementType,
<add> public String decode(DataBuffer dataBuffer, ResolvableType elementType,
<ide> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
<ide>
<ide> Charset charset = getCharset(mimeType);
<ide><path>spring-web/src/main/java/org/springframework/http/codec/json/AbstractJackson2Decoder.java
<ide> public Flux<Object> decode(Publisher<DataBuffer> input, ResolvableType elementTy
<ide> public Mono<Object> decodeToMono(Publisher<DataBuffer> input, ResolvableType elementType,
<ide> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
<ide>
<del> return DataBufferUtils.join(input).map(dataBuffer -> {
<del> try {
<del> ObjectReader objectReader = getObjectReader(elementType, hints);
<del> Object value = objectReader.readValue(dataBuffer.asInputStream());
<del> logValue(value, hints);
<del> return value;
<del> }
<del> catch (IOException ex) {
<del> throw processException(ex);
<del> }
<del> finally {
<del> DataBufferUtils.release(dataBuffer);
<del> }
<del> });
<add> return DataBufferUtils.join(input)
<add> .map(dataBuffer -> decode(dataBuffer, elementType, mimeType, hints));
<add> }
<add>
<add> @Override
<add> public Object decode(DataBuffer dataBuffer, ResolvableType targetType,
<add> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) throws DecodingException {
<add>
<add> try {
<add> ObjectReader objectReader = getObjectReader(targetType, hints);
<add> Object value = objectReader.readValue(dataBuffer.asInputStream());
<add> logValue(value, hints);
<add> return value;
<add> }
<add> catch (IOException ex) {
<add> throw processException(ex);
<add> }
<add> finally {
<add> DataBufferUtils.release(dataBuffer);
<add> }
<ide> }
<ide>
<ide> private ObjectReader getObjectReader(ResolvableType elementType, @Nullable Map<String, Object> hints) {
<ide><path>spring-web/src/main/java/org/springframework/http/codec/protobuf/ProtobufDecoder.java
<ide> public Flux<Message> decode(Publisher<DataBuffer> inputStream, ResolvableType el
<ide> public Mono<Message> decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementType,
<ide> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
<ide>
<del> return DataBufferUtils.join(inputStream).map(dataBuffer -> {
<del> try {
<del> Message.Builder builder = getMessageBuilder(elementType.toClass());
<del> ByteBuffer buffer = dataBuffer.asByteBuffer();
<del> builder.mergeFrom(CodedInputStream.newInstance(buffer), this.extensionRegistry);
<del> return builder.build();
<del> }
<del> catch (IOException ex) {
<del> throw new DecodingException("I/O error while parsing input stream", ex);
<del> }
<del> catch (Exception ex) {
<del> throw new DecodingException("Could not read Protobuf message: " + ex.getMessage(), ex);
<del> }
<del> finally {
<del> DataBufferUtils.release(dataBuffer);
<del> }
<del> }
<del> );
<add> return DataBufferUtils.join(inputStream)
<add> .map(dataBuffer -> decode(dataBuffer, elementType, mimeType, hints));
<ide> }
<ide>
<add> @Override
<add> public Message decode(DataBuffer dataBuffer, ResolvableType targetType,
<add> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) throws DecodingException {
<add>
<add> try {
<add> Message.Builder builder = getMessageBuilder(targetType.toClass());
<add> ByteBuffer buffer = dataBuffer.asByteBuffer();
<add> builder.mergeFrom(CodedInputStream.newInstance(buffer), this.extensionRegistry);
<add> return builder.build();
<add> }
<add> catch (IOException ex) {
<add> throw new DecodingException("I/O error while parsing input stream", ex);
<add> }
<add> catch (Exception ex) {
<add> throw new DecodingException("Could not read Protobuf message: " + ex.getMessage(), ex);
<add> }
<add> finally {
<add> DataBufferUtils.release(dataBuffer);
<add> }
<add> }
<add>
<add>
<ide> /**
<ide> * Create a new {@code Message.Builder} instance for the given class.
<ide> * <p>This method uses a ConcurrentHashMap for caching method lookups.
<ide><path>spring-web/src/main/java/org/springframework/http/codec/xml/Jaxb2XmlDecoder.java
<ide> public Flux<Object> decode(Publisher<DataBuffer> inputStream, ResolvableType ele
<ide> public Mono<Object> decodeToMono(Publisher<DataBuffer> input, ResolvableType elementType,
<ide> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
<ide>
<del> return DataBufferUtils.join(input).map(dataBuffer -> {
<del> try {
<del> Iterator eventReader = inputFactory.createXMLEventReader(dataBuffer.asInputStream());
<del> List<XMLEvent> events = new ArrayList<>();
<del> eventReader.forEachRemaining(event -> events.add((XMLEvent) event));
<del> return unmarshal(events, elementType.toClass());
<del> }
<del> catch (XMLStreamException ex) {
<del> throw Exceptions.propagate(ex);
<del> }
<del> finally {
<del> DataBufferUtils.release(dataBuffer);
<del> }
<del> });
<add> return DataBufferUtils.join(input)
<add> .map(dataBuffer -> decode(dataBuffer, elementType, mimeType, hints));
<add> }
<add>
<add> @Override
<add> @SuppressWarnings({"rawtypes", "unchecked", "cast"}) // XMLEventReader is Iterator<Object> on JDK 9
<add> public Object decode(DataBuffer dataBuffer, ResolvableType targetType,
<add> @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) throws DecodingException {
<add>
<add> try {
<add> Iterator eventReader = inputFactory.createXMLEventReader(dataBuffer.asInputStream());
<add> List<XMLEvent> events = new ArrayList<>();
<add> eventReader.forEachRemaining(event -> events.add((XMLEvent) event));
<add> return unmarshal(events, targetType.toClass());
<add> }
<add> catch (XMLStreamException ex) {
<add> throw Exceptions.propagate(ex);
<add> }
<add> finally {
<add> DataBufferUtils.release(dataBuffer);
<add> }
<ide> }
<ide>
<ide> private Object unmarshal(List<XMLEvent> events, Class<?> outputClass) { | 10 |
Ruby | Ruby | add a test for adding "via" using `scope` | 4c641c6e362238afbe76b9a1c9d06339f2a805c4 | <ide><path>actionpack/test/dispatch/mapper_test.rb
<ide> def test_mapping_requirements
<ide> assert_equal(/.+?/, requirements[:rest])
<ide> end
<ide>
<add> def test_via_scope
<add> fakeset = FakeSet.new
<add> mapper = Mapper.new fakeset
<add> mapper.scope(via: :put) do
<add> mapper.match '/', :to => 'posts#index', :as => :main
<add> end
<add> assert_equal ["PUT"], fakeset.conditions.first[:request_method]
<add> end
<add>
<ide> def test_map_slash
<ide> fakeset = FakeSet.new
<ide> mapper = Mapper.new fakeset | 1 |
PHP | PHP | expand doc blocks | 086dc2c1f6b250c8ded5bce733005aa8bffd7861 | <ide><path>lib/Cake/Network/Http/Adapter/Stream.php
<ide> /**
<ide> * Implements sending Cake\Network\Http\Request
<ide> * via php's stream API.
<add> *
<add> * This approach and implementation is partly inspired by Aura.Http
<ide> */
<ide> class Stream {
<ide>
<add>/**
<add> * Context resource used by the stream API.
<add> *
<add> * @var resource
<add> */
<ide> protected $_context;
<add>
<add>/**
<add> * Array of options/content for the stream context.
<add> *
<add> * @var array
<add> */
<ide> protected $_contextOptions;
<add>
<add>/**
<add> * The stream resource.
<add> *
<add> * @var resource
<add> */
<ide> protected $_stream;
<ide>
<add>/**
<add> * Send a request and get a response back.
<add> *
<add> * @param Cake\Network\Http\Request $request The request object to send.
<add> * @param array $options Array of options for the stream.
<add> * @return Cake\Network\Http\Response
<add> */
<ide> public function send(Request $request, $options) {
<ide> $this->_context = array();
<ide>
<ide> public function send(Request $request, $options) {
<ide> /**
<ide> * Build the stream context out of the request object.
<ide> *
<del> * @param Request $request The request to build context from.
<add> * @param Cake\Network\Http\Request $request The request to build context from.
<ide> * @param array $options Additional request options.
<ide> * @return void
<ide> */
<ide> protected function _buildContext(Request $request, $options) {
<ide> * Build the header context for the request.
<ide> *
<ide> * Creates cookies & headers.
<add> *
<add> * @param Cake\Network\Http\Request $request The request being sent.
<add> * @param array $options Array of options to use.
<add> * @return void
<ide> */
<ide> protected function _buildHeaders(Request $request, $options) {
<ide> $headers = [];
<ide> protected function _buildHeaders(Request $request, $options) {
<ide> * If the $request->content() is a string, it will be used as is.
<ide> * Array data will be processed with Cake\Network\Http\FormData
<ide> *
<del> * @param Request $request
<del> * @param array $options
<add> * @param Cake\Network\Http\Request $request The request being sent.
<add> * @param array $options Array of options to use.
<add> * @return void
<ide> */
<del> protected function _buildContent($request, $options) {
<add> protected function _buildContent(Request $request, $options) {
<ide> $content = $request->content();
<ide> if (empty($content)) {
<ide> return;
<ide> protected function _buildContent($request, $options) {
<ide> /**
<ide> * Build miscellaneous options for the request.
<ide> *
<del> * @param Request $request
<del> * @param array $options
<add> * @param Cake\Network\Http\Request $request The request being sent.
<add> * @param array $options Array of options to use.
<add> * @return void
<ide> */
<ide> protected function _buildOptions(Request $request, $options) {
<ide> $this->_contextOptions['method'] = $request->method();
<ide> protected function _buildOptions(Request $request, $options) {
<ide> /**
<ide> * Build SSL options for the request.
<ide> *
<del> * @param Request $request
<del> * @param array $options
<add> * @param Cake\Network\Http\Request $request The request being sent.
<add> * @param array $options Array of options to use.
<add> * @return void
<ide> */
<del> protected function _buildSslContext($request, $options) {
<add> protected function _buildSslContext(Request $request, $options) {
<ide> $sslOptions = [
<ide> 'ssl_verify_peer',
<ide> 'ssl_verify_depth', | 1 |
Go | Go | add missing parenthesis in docs for -author switch | 3fcb0d880aad65690cac304c30f72d0688a801d2 | <ide><path>api/client/commands.go
<ide> func (cli *DockerCli) CmdPs(args ...string) error {
<ide> func (cli *DockerCli) CmdCommit(args ...string) error {
<ide> cmd := cli.Subcmd("commit", "[OPTIONS] CONTAINER [REPOSITORY[:TAG]]", "Create a new image from a container's changes")
<ide> flComment := cmd.String([]string{"m", "-message"}, "", "Commit message")
<del> flAuthor := cmd.String([]string{"a", "#author", "-author"}, "", "Author (eg. \"John Hannibal Smith <hannibal@a-team.com>\"")
<add> flAuthor := cmd.String([]string{"a", "#author", "-author"}, "", "Author (eg. \"John Hannibal Smith <hannibal@a-team.com>\")")
<ide> // FIXME: --run is deprecated, it will be replaced with inline Dockerfile commands.
<ide> flConfig := cmd.String([]string{"#run", "#-run"}, "", "this option is deprecated and will be removed in a future version in favor of inline Dockerfile-compatible commands")
<ide> if err := cmd.Parse(args); err != nil { | 1 |
Python | Python | add k8s memory size str <-> n_bytes converters | 3c84489652dd2b12e0e1664eff8ce57b2a8a8a49 | <ide><path>libcloud/utils/misc.py
<ide> # limitations under the License.
<ide>
<ide> from typing import List
<add>from collections import OrderedDict
<ide>
<ide> import os
<ide> import binascii
<ide> from libcloud.utils.retry import TRANSIENT_SSL_ERROR # noqa: F401
<ide> from libcloud.utils.retry import TransientSSLError # noqa: F401
<ide>
<del>
<ide> __all__ = [
<ide> "find",
<ide> "get_driver",
<ide> "reverse_dict",
<ide> "lowercase_keys",
<ide> "get_secure_random_string",
<add> "retry",
<ide> "ReprMixin",
<ide> ]
<ide>
<add>K8S_UNIT_MAP = OrderedDict(
<add> {
<add> "K": 1000,
<add> "Ki": 1024,
<add> "M": 1000 * 1000,
<add> "Mi": 1024 * 1024,
<add> "G": 1000 * 1000 * 1000,
<add> "Gi": 1024 * 1024 * 1024,
<add> }
<add>)
<add>
<add>
<add>def to_n_bytes_from_k8s_memory_size_str(k8s_memory_size_str):
<add> """Convert k8s memory string to number of bytes
<add> (e.g. '1234Mi'-> 1293942784)
<add> """
<add> if k8s_memory_size_str.startswith("0"):
<add> return 0
<add> for unit, multiplier in K8S_UNIT_MAP.items():
<add> if k8s_memory_size_str.endswith(unit):
<add> return int(k8s_memory_size_str.strip(unit)) * multiplier
<add>
<add>
<add>def to_k8s_memory_size_str_from_n_bytes(n_bytes, unit=None):
<add> """Convert number of bytes to k8s memory string
<add> (e.g. 1293942784 -> '1234Mi')
<add> """
<add> if n_bytes == 0:
<add> return "0K"
<add> n_bytes = int(n_bytes)
<add> k8s_memory_size_str = None
<add> if unit is None:
<add> for unit, multiplier in reversed(K8S_UNIT_MAP.items()):
<add> converted_n_bytes_float = n_bytes / multiplier
<add> converted_n_bytes = n_bytes // multiplier
<add> k8s_memory_size_str = f"{converted_n_bytes}{unit}"
<add> if converted_n_bytes_float % 1 == 0:
<add> break
<add> elif K8S_UNIT_MAP.get(unit):
<add> k8s_memory_size_str = f"{n_bytes // K8S_UNIT_MAP[unit]}{unit}"
<add> return k8s_memory_size_str
<add>
<add>
<add># Error message which indicates a transient SSL error upon which request
<add># can be retried
<add>TRANSIENT_SSL_ERROR = "The read operation timed out"
<add>
<ide>
<ide> def find(value, predicate):
<ide> results = [x for x in value if predicate(x)] | 1 |
Text | Text | populate some labels | 211e130811145053440c56eec62ac6229d9d90b0 | <ide><path>.github/ISSUE_TEMPLATE/--new-model-addition.md
<ide> name: "\U0001F31F New model addition"
<ide> about: Submit a proposal/request to implement a new Transformer-based model
<ide> title: ''
<del>labels: ''
<add>labels: New model
<ide> assignees: ''
<ide>
<ide> ---
<ide><path>.github/ISSUE_TEMPLATE/migration.md
<ide> ---
<ide> name: "\U0001F4DA Migration from pytorch-pretrained-bert or pytorch-transformers"
<del>about: Report a problem when migrating from pytorch-pretrained-bert or pytorch-transformers to transformers
<add>about: Report a problem when migrating from pytorch-pretrained-bert or pytorch-transformers
<add> to transformers
<ide> title: ''
<del>labels: ''
<add>labels: Migration
<ide> assignees: ''
<ide>
<ide> ---
<ide><path>.github/ISSUE_TEMPLATE/question-help.md
<ide> assignees: ''
<ide>
<ide> <!-- You should first ask your question on SO, and only if
<ide> you didn't get an answer ask it here on GitHub. -->
<del>**A link to original question on Stack Overflow**:
<ide>\ No newline at end of file
<add>**A link to original question on Stack Overflow**: | 3 |
PHP | PHP | add basetype class | 67e7561bea5d225f30e28129640c160d10733f10 | <ide><path>src/Database/Type/BaseType.php
<add><?php
<add>/**
<add> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<add> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<add> *
<add> * Licensed under The MIT License
<add> * For full copyright and license information, please see the LICENSE.txt
<add> * Redistributions of files must retain the above copyright notice.
<add> *
<add> * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<add> * @link https://cakephp.org CakePHP(tm) Project
<add> * @since 4.0.0
<add> * @license https://opensource.org/licenses/mit-license.php MIT License
<add> */
<add>namespace Cake\Database\Type;
<add>
<add>use Cake\Database\Driver;
<add>use Cake\Database\TypeInterface;
<add>use PDO;
<add>
<add>/**
<add> * Base type class.
<add> */
<add>abstract class BaseType implements TypeInterface
<add>{
<add>
<add> /**
<add> * Identifier name for this type
<add> *
<add> * @var string|null
<add> */
<add> protected $_name;
<add>
<add> /**
<add> * Constructor
<add> *
<add> * @param string|null $name The name identifying this type
<add> */
<add> public function __construct($name = null)
<add> {
<add> $this->_name = $name;
<add> }
<add>
<add> /**
<add> * {@inheritDoc}
<add> */
<add> public function getName()
<add> {
<add> return $this->_name;
<add> }
<add>
<add> /**
<add> * {@inheritDoc}
<add> */
<add> public function getBaseType()
<add> {
<add> return $this->_name;
<add> }
<add>
<add> /**
<add> * {@inheritDoc}
<add> */
<add> public function toStatement($value, Driver $driver)
<add> {
<add> if ($value === null) {
<add> return PDO::PARAM_NULL;
<add> }
<add>
<add> return PDO::PARAM_STR;
<add> }
<add>
<add> /**
<add> * {@inheritDoc}
<add> */
<add> public function newId()
<add> {
<add> return null;
<add> }
<add>
<add> /**
<add> * Returns an array that can be used to describe the internal state of this
<add> * object.
<add> *
<add> * @return array
<add> */
<add> public function __debugInfo()
<add> {
<add> return [
<add> 'name' => $this->_name,
<add> ];
<add> }
<add>}
<ide><path>src/Database/Type/BinaryType.php
<ide> use Cake\Core\Exception\Exception;
<ide> use Cake\Database\Driver;
<ide> use Cake\Database\Driver\Sqlserver;
<del>use Cake\Database\Type;
<del>use Cake\Database\TypeInterface;
<ide> use PDO;
<ide>
<ide> /**
<ide> * Binary type converter.
<ide> *
<ide> * Use to convert binary data between PHP and the database types.
<ide> */
<del>class BinaryType extends Type implements TypeInterface
<add>class BinaryType extends BaseType
<ide> {
<del> /**
<del> * Identifier name for this type.
<del> *
<del> * (This property is declared here again so that the inheritance from
<del> * Cake\Database\Type can be removed in the future.)
<del> *
<del> * @var string|null
<del> */
<del> protected $_name;
<del>
<del> /**
<del> * Constructor.
<del> *
<del> * (This method is declared here again so that the inheritance from
<del> * Cake\Database\Type can be removed in the future.)
<del> *
<del> * @param string|null $name The name identifying this type
<del> */
<del> public function __construct($name = null)
<del> {
<del> $this->_name = $name;
<del> }
<ide>
<ide> /**
<ide> * Convert binary data into the database format.
<ide><path>src/Database/Type/BinaryUuidType.php
<ide> use Cake\Core\Exception\Exception;
<ide> use Cake\Database\Driver;
<ide> use Cake\Database\Driver\Sqlserver;
<del>use Cake\Database\Type;
<del>use Cake\Database\TypeInterface;
<ide> use Cake\Utility\Text;
<ide> use PDO;
<ide>
<ide> *
<ide> * Use to convert binary uuid data between PHP and the database types.
<ide> */
<del>class BinaryUuidType extends Type implements TypeInterface
<add>class BinaryUuidType extends BaseType
<ide> {
<del> /**
<del> * Identifier name for this type.
<del> *
<del> * (This property is declared here again so that the inheritance from
<del> * Cake\Database\Type can be removed in the future.)
<del> *
<del> * @var string|null
<del> */
<del> protected $_name;
<del>
<del> /**
<del> * Constructor.
<del> *
<del> * (This method is declared here again so that the inheritance from
<del> * Cake\Database\Type can be removed in the future.)
<del> *
<del> * @param string|null $name The name identifying this type
<del> */
<del> public function __construct($name = null)
<del> {
<del> $this->_name = $name;
<del> }
<ide>
<ide> /**
<ide> * Convert binary uuid data into the database format.
<ide><path>src/Database/Type/BoolType.php
<ide> namespace Cake\Database\Type;
<ide>
<ide> use Cake\Database\Driver;
<del>use Cake\Database\Type;
<del>use Cake\Database\TypeInterface;
<ide> use Cake\Database\Type\BatchCastingInterface;
<ide> use InvalidArgumentException;
<ide> use PDO;
<ide> *
<ide> * Use to convert bool data between PHP and the database types.
<ide> */
<del>class BoolType extends Type implements TypeInterface, BatchCastingInterface
<add>class BoolType extends BaseType implements BatchCastingInterface
<ide> {
<del> /**
<del> * Identifier name for this type.
<del> *
<del> * (This property is declared here again so that the inheritance from
<del> * Cake\Database\Type can be removed in the future.)
<del> *
<del> * @var string|null
<del> */
<del> protected $_name;
<del>
<del> /**
<del> * Constructor.
<del> *
<del> * (This method is declared here again so that the inheritance from
<del> * Cake\Database\Type can be removed in the future.)
<del> *
<del> * @param string|null $name The name identifying this type
<del> */
<del> public function __construct($name = null)
<del> {
<del> $this->_name = $name;
<del> }
<ide>
<ide> /**
<ide> * Convert bool data into the database format.
<ide><path>src/Database/Type/DateTimeType.php
<ide> namespace Cake\Database\Type;
<ide>
<ide> use Cake\Database\Driver;
<del>use Cake\Database\Type;
<del>use Cake\Database\TypeInterface;
<ide> use Cake\Database\Type\BatchCastingInterface;
<ide> use DateTimeImmutable;
<ide> use DateTimeInterface;
<ide> *
<ide> * Use to convert datetime instances to strings & back.
<ide> */
<del>class DateTimeType extends Type implements TypeInterface, BatchCastingInterface
<add>class DateTimeType extends BaseType
<ide> {
<del> /**
<del> * Identifier name for this type.
<del> *
<del> * (This property is declared here again so that the inheritance from
<del> * Cake\Database\Type can be removed in the future.)
<del> *
<del> * @var string|null
<del> */
<del> protected $_name;
<ide>
<ide> /**
<ide> * The class to use for representing date objects
<ide><path>src/Database/Type/DecimalType.php
<ide> namespace Cake\Database\Type;
<ide>
<ide> use Cake\Database\Driver;
<del>use Cake\Database\Type;
<del>use Cake\Database\TypeInterface;
<ide> use Cake\Database\Type\BatchCastingInterface;
<ide> use InvalidArgumentException;
<ide> use PDO;
<ide> *
<ide> * Use to convert decimal data between PHP and the database types.
<ide> */
<del>class DecimalType extends Type implements TypeInterface, BatchCastingInterface
<add>class DecimalType extends BaseType implements BatchCastingInterface
<ide> {
<del> /**
<del> * Identifier name for this type.
<del> *
<del> * (This property is declared here again so that the inheritance from
<del> * Cake\Database\Type can be removed in the future.)
<del> *
<del> * @var string|null
<del> */
<del> protected $_name;
<del>
<del> /**
<del> * Constructor.
<del> *
<del> * (This method is declared here again so that the inheritance from
<del> * Cake\Database\Type can be removed in the future.)
<del> *
<del> * @param string|null $name The name identifying this type
<del> */
<del> public function __construct($name = null)
<del> {
<del> $this->_name = $name;
<del> }
<ide>
<ide> /**
<ide> * The class to use for representing number objects
<ide><path>src/Database/Type/FloatType.php
<ide> namespace Cake\Database\Type;
<ide>
<ide> use Cake\Database\Driver;
<del>use Cake\Database\Type;
<del>use Cake\Database\TypeInterface;
<ide> use Cake\Database\Type\BatchCastingInterface;
<ide> use PDO;
<ide> use RuntimeException;
<ide> *
<ide> * Use to convert float/decimal data between PHP and the database types.
<ide> */
<del>class FloatType extends Type implements TypeInterface, BatchCastingInterface
<add>class FloatType extends BaseType implements BatchCastingInterface
<ide> {
<add>
<ide> /**
<ide> * Identifier name for this type.
<ide> *
<ide><path>src/Database/Type/IntegerType.php
<ide> namespace Cake\Database\Type;
<ide>
<ide> use Cake\Database\Driver;
<del>use Cake\Database\Type;
<del>use Cake\Database\TypeInterface;
<ide> use Cake\Database\Type\BatchCastingInterface;
<ide> use InvalidArgumentException;
<ide> use PDO;
<ide> *
<ide> * Use to convert integer data between PHP and the database types.
<ide> */
<del>class IntegerType extends Type implements TypeInterface, BatchCastingInterface
<add>class IntegerType extends BaseType implements BatchCastingInterface
<ide> {
<del> /**
<del> * Identifier name for this type.
<del> *
<del> * (This property is declared here again so that the inheritance from
<del> * Cake\Database\Type can be removed in the future.)
<del> *
<del> * @var string|null
<del> */
<del> protected $_name;
<del>
<del> /**
<del> * Constructor.
<del> *
<del> * (This method is declared here again so that the inheritance from
<del> * Cake\Database\Type can be removed in the future.)
<del> *
<del> * @param string|null $name The name identifying this type
<del> */
<del> public function __construct($name = null)
<del> {
<del> $this->_name = $name;
<del> }
<ide>
<ide> /**
<ide> * Convert integer data into the database format.
<ide><path>src/Database/Type/JsonType.php
<ide> namespace Cake\Database\Type;
<ide>
<ide> use Cake\Database\Driver;
<del>use Cake\Database\Type;
<del>use Cake\Database\TypeInterface;
<ide> use Cake\Database\Type\BatchCastingInterface;
<ide> use InvalidArgumentException;
<ide> use PDO;
<ide> *
<ide> * Use to convert json data between PHP and the database types.
<ide> */
<del>class JsonType extends Type implements TypeInterface, BatchCastingInterface
<add>class JsonType extends BaseType implements BatchCastingInterface
<ide> {
<del> /**
<del> * Identifier name for this type.
<del> *
<del> * (This property is declared here again so that the inheritance from
<del> * Cake\Database\Type can be removed in the future.)
<del> *
<del> * @var string|null
<del> */
<del> protected $_name;
<del>
<del> /**
<del> * Constructor.
<del> *
<del> * (This method is declared here again so that the inheritance from
<del> * Cake\Database\Type can be removed in the future.)
<del> *
<del> * @param string|null $name The name identifying this type
<del> */
<del> public function __construct($name = null)
<del> {
<del> $this->_name = $name;
<del> }
<ide>
<ide> /**
<ide> * Convert a value data into a JSON string
<ide><path>src/Database/Type/StringType.php
<ide> namespace Cake\Database\Type;
<ide>
<ide> use Cake\Database\Driver;
<del>use Cake\Database\Type;
<del>use Cake\Database\TypeInterface;
<ide> use InvalidArgumentException;
<ide> use PDO;
<ide>
<ide> *
<ide> * Use to convert string data between PHP and the database types.
<ide> */
<del>class StringType extends Type implements OptionalConvertInterface, TypeInterface
<add>class StringType extends BaseType implements OptionalConvertInterface
<ide> {
<ide>
<ide> /** | 10 |
Ruby | Ruby | match preferred shell by symbol | 36bc11b01a1f4bd8d8364842e7d477c6f285cddb | <ide><path>Library/Homebrew/utils/shell.rb
<ide> def export_value(key, value, shell = preferred)
<ide>
<ide> # return the shell profile file based on user's preferred shell
<ide> def profile
<del> return "#{ENV["ZDOTDIR"]}/.zshrc" if preferred == "zsh" && ENV["ZDOTDIR"].present?
<del>
<add> return "#{ENV["ZDOTDIR"]}/.zshrc" if preferred == :zsh && ENV["ZDOTDIR"].present?
<add>
<ide> SHELL_PROFILE_MAP.fetch(preferred, "~/.bash_profile")
<ide> end
<ide> | 1 |
Python | Python | add tests for isscalar | c0db59fe1afcf67e4c6c3b0c8034974ef008704f | <ide><path>numpy/core/tests/test_numeric.py
<ide> def test_var(self):
<ide> assert_(w[0].category is RuntimeWarning)
<ide>
<ide>
<add>class TestIsscalar(object):
<add> def test_isscalar(self):
<add> assert_(np.isscalar(3.1))
<add> assert_(np.isscalar(np.int16(12345)))
<add> assert_(np.isscalar(False))
<add> assert_(np.isscalar('numpy'))
<add> assert_(not np.isscalar([3.1]))
<add> assert_(not np.isscalar(None))
<add>
<add> # PEP 3141
<add> from fractions import Fraction
<add> assert_(np.isscalar(Fraction(5, 17)))
<add> from numbers import Number
<add> assert_(np.isscalar(Number()))
<add>
<add>
<ide> class TestBoolScalar(object):
<ide> def test_logical(self):
<ide> f = np.False_ | 1 |
Ruby | Ruby | handle kwargs only in ruby >= '2.7' | de3d9680ac5a0667d3ba885cd3d2a394639fe538 | <ide><path>activemodel/lib/active_model/attribute_methods.rb
<ide> def attribute_method_matchers_matching(method_name)
<ide> # using the given `extra` args. This falls back on `define_method`
<ide> # and `send` if the given names cannot be compiled.
<ide> def define_proxy_call(include_private, mod, name, target, *extra)
<add> kw = RUBY_VERSION >= '2.7' ? ", **options" : nil
<ide> defn = if NAME_COMPILABLE_REGEXP.match?(name)
<del> "def #{name}(*args)"
<add> "def #{name}(*args#{kw})"
<ide> else
<del> "define_method(:'#{name}') do |*args|"
<add> "define_method(:'#{name}') do |*args#{kw}|"
<ide> end
<ide>
<del> extra = (extra.map!(&:inspect) << "*args").join(", ")
<add> extra = (extra.map!(&:inspect) << "*args#{kw}").join(", ")
<ide>
<ide> body = if CALL_COMPILABLE_REGEXP.match?(target)
<ide> "#{"self." unless include_private}#{target}(#{extra})" | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.