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
|
---|---|---|---|---|---|
Javascript | Javascript | fix proposal for | 03cf74ccffe7b931c052f357bb43123ba0749d67 | <ide><path>src/animation/PropertyBinding.js
<ide> THREE.PropertyBinding.parseTrackName = function( trackName ) {
<ide> // .bone[Armature.DEF_cog].position
<ide> // created and tested via https://regex101.com/#javascript
<ide>
<del> var re = /^(([\w]+\/)*)([\w-\d]+)?(\.([\w]+)(\[([\w\d\[\]\_. ]+)\])?)?(\.([\w.]+)(\[([\w\d\[\]\_. ]+)\])?)$/;
<add> var re = /^(([\w]+\/)*)([\w-\d]+)?(\.([\w]+)(\[([\w\d\[\]\_.:\- ]+)\])?)?(\.([\w.]+)(\[([\w\d\[\]\_. ]+)\])?)$/;
<ide> var matches = re.exec(trackName);
<ide>
<ide> if( ! matches ) { | 1 |
Ruby | Ruby | add test for dependency options | 6ed24d3877eca5b117924831ae3e3267123e0675 | <ide><path>Library/Homebrew/test/test_formula.rb
<ide> def initialize(*args)
<ide> ensure
<ide> path.unlink
<ide> end
<add>
<add> def test_dependency_option_integration
<add> f = formula do
<add> url 'foo-1.0'
<add> depends_on 'foo' => :optional
<add> depends_on 'bar' => :recommended
<add> end
<add>
<add> assert f.build.has_option?('with-foo')
<add> assert f.build.has_option?('without-bar')
<add> end
<ide> end | 1 |
Text | Text | remove images directory | c029f8eb9548b0548fae2cd7872d920236e78c1d | <ide><path>docs/your-first-package.md
<ide> ol.entries .hide-me {
<ide> Refresh Atom, and run the `changer` command. You'll see all the non-changed
<ide> files disappear from the tree. Success!
<ide>
<del>![Changer File View][changer-file-view]
<add>![Changer_File_View]
<add>
<ide>
<ide> There are a number of ways you can get the list back; let's just naively iterate
<ide> over the same elements and remove the class:
<ide> rootView.vertical.append(this)
<ide> If you refresh Atom and hit the key command, you'll see a box appear right underneath
<ide> the editor:
<ide>
<del>![Changer Panel][changer-panel-append]
<add>![Changer_Panel_Append]
<ide>
<ide> As you might have guessed, `rootView.vertical.append` tells Atom to append `this`
<ide> item (_i.e._, whatever is defined by`@content`) _vertically_ to the editor. If
<ide> else
<ide> for file in modifiedFiles
<ide> stat = fs.lstatSync(file)
<ide> mtime = stat.mtime
<del> @modifiedFilesList.append("<li>#{file} - Modified at #{mtime}")
<add> @modifiedFilesList.append("<li>#{file} - Modified at #{mtime}")
<ide> rootView.vertical.append(this)
<ide> ```
<ide>
<ide> When you toggle the modified files list, your pane is now populated with the
<ide> filenames and modified times of files in your project:
<ide>
<del>![Changer Panel][changer-panel-timestamps]
<add>![Changer_Panel_Timestamps]
<ide>
<ide> You might notice that subsequent calls to this command reduplicate information.
<ide> We could provide an elegant way of rechecking files already in the list, but for
<ide> For more information on the mechanics of packages, check out
<ide> [space-pen]: https://github.com/atom/space-pen
<ide> [node]: http://nodejs.org/
<ide> [path]: http://nodejs.org/docs/latest/api/path.html
<del>[theme-vars]: theme-variables.html
<del>[changer-file-view]: https://f.cloud.github.com/assets/69169/1441187/d7a7cb46-41a7-11e3-8128-d93f70a5d5c1.png
<del>[changer-panel-append]: https://f.cloud.github.com/assets/69169/1441189/db0c74da-41a7-11e3-8286-b82dd9190c34.png
<del>[changer-panel-timestamps]: https://f.cloud.github.com/assets/69169/1441190/dcc8eeb6-41a7-11e3-830f-1f1b33072fcd.png
<del>[creating-a-package]: creating-a-package.html
<add>[theme-vars]: ../theme-variables.html | 1 |
Javascript | Javascript | enable concurrentroot in rn vr apps | 3e8934b49be4babedf6a26916528a7450089e118 | <ide><path>Libraries/ReactNative/AppRegistry.js
<ide> const AppRegistry = {
<ide> runnables[appKey] = {
<ide> componentProvider,
<ide> run: (appParameters, displayMode) => {
<add> const concurrentRootEnabled =
<add> appParameters.initialProps?.concurrentRoot ||
<add> appParameters.concurrentRoot;
<ide> renderApplication(
<ide> componentProviderInstrumentationHook(
<ide> componentProvider,
<ide> const AppRegistry = {
<ide> appKey === 'LogBox',
<ide> appKey,
<ide> coerceDisplayMode(displayMode),
<del> appParameters.concurrentRoot,
<add> concurrentRootEnabled,
<ide> );
<ide> },
<ide> }; | 1 |
PHP | PHP | slugify new session.cookie to comply with rfc 6265 | 28719679b707688f6622474143ede71b6a078562 | <ide><path>config/session.php
<ide> |
<ide> */
<ide>
<del> 'cookie' => env('SESSION_COOKIE', snake_case(env('APP_NAME', 'laravel')).'_session'),
<add> 'cookie' => env('SESSION_COOKIE', str_slug(env('APP_NAME', 'laravel'), '_').'_session'),
<ide>
<ide> /*
<ide> |-------------------------------------------------------------------------- | 1 |
Python | Python | test the transformer layer with dynamic sequence | 2f9f2479556b72ff6d4f1f549a7a0c8c348a0422 | <ide><path>official/nlp/modeling/layers/transformer_test.py
<ide> def test_transform_with_initializer(self):
<ide> # The default output of a transformer layer should be the same as the input.
<ide> self.assertEqual(data_tensor.shape.as_list(), output.shape.as_list())
<ide>
<add> def test_dynamic_layer_sequence(self):
<add> test_layer = transformer.Transformer(
<add> num_attention_heads=10,
<add> intermediate_size=2048,
<add> intermediate_activation='relu',
<add> kernel_initializer=tf.keras.initializers.TruncatedNormal(stddev=0.02))
<add> # Create a 3-dimensional input (the first dimension is implicit).
<add> width = 30
<add> input_tensor = tf.keras.Input(shape=(None, width))
<add> output_tensor = test_layer(input_tensor)
<add> model = tf.keras.Model(input_tensor, output_tensor)
<add>
<add> input_length = 17
<add> input_data = np.ones((1, input_length, width))
<add> output_data = model.predict(input_data)
<add>
<add> self.assertAllEqual([1, input_length, width], output_data.shape)
<add>
<ide>
<ide> if __name__ == '__main__':
<ide> assert tf.version.VERSION.startswith('2.') | 1 |
Python | Python | add test for get_driver | b6e3ca05c1f0a221afd14aa30e9a4fa28d79b9cf | <ide><path>test/test_utils.py
<ide> warnings.simplefilter('default')
<ide>
<ide> import libcloud.utils
<add>from libcloud.compute.types import Provider
<add>from libcloud.compute.providers import DRIVERS
<ide>
<ide> WARNINGS_BUFFER = []
<ide>
<ide> def test_guess_file_mime_type(self):
<ide>
<ide> self.assertTrue(mimetype.find('python') != -1)
<ide>
<add> def test_get_driver(self):
<add> driver = libcloud.utils.get_driver(drivers=DRIVERS,
<add> provider=Provider.DUMMY)
<add> self.assertTrue(driver is not None)
<add>
<add> try:
<add> driver = libcloud.utils.get_driver(drivers=DRIVERS,
<add> provider='fooba')
<add> except AttributeError:
<add> pass
<add> else:
<add> self.fail('Invalid provider, but an exception was not thrown')
<add>
<ide> def test_deprecated_warning(self):
<ide> warnings.showwarning = show_warning
<ide> | 1 |
Text | Text | update outdated release schedule | f272f97df1d41d4fd60c642eef92f6114a118383 | <ide><path>Releases.md
<ide> https://github.com/facebook/react-native/releases
<ide>
<ide> ## Release schedule
<ide>
<del>| Version | RC release | Stable release |
<del>| ------- | ---------------- | -------------- |
<del>| 0.27.0 | week of May 16 | June 6 |
<del>| 0.28.0 | week of June 6 | June 20 |
<del>| 0.29.0 | week of June 20 | July 4 |
<del>| 0.30.0 | week of July 4 | July 18 |
<del>| 0.31.0 | week of July 18 | Aug 1 |
<del>| 0.32.0 | week of Aug 1 | Aug 15 |
<del>| ... | ... | ... |
<add>| Version | RC release | Stable release |
<add>| ------- | ------------------- | -------------- |
<add>| 0.36.0 | week of October 10 | October 24 |
<add>| 0.37.0 | week of October 24 | November 7 |
<add>| 0.38.0 | week of November 7 | November 21 |
<add>| 0.39.0 | week of November 21 | December 5 |
<add>| 0.40.0 | week of December 5 | December 19 |
<add>| ... | ... | ... |
<ide>
<ide> -------------------
<ide> ## How to cut a new release branch | 1 |
Python | Python | retain backward compatibility. enforce c order | bb0e4f356cce2f199d9c08ffe572fbabadc846d1 | <ide><path>numpy/lib/index_tricks.py
<ide> class ndindex(object):
<ide> """
<ide> def __init__(self, *shape):
<ide> x = as_strided(_nx.zeros(1), shape=shape, strides=_nx.zeros_like(shape))
<del> self._it = _nx.nditer(x, flags=['multi_index'])
<add> self._it = _nx.nditer(x, flags=['multi_index'], order='C')
<ide>
<ide> def __iter__(self):
<ide> return self
<ide>
<add> def ndincr(self):
<add> """
<add> Increment the multi-dimensional index by one.
<add>
<add> This method is for backward compatibility only: do not use.
<add> """
<add> self.next()
<add>
<ide> def next(self):
<ide> """
<ide> Standard iterator method, updates the index and returns the index tuple. | 1 |
Javascript | Javascript | fix small lint warnings | 07254bb0a5459df1a9f7d451bbb4be73d00083f0 | <ide><path>pdf.js
<ide> var PDFImage = (function() {
<ide>
<ide> this.decode = dict.get('Decode', 'D');
<ide>
<del> var mask = xref.fetchIfRef(image.dict.get('Mask'));
<del> var smask = xref.fetchIfRef(image.dict.get('SMask'));
<add> var mask = xref.fetchIfRef(dict.get('Mask'));
<add> var smask = xref.fetchIfRef(dict.get('SMask'));
<ide>
<ide> if (mask) {
<ide> TODO('masked images');
<ide><path>test/driver.js
<ide> 'use strict';
<ide>
<ide> var appPath, browser, canvas, currentTaskIdx, manifest, stdout;
<add>var inFlightRequests = 0;
<ide>
<ide> function queryParams() {
<ide> var qs = window.location.search.substring(1);
<ide> function load() {
<ide> if (r.readyState == 4) {
<ide> log('done\n');
<ide> manifest = JSON.parse(r.responseText);
<del> currentTaskIdx = 0, nextTask();
<add> currentTaskIdx = 0;
<add> nextTask();
<ide> }
<ide> };
<ide> r.send(null);
<ide> function nextTask() {
<ide> failure = 'load PDF doc : ' + e.toString();
<ide> }
<ide>
<del> task.pageNum = 1, nextPage(task, failure);
<add> task.pageNum = 1;
<add> nextPage(task, failure);
<ide> }
<ide> };
<ide> r.send(null);
<ide> function nextPage(task, loadError) {
<ide> if (!task.pdfDoc) {
<ide> sendTaskResult(canvas.toDataURL('image/png'), task, failure);
<ide> log('done' + (failure ? ' (failed !: ' + failure + ')' : '') + '\n');
<del> ++currentTaskIdx, nextTask();
<add> ++currentTaskIdx;
<add> nextTask();
<ide> return;
<ide> }
<ide>
<ide> function nextPage(task, loadError) {
<ide> log(' Round ' + (1 + task.round) + '\n');
<ide> task.pageNum = 1;
<ide> } else {
<del> ++currentTaskIdx, nextTask();
<add> ++currentTaskIdx;
<add> nextTask();
<ide> return;
<ide> }
<ide> }
<ide> function nextPage(task, loadError) {
<ide> page.startRendering(
<ide> ctx,
<ide> function(e) {
<del> snapshotCurrentPage(page, task, (!failure && e) ?
<add> snapshotCurrentPage(task, (!failure && e) ?
<ide> ('render : ' + e) : failure);
<ide> }
<ide> );
<ide> function nextPage(task, loadError) {
<ide> if (failure) {
<ide> // Skip right to snapshotting if there was a failure, since the
<ide> // fonts might be in an inconsistent state.
<del> snapshotCurrentPage(page, task, failure);
<add> snapshotCurrentPage(task, failure);
<ide> }
<ide> }
<ide>
<del>function snapshotCurrentPage(page, task, failure) {
<add>function snapshotCurrentPage(task, failure) {
<ide> log('done, snapshotting... ');
<ide>
<ide> sendTaskResult(canvas.toDataURL('image/png'), task, failure);
<ide> function snapshotCurrentPage(page, task, failure) {
<ide> var backoff = (inFlightRequests > 0) ? inFlightRequests * 10 : 0;
<ide> setTimeout(
<ide> function() {
<del> ++task.pageNum, nextPage(task);
<add> ++task.pageNum;
<add> nextPage(task);
<ide> },
<ide> backoff
<ide> );
<ide> function done() {
<ide> }
<ide> }
<ide>
<del>var inFlightRequests = 0;
<ide> function sendTaskResult(snapshot, task, failure) {
<ide> var result = { browser: browser,
<ide> id: task.id,
<ide> function sendTaskResult(snapshot, task, failure) {
<ide> if (r.readyState == 4) {
<ide> inFlightRequests--;
<ide> }
<del> }
<add> };
<ide> document.getElementById('inFlightCount').innerHTML = inFlightRequests++;
<ide> r.send(JSON.stringify(result));
<ide> }
<ide><path>utils/cffStandardStrings.js
<ide> var CFFDictDataMap = {
<ide> '18': {
<ide> name: 'ExpansionFactor'
<ide> },
<del> '9': {
<add> '19': {
<ide> name: 'initialRandomSeed'
<ide> },
<ide> '20': {
<ide><path>utils/fonts_utils.js
<ide> function readCharstringEncoding(aString) {
<ide> } else if (value <= 31) {
<ide> token = CFFEncodingMap[value];
<ide> } else if (value < 247) {
<del> token = parseInt(value) - 139;
<add> token = parseInt(value, 10) - 139;
<ide> } else if (value < 251) {
<ide> token = ((value - 247) * 256) + aString[i++] + 108;
<ide> } else if (value < 255) {
<ide> function readFontDictData(aString, aMap) {
<ide> while (!parsed) {
<ide> var byte = aString[i++];
<ide>
<del> var nibbles = [parseInt(byte / 16), parseInt(byte % 16)];
<add> var nibbles = [parseInt(byte / 16, 10), parseInt(byte % 16, 10)];
<ide> for (var j = 0; j < nibbles.length; j++) {
<ide> var nibble = nibbles[j];
<ide> switch (nibble) {
<ide> function readFontDictData(aString, aMap) {
<ide> } else if (value <= 31) {
<ide> token = aMap[value];
<ide> } else if (value <= 246) {
<del> token = parseInt(value) - 139;
<add> token = parseInt(value, 10) - 139;
<ide> } else if (value <= 250) {
<ide> token = ((value - 247) * 256) + aString[i++] + 108;
<ide> } else if (value <= 254) {
<ide> function readFontIndexData(aStream, aIsByte) {
<ide> }
<ide> error(offsize + ' is not a valid offset size');
<ide> return null;
<del> };
<add> }
<ide>
<ide> var offsets = [];
<ide> for (var i = 0; i < count + 1; i++)
<ide> var Type2Parser = function(aFilePath) {
<ide> function dump(aStr) {
<ide> if (debug)
<ide> log(aStr);
<del> };
<add> }
<ide>
<ide> function parseAsToken(aString, aMap) {
<ide> var decoded = readFontDictData(aString, aMap);
<ide> var Type2Parser = function(aFilePath) {
<ide> }
<ide> }
<ide> }
<del> };
<add> }
<ide>
<ide> this.parse = function(aStream) {
<ide> font.set('major', aStream.getByte());
<ide> var Type2Parser = function(aFilePath) {
<ide> aStream.pos = charsetEntry;
<ide> var charset = readCharset(aStream, charStrings);
<ide> }
<del> }
<add> };
<ide> };
<ide>
<ide> /*
<ide><path>web/compatibility.js
<ide> /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
<ide> /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
<ide>
<add>'use strict';
<add>
<ide> // Checking if the typed arrays are supported
<ide> (function() {
<ide> if (typeof Uint8Array !== 'undefined')
<ide> return this.slice(start, end);
<ide> }
<ide>
<del> function set_(array, offset) {
<del> if (arguments.length < 2) offset = 0;
<add> function set_function(array, offset) {
<add> if (arguments.length < 2)
<add> offset = 0;
<ide> for (var i = 0, n = array.length; i < n; ++i, ++offset)
<ide> this[offset] = array[i] & 0xFF;
<ide> }
<ide>
<ide> function TypedArray(arg1) {
<ide> var result;
<ide> if (typeof arg1 === 'number') {
<del> result = new Array(arg1);
<del> for (var i = 0; i < arg1; ++i)
<del> result[i] = 0;
<add> result = [];
<add> for (var i = 0; i < arg1; ++i)
<add> result[i] = 0;
<ide> } else
<del> result = arg1.slice(0);
<add> result = arg1.slice(0);
<add>
<ide> result.subarray = subarray;
<ide> result.buffer = result;
<ide> result.byteLength = result.length;
<del> result.set = set_;
<add> result.set = set_function;
<add>
<ide> if (typeof arg1 === 'object' && arg1.buffer)
<ide> result.buffer = arg1.buffer;
<ide>
<ide><path>web/viewer.js
<ide> var PDFView = {
<ide> },
<ide>
<ide> get page() {
<del> return parseInt(document.location.hash.substring(1)) || 1;
<add> return parseInt(document.location.hash.substring(1), 10) || 1;
<ide> },
<ide>
<ide> open: function(url, scale) {
<ide> var PDFView = {
<ide> }
<ide>
<ide> this.setScale(scale || kDefaultScale, true);
<del> this.page = parseInt(document.location.hash.substring(1)) || 1;
<add> this.page = parseInt(document.location.hash.substring(1), 10) || 1;
<ide> this.pagesRefMap = pagesRefMap;
<ide> this.destinations = pdf.catalog.destinations;
<ide> if (pdf.catalog.documentOutline) {
<ide> var PDFView = {
<ide>
<ide> var currentHeight = kBottomMargin;
<ide> var windowTop = window.pageYOffset;
<del> for (var i = 1; i <= pages.length; i++) {
<add> for (var i = 1; i <= pages.length; ++i) {
<ide> var page = pages[i - 1];
<ide> var pageHeight = page.height * page.scale + kBottomMargin;
<ide> if (currentHeight + pageHeight > windowTop)
<ide> var PDFView = {
<ide> }
<ide>
<ide> var windowBottom = window.pageYOffset + window.innerHeight;
<del> for (; i <= pages.length && currentHeight < windowBottom; i++) {
<del> var page = pages[i - 1];
<del> visiblePages.push({ id: page.id, y: currentHeight, view: page });
<del> currentHeight += page.height * page.scale + kBottomMargin;
<add> for (; i <= pages.length && currentHeight < windowBottom; ++i) {
<add> var singlePage = pages[i - 1];
<add> visiblePages.push({ id: singlePage.id, y: currentHeight,
<add> view: singlePage });
<add> currentHeight += singlePage.height * singlePage.scale + kBottomMargin;
<ide> }
<ide>
<ide> return visiblePages;
<ide> var PageView = function(container, content, id, width, height,
<ide> div.removeAttribute('data-loaded');
<ide> };
<ide>
<del> function setupLinks(canvas, content, scale) {
<add> function setupLinks(content, scale) {
<ide> function bindLink(link, dest) {
<ide> link.onclick = function() {
<ide> if (dest)
<ide> PDFView.navigateTo(dest);
<ide> return false;
<del> }
<add> };
<ide> }
<ide> var links = content.getLinks();
<ide> for (var i = 0; i < links.length; i++) {
<ide> var PageView = function(container, content, id, width, height,
<ide> var width = 0, height = 0, widthScale, heightScale;
<ide> var scale = 0;
<ide> switch (dest[1].name) {
<del> default:
<del> return;
<ide> case 'XYZ':
<ide> x = dest[2];
<ide> y = dest[3];
<ide> var PageView = function(container, content, id, width, height,
<ide> height / kCssUnits;
<ide> scale = Math.min(widthScale, heightScale);
<ide> break;
<add> default:
<add> return;
<ide> }
<ide>
<ide> var boundingRect = [
<ide> var PageView = function(container, content, id, width, height,
<ide> stats.begin = Date.now();
<ide> this.content.startRendering(ctx, this.updateStats);
<ide>
<del> setupLinks(canvas, this.content, this.scale);
<add> setupLinks(this.content, this.scale);
<ide> div.setAttribute('data-loaded', true);
<ide>
<ide> return true;
<ide><path>worker/canvas.js
<ide> function GradientProxy(cmdQueue, x0, y0, x1, y1) {
<ide> cmdQueue.push(['$createLinearGradient', [x0, y0, x1, y1]]);
<ide> this.addColorStop = function(i, rgba) {
<ide> cmdQueue.push(['$addColorStop', [i, rgba]]);
<del> }
<add> };
<ide> }
<ide>
<ide> // Really simple PatternProxy.
<ide> function CanvasProxy(width, height) {
<ide> throw 'CanvasProxy can only provide a 2d context.';
<ide> }
<ide> return ctx;
<del> }
<add> };
<ide>
<ide> // Expose only the minimum of the canvas object - there is no dom to do
<ide> // more here.
<ide> function CanvasProxy(width, height) {
<ide> return function() {
<ide> // console.log("funcCall", name)
<ide> cmdQueue.push([name, Array.prototype.slice.call(arguments)]);
<del> }
<add> };
<ide> }
<ide> var name;
<ide> for (var i = 0; i < ctxFunc.length; i++) {
<ide> function CanvasProxy(width, height) {
<ide>
<ide> ctx.createPattern = function(object, kind) {
<ide> return new PatternProxy(cmdQueue, object, kind);
<del> }
<add> };
<ide>
<ide> ctx.createLinearGradient = function(x0, y0, x1, y1) {
<ide> return new GradientProxy(cmdQueue, x0, y0, x1, y1);
<del> }
<add> };
<ide>
<ide> ctx.getImageData = function(x, y, w, h) {
<ide> return {
<ide> width: w,
<ide> height: h,
<ide> data: Uint8ClampedArray(w * h * 4)
<ide> };
<del> }
<add> };
<ide>
<ide> ctx.putImageData = function(data, x, y, width, height) {
<ide> cmdQueue.push(['$putImageData', [data, x, y, width, height]]);
<del> }
<add> };
<ide>
<ide> ctx.drawImage = function(image, x, y, width, height,
<ide> sx, sy, swidth, sheight) {
<ide> function CanvasProxy(width, height) {
<ide> } else {
<ide> throw 'unkown type to drawImage';
<ide> }
<del> }
<add> };
<ide>
<ide> // Setup property access to `ctx`.
<ide> var ctxProp = {
<ide> function CanvasProxy(width, height) {
<ide> function buildGetter(name) {
<ide> return function() {
<ide> return ctx['$' + name];
<del> }
<add> };
<ide> }
<ide>
<ide> function buildSetter(name) {
<ide> return function(value) {
<ide> cmdQueue.push(['$', name, value]);
<del> return ctx['$' + name] = value;
<del> }
<add> return (ctx['$' + name] = value);
<add> };
<ide> }
<ide>
<ide> // Setting the value to `stroke|fillStyle` needs special handling, as it
<ide> function CanvasProxy(width, height) {
<ide> cmdQueue.push(['$' + name + 'Pattern', [value.id]]);
<ide> } else {
<ide> cmdQueue.push(['$', name, value]);
<del> return ctx['$' + name] = value;
<add> return (ctx['$' + name] = value);
<ide> }
<del> }
<add> };
<ide> }
<ide>
<ide> for (var name in ctxProp) {
<ide><path>worker/client.js
<ide> FontWorker.prototype = {
<ide>
<ide> 'fonts': function(data) {
<ide> // console.log("got processed fonts from worker", Object.keys(data));
<del> for (name in data) {
<add> for (var name in data) {
<ide> // Update the encoding property.
<ide> var font = Fonts.lookup(name);
<ide> font.properties = {
<ide> function WorkerPDFDoc(canvas) {
<ide> // Copy over the imageData.
<ide> var len = imageRealData.length;
<ide> while (len--)
<del> imgRealData[len] = imageRealData[len];
<add> imgRealData[len] = imageRealData[len];
<ide>
<ide> this.putImageData(imgData, x, y);
<ide> },
<ide> function WorkerPDFDoc(canvas) {
<ide> },
<ide>
<ide> 'pdf_num_pages': function(data) {
<del> this.numPages = parseInt(data);
<add> this.numPages = parseInt(data, 10);
<ide> if (this.loadCallback) {
<ide> this.loadCallback();
<ide> }
<ide> function WorkerPDFDoc(canvas) {
<ide> 'setup_page': function(data) {
<ide> var size = data.split(',');
<ide> var canvas = this.canvas, ctx = this.ctx;
<del> canvas.width = parseInt(size[0]);
<del> canvas.height = parseInt(size[1]);
<add> canvas.width = parseInt(size[0], 10);
<add> canvas.height = parseInt(size[1], 10);
<ide> },
<ide>
<ide> 'fonts': function(data) {
<ide> WorkerPDFDoc.prototype.open = function(url, callback) {
<ide> };
<ide>
<ide> WorkerPDFDoc.prototype.showPage = function(numPage) {
<del> this.numPage = parseInt(numPage);
<add> this.numPage = parseInt(numPage, 10);
<ide> console.log('=== start rendering page ' + numPage + ' ===');
<ide> console.time('>>> total page display time:');
<ide> this.worker.postMessage(numPage);
<ide> WorkerPDFDoc.prototype.showPage = function(numPage) {
<ide> };
<ide>
<ide> WorkerPDFDoc.prototype.nextPage = function() {
<del> if (this.numPage == this.numPages) return;
<del> this.showPage(++this.numPage);
<add> if (this.numPage != this.numPages)
<add> this.showPage(++this.numPage);
<ide> };
<ide>
<ide> WorkerPDFDoc.prototype.prevPage = function() {
<del> if (this.numPage == 1) return;
<del> this.showPage(--this.numPage);
<add> if (this.numPage != 1)
<add> this.showPage(--this.numPage);
<ide> };
<add>
<ide><path>worker/console.js
<ide> var console = {
<ide> this.log('Timer:', name, Date.now() - time);
<ide> }
<ide> };
<add>
<ide><path>worker/font.js
<ide> this.onmessage = function(event) {
<ide> throw 'Unkown action from worker: ' + data.action;
<ide> }
<ide> };
<add>
<ide><path>worker/pdf.js
<ide> onmessage = function(event) {
<ide> console.time('compile');
<ide>
<ide> // Let's try to render the first page...
<del> var page = pdfDocument.getPage(parseInt(data));
<add> var page = pdfDocument.getPage(parseInt(data, 10));
<ide>
<ide> var pdfToCssUnitsCoef = 96.0 / 72.0;
<ide> var pageWidth = (page.mediaBox[2] - page.mediaBox[0]) * pdfToCssUnitsCoef; | 11 |
Javascript | Javascript | fix lint errors | 84b5fd411d6e6f194e0b8356fd12bd0503dcc49f | <ide><path>src/update-process-env.js
<ide> async function getEnvFromShell(env) {
<ide> return null;
<ide> }
<ide>
<del> let result = {}
<add> let result = {};
<ide> for (let line of stdout.split('\0')) {
<ide> if (line.includes('=')) {
<del> let components = line.split('=')
<del> let key = components.shift()
<del> let value = components.join('=')
<del> result[key] = value
<add> let components = line.split('=');
<add> let key = components.shift();
<add> let value = components.join('=');
<add> result[key] = value;
<ide> }
<ide> }
<ide> return result; | 1 |
Text | Text | fix dependencyparser.predict docs (resolves ) | 7819404127804db2d76ac2eb8e1569f22f2b1d2f | <ide><path>website/docs/api/dependencyparser.md
<ide> Apply the pipeline's model to a batch of docs, without modifying them.
<ide> > scores = parser.predict([doc1, doc2])
<ide> > ```
<ide>
<del>| Name | Type | Description |
<del>| ----------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
<del>| `docs` | iterable | The documents to predict. |
<del>| **RETURNS** | tuple | A `(scores, tensors)` tuple where `scores` is the model's prediction for each document and `tensors` is the token representations used to predict the scores. Each tensor is an array with one row for each token in the document. |
<add>| Name | Type | Description |
<add>| ----------- | ------------------- | ---------------------------------------------- |
<add>| `docs` | iterable | The documents to predict. |
<add>| **RETURNS** | `syntax.StateClass` | A helper class for the parse state (internal). |
<ide>
<ide> ## DependencyParser.set_annotations {#set_annotations tag="method"}
<ide> | 1 |
Javascript | Javascript | add separator comment between text nodes | 6a589ad711db330c68a371321450ee2f0087e22f | <ide><path>packages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js
<ide> describe('ReactDOMFizzServer', () => {
<ide> <div>hello world</div>,
<ide> );
<ide> const result = await readResult(stream);
<del> expect(result).toBe('<div>hello world</div>');
<add> expect(result).toMatchInlineSnapshot(`"<div>hello world<!-- --></div>"`);
<ide> });
<ide>
<ide> // @gate experimental
<ide> describe('ReactDOMFizzServer', () => {
<ide> expect(isComplete).toBe(true);
<ide>
<ide> const result = await readResult(stream);
<del> expect(result).toBe('<div><!--$-->Done<!--/$--></div>');
<add> expect(result).toMatchInlineSnapshot(
<add> `"<div><!--$-->Done<!-- --><!--/$--></div>"`,
<add> );
<ide> });
<ide>
<ide> // @gate experimental
<ide><path>packages/react-dom/src/__tests__/ReactDOMFizzServerNode-test.js
<ide> describe('ReactDOMFizzServer', () => {
<ide> );
<ide> startWriting();
<ide> jest.runAllTimers();
<del> expect(output.result).toBe('<div>hello world</div>');
<add> expect(output.result).toMatchInlineSnapshot(
<add> `"<div>hello world<!-- --></div>"`,
<add> );
<ide> });
<ide>
<ide> // @gate experimental
<ide> describe('ReactDOMFizzServer', () => {
<ide> '<!doctype html><html><head><title>test</title><head><body>';
<ide> // Then React starts writing.
<ide> startWriting();
<del> expect(output.result).toBe(
<del> '<!doctype html><html><head><title>test</title><head><body><div>hello world</div>',
<add> expect(output.result).toMatchInlineSnapshot(
<add> `"<!doctype html><html><head><title>test</title><head><body><div>hello world<!-- --></div>"`,
<ide> );
<ide> });
<ide>
<ide> describe('ReactDOMFizzServer', () => {
<ide> '<!doctype html><html><head><title>test</title><head><body>';
<ide> // Then React starts writing.
<ide> startWriting();
<del> expect(output.result).toBe(
<del> '<!doctype html><html><head><title>test</title><head><body><div><!--$-->Done<!--/$--></div>',
<add> expect(output.result).toMatchInlineSnapshot(
<add> `"<!doctype html><html><head><title>test</title><head><body><div><!--$-->Done<!-- --><!--/$--></div>"`,
<ide> );
<ide> });
<ide>
<ide><path>packages/react-dom/src/server/ReactDOMServerFormatConfig.js
<ide> export function pushEmpty(
<ide> }
<ide> }
<ide>
<add>const textSeparator = stringToPrecomputedChunk('<!-- -->');
<add>
<ide> export function pushTextInstance(
<ide> target: Array<Chunk | PrecomputedChunk>,
<ide> text: string,
<ide> export function pushTextInstance(
<ide> if (assignID !== null) {
<ide> pushDummyNodeWithID(target, responseState, assignID);
<ide> }
<del> target.push(stringToChunk(encodeHTMLTextNode(text)));
<add> if (text === '') {
<add> // Empty text doesn't have a DOM node representation and the hydration is aware of this.
<add> return;
<add> }
<add> // TODO: Avoid adding a text separator in common cases.
<add> target.push(stringToChunk(encodeHTMLTextNode(text)), textSeparator);
<ide> }
<ide>
<ide> const startTag1 = stringToPrecomputedChunk('<'); | 3 |
Javascript | Javascript | fix reconciling components to content | 5ef3c1b09b486d711b556655c28b93e207a90399 | <ide><path>src/core/ReactMultiChild.js
<ide> function enqueueMarkup(parentID, markup, toIndex) {
<ide> type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
<ide> markupIndex: markupQueue.push(markup) - 1,
<ide> fromIndex: null,
<add> textContent: null,
<ide> toIndex: toIndex
<ide> });
<ide> }
<ide> function enqueueMove(parentID, fromIndex, toIndex) {
<ide> parentNode: null,
<ide> type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
<ide> markupIndex: null,
<add> textContent: null,
<ide> fromIndex: fromIndex,
<ide> toIndex: toIndex
<ide> });
<ide> function enqueueRemove(parentID, fromIndex) {
<ide> parentNode: null,
<ide> type: ReactMultiChildUpdateTypes.REMOVE_NODE,
<ide> markupIndex: null,
<add> textContent: null,
<ide> fromIndex: fromIndex,
<ide> toIndex: null
<ide> });
<ide> }
<ide>
<add>/**
<add> * Enqueues setting the text content.
<add> *
<add> * @param {string} parentID ID of the parent component.
<add> * @param {string} textContent Text content to set.
<add> * @private
<add> */
<add>function enqueueTextContent(parentID, textContent) {
<add> // NOTE: Null values reduce hidden classes.
<add> updateQueue.push({
<add> parentID: parentID,
<add> parentNode: null,
<add> type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
<add> markupIndex: null,
<add> textContent: textContent,
<add> fromIndex: null,
<add> toIndex: null
<add> });
<add>}
<add>
<ide> /**
<ide> * Processes any enqueued updates.
<ide> *
<ide> var ReactMultiChild = {
<ide> return mountImages;
<ide> },
<ide>
<add> /**
<add> * Replaces any rendered children with a text content string.
<add> *
<add> * @param {string} nextContent String of content.
<add> * @internal
<add> */
<add> updateTextContent: function(nextContent) {
<add> updateDepth++;
<add> try {
<add> var prevChildren = this._renderedChildren;
<add> // Remove any rendered children.
<add> for (var name in prevChildren) {
<add> if (prevChildren.hasOwnProperty(name) &&
<add> prevChildren[name]) {
<add> this._unmountChildByName(prevChildren[name], name);
<add> }
<add> }
<add> // Set new text content.
<add> this.setTextContent(nextContent);
<add> } catch (error) {
<add> updateDepth--;
<add> updateDepth || clearQueue();
<add> throw error;
<add> }
<add> updateDepth--;
<add> updateDepth || processQueue();
<add> },
<add>
<ide> /**
<ide> * Updates the rendered children with new children.
<ide> *
<ide> var ReactMultiChild = {
<ide> prevChild._mountIndex = nextIndex;
<ide> } else {
<ide> if (prevChild) {
<del> this._unmountChildByName(prevChild, name);
<add> // Update `lastIndex` before `_mountIndex` gets unset by unmounting.
<ide> lastIndex = Math.max(prevChild._mountIndex, lastIndex);
<add> this._unmountChildByName(prevChild, name);
<ide> }
<ide> if (nextChild) {
<ide> this._mountChildByNameAtIndex(
<ide> var ReactMultiChild = {
<ide> enqueueRemove(this._rootNodeID, child._mountIndex);
<ide> },
<ide>
<add> /**
<add> * Sets this text content string.
<add> *
<add> * @param {string} textContent Text content to set.
<add> * @protected
<add> */
<add> setTextContent: function(textContent) {
<add> enqueueTextContent(this._rootNodeID, textContent);
<add> },
<add>
<ide> /**
<ide> * Mounts a child with the supplied name.
<ide> *
<ide><path>src/core/ReactMultiChildUpdateTypes.js
<ide> var keyMirror = require('keyMirror');
<ide> var ReactMultiChildUpdateTypes = keyMirror({
<ide> INSERT_MARKUP: null,
<ide> MOVE_EXISTING: null,
<del> REMOVE_NODE: null
<add> REMOVE_NODE: null,
<add> TEXT_CONTENT: null
<ide> });
<ide>
<ide> module.exports = ReactMultiChildUpdateTypes;
<ide><path>src/core/ReactNativeComponent.js
<ide> ReactNativeComponent.Mixin = {
<ide> this.updateChildren(null, transaction);
<ide> }
<ide> if (lastUsedContent !== contentToUse) {
<del> ReactComponent.DOMIDOperations.updateTextContentByID(
<del> this._rootNodeID,
<del> '' + contentToUse
<del> );
<add> this.updateTextContent('' + contentToUse);
<ide> }
<ide> } else {
<ide> var contentRemoved = lastUsedContent != null && contentToUse == null;
<ide> if (contentRemoved) {
<del> ReactComponent.DOMIDOperations.updateTextContentByID(
<del> this._rootNodeID,
<del> ''
<del> );
<add> this.updateTextContent('');
<ide> }
<ide> this.updateChildren(flattenChildren(nextProps.children), transaction);
<ide> }
<ide><path>src/core/__tests__/ReactMultiChildText-test.js
<ide> describe('ReactMultiChildText', function() {
<ide> );
<ide> }).toThrow();
<ide> });
<add>
<add> it('should render between nested components and inline children', function() {
<add> var container = document.createElement('div');
<add> React.renderComponent(<div><h1><span /><span /></h1></div>, container);
<add>
<add> expect(function() {
<add> React.renderComponent(<div><h1>A</h1></div>, container);
<add> }).not.toThrow();
<add>
<add> React.renderComponent(<div><h1><span /><span /></h1></div>, container);
<add>
<add> expect(function() {
<add> React.renderComponent(<div><h1>{['A']}</h1></div>, container);
<add> }).not.toThrow();
<add>
<add> React.renderComponent(<div><h1><span /><span /></h1></div>, container);
<add>
<add> expect(function() {
<add> React.renderComponent(<div><h1>{['A', 'B']}</h1></div>, container);
<add> }).not.toThrow();
<add> });
<ide> });
<ide><path>src/dom/DOMChildrenOperations.js
<ide> var Danger = require('Danger');
<ide> var ReactMultiChildUpdateTypes = require('ReactMultiChildUpdateTypes');
<ide>
<add>var getTextContentAccessor = require('getTextContentAccessor');
<add>
<add>/**
<add> * The DOM property to use when setting text content.
<add> *
<add> * @type {string}
<add> * @private
<add> */
<add>var textContentAccessor = getTextContentAccessor() || 'NA';
<add>
<ide> /**
<ide> * Inserts `childNode` as a child of `parentNode` at the `index`.
<ide> *
<ide> var DOMChildrenOperations = {
<ide> var updatedChildren = null;
<ide>
<ide> for (var i = 0; update = updates[i]; i++) {
<del> if (update.type !== ReactMultiChildUpdateTypes.INSERT_MARKUP) {
<add> if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING ||
<add> update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
<ide> var updatedIndex = update.fromIndex;
<ide> var updatedChild = update.parentNode.childNodes[updatedIndex];
<ide> var parentID = update.parentID;
<ide> var DOMChildrenOperations = {
<ide> update.toIndex
<ide> );
<ide> break;
<add> case ReactMultiChildUpdateTypes.TEXT_CONTENT:
<add> update.parentNode[textContentAccessor] = update.textContent;
<add> break;
<ide> case ReactMultiChildUpdateTypes.REMOVE_NODE:
<ide> // Already removed by the for-loop above.
<ide> break; | 5 |
Ruby | Ruby | pass block for logging | bc53543cb3805abd334745a50c9014b31096c8da | <ide><path>actionpack/lib/action_controller/metal/live.rb
<ide> def log_error(exception)
<ide> logger = ActionController::Base.logger
<ide> return unless logger
<ide>
<del> message = "\n#{exception.class} (#{exception.message}):\n"
<del> message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
<del> message << " " << exception.backtrace.join("\n ")
<del> logger.fatal("#{message}\n\n")
<add> logger.fatal do
<add> message = "\n#{exception.class} (#{exception.message}):\n"
<add> message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
<add> message << " " << exception.backtrace.join("\n ")
<add> "#{message}\n\n"
<add> end
<ide> end
<ide>
<ide> def response_body=(body) | 1 |
Python | Python | use .freeze not ._freeze | 33a62b0f52d1e1cac49e8f30f2a1ff471e1f1bfe | <ide><path>celery/app/builtins.py
<ide> def prepare_steps(self, args, tasks):
<ide> # First task get partial args from chain.
<ide> task = maybe_subtask(steps.popleft())
<ide> task = task.clone() if i else task.clone(args)
<del> res = task._freeze()
<add> res = task.freeze()
<ide> i += 1
<ide>
<ide> if isinstance(task, group):
<ide> def prepare_steps(self, args, tasks):
<ide> next_step = steps.popleft()
<ide> # for chords we freeze by pretending it's a normal
<ide> # task instead of a group.
<del> res = Signature._freeze(task)
<add> res = Signature.freeze(task)
<ide> task = chord(task, body=next_step, task_id=res.task_id)
<ide> except IndexError:
<ide> pass # no callback, so keep as group
<ide> def apply_async(self, args=(), kwargs={}, task_id=None,
<ide> body.options['group_id'] = group_id
<ide> [body.link(s) for s in options.pop('link', [])]
<ide> [body.link_error(s) for s in options.pop('link_error', [])]
<del> body_result = body._freeze(task_id)
<add> body_result = body.freeze(task_id)
<ide> parent = super(Chord, self).apply_async((header, body, args),
<ide> kwargs, **options)
<ide> body_result.parent = parent
<ide><path>celery/canvas.py
<ide> def __init__(self, keypath):
<ide> self.path = path.split('.') if path else None
<ide>
<ide> def _path(self, obj):
<del> return (reduce(lambda d, k: d[k], [obj] + self.path) if self.path
<add> return (reduce(lambda d, k: d[k], obj, self.path) if self.path
<ide> else obj)
<ide>
<ide> def __get__(self, obj, type=None):
<ide> def __call__(self, body=None, task_id=None, **kwargs):
<ide> kwargs = dict(self.kwargs, body=body, **kwargs)
<ide> if _chord.app.conf.CELERY_ALWAYS_EAGER:
<ide> return self.apply((), kwargs)
<del> res = body._freeze(task_id)
<add> res = body.freeze(task_id)
<ide> parent = _chord(**kwargs)
<ide> res.parent = parent
<ide> return res
<ide><path>celery/tests/backends/test_base.py
<ide> def callback(result):
<ide> task = Mock()
<ide> task.request.group = 'grid'
<ide> cb = task.request.chord = callback.s()
<del> task.request.chord._freeze()
<add> task.request.chord.freeze()
<ide> callback.backend = b
<ide> callback.backend.fail_from_current_stack = Mock()
<ide> yield task, deps, cb
<ide><path>celery/tests/case.py
<ide> def _inner(*args, **kwargs):
<ide>
<ide>
<ide> def body_from_sig(app, sig, utc=True):
<del> sig._freeze()
<add> sig.freeze()
<ide> callbacks = sig.options.pop('link', None)
<ide> errbacks = sig.options.pop('link_error', None)
<ide> countdown = sig.options.pop('countdown', None)
<ide><path>celery/tests/tasks/test_canvas.py
<ide> def test_set_immutable(self):
<ide>
<ide> def test_election(self):
<ide> x = add.s(2, 2)
<del> x._freeze('foo')
<add> x.freeze('foo')
<ide> prev, x.type.app.control = x.type.app.control, Mock()
<ide> try:
<ide> r = x.election()
<ide><path>celery/tests/worker/test_request.py
<ide> def test_tzlocal_is_cached(self):
<ide>
<ide> def test_execute_magic_kwargs(self):
<ide> task = self.add.s(2, 2)
<del> task._freeze()
<add> task.freeze()
<ide> req = self.get_request(task)
<ide> self.add.accept_magic_kwargs = True
<ide> try:
<ide><path>celery/tests/worker/test_strategy.py
<ide> def test_when_rate_limited__limits_disabled(self):
<ide>
<ide> def test_when_revoked(self):
<ide> task = self.add.s(2, 2)
<del> task._freeze()
<add> task.freeze()
<ide> state.revoked.add(task.id)
<ide> try:
<ide> with self._context(task) as C: | 7 |
Text | Text | add v4.4.3 to changelog | 1ea72b1cd37d80b45f97f05ef228dfeb13405370 | <ide><path>CHANGELOG.md
<ide> # Ember Changelog
<ide>
<add>### v4.4.3 (October 12, 2022)
<add>
<add>- [#20166](https://github.com/emberjs/ember.js/pull/20166) [BUGFIX] Fix missing `RouteInfo` entries
<add>
<ide> ### v4.7.1 (October 12, 2022)
<ide>
<ide> - [#20166](https://github.com/emberjs/ember.js/pull/20166) [BUGFIX] Fix missing `RouteInfo` entries | 1 |
Javascript | Javascript | add angularjs tag to plunks and make private | 25e1ad9a9443de6b7ebb40409af72021cc4e7b20 | <ide><path>docs/src/templates/js/docs.js
<ide> docsApp.serviceFactory.openPlunkr = function(templateMerge, formPostData, angula
<ide> });
<ide>
<ide> postData['files[index.html]'] = templateMerge(indexHtmlContent, indexProp);
<del>
<add> postData['tags[]'] = "angularjs";
<add>
<add> postData.private = true;
<ide> postData.description = 'AngularJS Example Plunkr';
<ide>
<ide> formPostData('http://plnkr.co/edit/?p=preview', postData); | 1 |
Ruby | Ruby | use parallel assignments rather than indices | c7f065b8da7a0da65bc5a39a156a6a14eb28f834 | <ide><path>Library/Homebrew/utils/github.rb
<ide> def create_fork(repo)
<ide> end
<ide>
<ide> def check_fork_exists(repo)
<del> username = api_credentials[1]
<del> reponame = repo.split("/")[1]
<add> _, username = api_credentials
<add> _, reponame = repo.split("/")
<ide> json = open_api(url_to("repos", username, reponame))
<ide> return false if json["message"] == "Not Found"
<ide> | 1 |
Go | Go | fix proc regex | 2b4f64e59018c21aacbf311d5c774dd5521b5352 | <ide><path>daemon/execdriver/native/apparmor.go
<ide> profile {{.Name}} flags=(attach_disconnected,mediate_deleted) {
<ide> file,
<ide> umount,
<ide>
<del> deny @{PROC}/{*,**^[0-9]*,sys/kernel/shm*} wkx,
<add> deny @{PROC}/* w, # deny write for all files directly in /proc (not in a subdir)
<add> # deny write to files not in /proc/<number>/** or /proc/sys/**
<add> deny @{PROC}/{[^1-9],[^1-9][^0-9],[^1-9s][^0-9y][^0-9s],[^1-9][^0-9][^0-9][^0-9]*}/** w,
<add> deny @{PROC}/sys/[^k]** w, # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel)
<add> deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w, # deny everything except shm* in /proc/sys/kernel/
<ide> deny @{PROC}/sysrq-trigger rwklx,
<ide> deny @{PROC}/mem rwklx,
<ide> deny @{PROC}/kmem rwklx,
<ide><path>integration-cli/docker_cli_run_unix_test.go
<ide> func (s *DockerSuite) TestRunSeccompDefaultProfile(c *check.C) {
<ide> c.Fatalf("expected hello, got: %s, %v", out, err)
<ide> }
<ide> }
<add>
<add>func (s *DockerSuite) TestRunApparmorProcDirectory(c *check.C) {
<add> testRequires(c, SameHostDaemon, Apparmor)
<add>
<add> // running w seccomp unconfined tests the apparmor profile
<add> runCmd := exec.Command(dockerBinary, "run", "--security-opt", "seccomp:unconfined", "debian:jessie", "chmod", "777", "/proc/1/cgroup")
<add> if out, _, err := runCommandWithOutput(runCmd); err == nil || !(strings.Contains(out, "Permission denied") || strings.Contains(out, "Operation not permitted")) {
<add> c.Fatalf("expected chmod 777 /proc/1/cgroup to fail, got %s: %v", out, err)
<add> }
<add>
<add> runCmd = exec.Command(dockerBinary, "run", "--security-opt", "seccomp:unconfined", "debian:jessie", "chmod", "777", "/proc/1/attr/current")
<add> if out, _, err := runCommandWithOutput(runCmd); err == nil || !(strings.Contains(out, "Permission denied") || strings.Contains(out, "Operation not permitted")) {
<add> c.Fatalf("expected chmod 777 /proc/1/attr/current to fail, got %s: %v", out, err)
<add> }
<add>} | 2 |
Ruby | Ruby | fix normalization of old- and new-style options | d1c0d4c8793d6ea80f1e9dd3759aa22eb506211a | <ide><path>Library/Homebrew/cmd/options.rb
<ide> def options
<ide>
<ide> def dump_options_for_formula f
<ide> f.build.each do |k,v|
<del> k.prepend "--" unless k.start_with? "--"
<del> puts k
<add> puts "--"+k
<ide> puts "\t"+v
<ide> end
<ide> end
<ide><path>Library/Homebrew/formula.rb
<ide> def initialize name='__UNKNOWN__', path=nil
<ide> @downloader = download_strategy.new(name, @active_spec)
<ide>
<ide> # Combine DSL `option` and `def options`
<del> options.each {|o| self.class.build.add(o[0], o[1]) }
<add> options.each do |opt, desc|
<add> # make sure to strip "--" from the start of options
<add> self.class.build.add opt[/--(.+)$/, 1], desc
<add> end
<ide> end
<ide>
<ide> def url; @active_spec.url; end | 2 |
Python | Python | use consistent test names | 7262421bb272458ce61de5f2f76f1ca8d6b54686 | <ide><path>spacy/tests/doc/test_add_entities.py
<ide> import pytest
<ide>
<ide>
<del>def test_add_entities_set_ents_iob(en_vocab):
<add>def test_doc_add_entities_set_ents_iob(en_vocab):
<ide> text = ["This", "is", "a", "lion"]
<ide> doc = get_doc(en_vocab, text)
<ide> ner = EntityRecognizer(en_vocab, features=[(2,), (3,)])
<ide><path>spacy/tests/doc/test_array.py
<ide> import pytest
<ide>
<ide>
<del>def test_array_attr_of_token(en_tokenizer, en_vocab):
<add>def test_doc_array_attr_of_token(en_tokenizer, en_vocab):
<ide> text = "An example sentence"
<ide> tokens = en_tokenizer(text)
<ide> example = tokens.vocab["example"]
<ide> def test_array_attr_of_token(en_tokenizer, en_vocab):
<ide> assert feats_array[0][0] != feats_array[0][1]
<ide>
<ide>
<del>def test_array_tag(en_tokenizer):
<add>def test_doc_array_tag(en_tokenizer):
<ide> text = "A nice sentence."
<ide> tags = ['DET', 'ADJ', 'NOUN', 'PUNCT']
<ide> tokens = en_tokenizer(text)
<ide> def test_array_tag(en_tokenizer):
<ide> assert feats_array[3][1] == doc[3].pos
<ide>
<ide>
<del>def test_array_dep(en_tokenizer):
<add>def test_doc_array_dep(en_tokenizer):
<ide> text = "A nice sentence."
<ide> deps = ['det', 'amod', 'ROOT', 'punct']
<ide> tokens = en_tokenizer(text)
<ide><path>spacy/tests/doc/test_noun_chunks.py
<ide> import numpy
<ide>
<ide>
<del>def test_noun_chunks_not_nested(en_tokenizer):
<add>def test_doc_noun_chunks_not_nested(en_tokenizer):
<ide> text = "Peter has chronic command and control issues"
<ide> heads = [1, 0, 4, 3, -1, -2, -5]
<ide> deps = ['nsubj', 'ROOT', 'amod', 'nmod', 'cc', 'conj', 'dobj']
<ide><path>spacy/tests/doc/test_token_api.py
<ide> import numpy
<ide>
<ide>
<del>def test_token_api_strings(en_tokenizer):
<add>def test_doc_token_api_strings(en_tokenizer):
<ide> text = "Give it back! He pleaded."
<ide> tags = ['VERB', 'PRON', 'PART', 'PUNCT', 'PRON', 'VERB', 'PUNCT']
<ide> heads = [0, -1, -2, -3, 1, 0, -1]
<ide> def test_token_api_strings(en_tokenizer):
<ide> assert doc[0].dep_ == 'ROOT'
<ide>
<ide>
<del>def test_token_api_flags(en_tokenizer):
<add>def test_doc_token_api_flags(en_tokenizer):
<ide> text = "Give it back! He pleaded."
<ide> tokens = en_tokenizer(text)
<ide> assert tokens[0].check_flag(IS_ALPHA)
<ide> def test_token_api_flags(en_tokenizer):
<ide>
<ide>
<ide> @pytest.mark.parametrize('text', ["Give it back! He pleaded."])
<del>def test_token_api_prob_inherited_from_vocab(en_tokenizer, text):
<add>def test_doc_token_api_prob_inherited_from_vocab(en_tokenizer, text):
<ide> word = text.split()[0]
<ide> en_tokenizer.vocab[word].prob = -1
<ide> tokens = en_tokenizer(text)
<ide> assert tokens[0].prob != 0
<ide>
<ide>
<ide> @pytest.mark.parametrize('text', ["one two"])
<del>def test_token_api_str_builtin(en_tokenizer, text):
<add>def test_doc_token_api_str_builtin(en_tokenizer, text):
<ide> tokens = en_tokenizer(text)
<ide> assert str(tokens[0]) == text.split(' ')[0]
<ide> assert str(tokens[1]) == text.split(' ')[1]
<ide>
<ide>
<del>def test_token_api_is_properties(en_vocab):
<add>def test_doc_token_api_is_properties(en_vocab):
<ide> text = ["Hi", ",", "my", "email", "is", "[email protected]"]
<ide> doc = get_doc(en_vocab, text)
<ide> assert doc[0].is_title
<ide> def test_token_api_is_properties(en_vocab):
<ide> @pytest.mark.parametrize('text,vectors', [
<ide> ("apples oranges ldskbjls", ["apples -1 -1 -1", "oranges -1 -1 0"])
<ide> ])
<del>def test_token_api_vectors(en_tokenizer, text_file, text, vectors):
<add>def test_doc_token_api_vectors(en_tokenizer, text_file, text, vectors):
<ide> text_file.write('\n'.join(vectors))
<ide> text_file.seek(0)
<ide> vector_length = en_tokenizer.vocab.load_vectors(text_file)
<ide> def test_token_api_vectors(en_tokenizer, text_file, text, vectors):
<ide> numpy.sqrt(numpy.dot(tokens[0].vector, tokens[0].vector)))
<ide>
<ide>
<del>def test_token_api_ancestors(en_tokenizer):
<add>def test_doc_token_api_ancestors(en_tokenizer):
<ide> # the structure of this sentence depends on the English annotation scheme
<ide> text = "Yesterday I saw a dog that barked loudly."
<ide> heads = [2, 1, 0, 1, -2, 1, -2, -1, -6]
<ide> def test_token_api_ancestors(en_tokenizer):
<ide> assert not doc[6].is_ancestor_of(doc[2])
<ide>
<ide>
<del>def test_token_api_head_setter(en_tokenizer):
<add>def test_doc_token_api_head_setter(en_tokenizer):
<ide> # the structure of this sentence depends on the English annotation scheme
<ide> text = "Yesterday I saw a dog that barked loudly."
<ide> heads = [2, 1, 0, 1, -2, 1, -2, -1, -6] | 4 |
Javascript | Javascript | fix error handling | 333adf61eb3d8d973b28e6c86d8b93d39d95cfe6 | <ide><path>lib/internal/crypto/random.js
<ide> const {
<ide>
<ide> const { kMaxLength } = require('buffer');
<ide> const kMaxUint32 = Math.pow(2, 32) - 1;
<add>const kMaxPossibleLength = Math.min(kMaxLength, kMaxUint32);
<ide>
<del>function assertOffset(offset, length) {
<del> if (typeof offset !== 'number' || Number.isNaN(offset)) {
<del> throw new ERR_INVALID_ARG_TYPE('offset', 'number');
<add>function assertOffset(offset, elementSize, length) {
<add> if (typeof offset !== 'number') {
<add> throw new ERR_INVALID_ARG_TYPE('offset', 'number', offset);
<ide> }
<ide>
<del> if (offset > kMaxUint32 || offset < 0) {
<del> throw new ERR_INVALID_ARG_TYPE('offset', 'uint32');
<del> }
<add> offset *= elementSize;
<ide>
<del> if (offset > kMaxLength || offset > length) {
<del> throw new ERR_OUT_OF_RANGE('offset');
<add> const maxLength = Math.min(length, kMaxPossibleLength);
<add> if (Number.isNaN(offset) || offset > maxLength || offset < 0) {
<add> throw new ERR_OUT_OF_RANGE('offset', `>= 0 && <= ${maxLength}`, offset);
<ide> }
<add>
<add> return offset;
<ide> }
<ide>
<del>function assertSize(size, offset = 0, length = Infinity) {
<del> if (typeof size !== 'number' || Number.isNaN(size)) {
<del> throw new ERR_INVALID_ARG_TYPE('size', 'number');
<add>function assertSize(size, elementSize, offset, length) {
<add> if (typeof size !== 'number') {
<add> throw new ERR_INVALID_ARG_TYPE('size', 'number', size);
<ide> }
<ide>
<del> if (size > kMaxUint32 || size < 0) {
<del> throw new ERR_INVALID_ARG_TYPE('size', 'uint32');
<add> size *= elementSize;
<add>
<add> if (Number.isNaN(size) || size > kMaxPossibleLength || size < 0) {
<add> throw new ERR_OUT_OF_RANGE('size',
<add> `>= 0 && <= ${kMaxPossibleLength}`, size);
<ide> }
<ide>
<del> if (size + offset > length || size > kMaxLength) {
<del> throw new ERR_OUT_OF_RANGE('size');
<add> if (size + offset > length) {
<add> throw new ERR_OUT_OF_RANGE('size + offset', `<= ${length}`, size + offset);
<ide> }
<add>
<add> return size;
<ide> }
<ide>
<ide> function randomBytes(size, cb) {
<del> assertSize(size);
<add> assertSize(size, 1, 0, Infinity);
<ide> if (cb !== undefined && typeof cb !== 'function')
<ide> throw new ERR_INVALID_CALLBACK();
<ide> return _randomBytes(size, cb);
<ide> function randomFillSync(buf, offset = 0, size) {
<ide>
<ide> const elementSize = buf.BYTES_PER_ELEMENT || 1;
<ide>
<del> offset *= elementSize;
<del> assertOffset(offset, buf.byteLength);
<add> offset = assertOffset(offset, elementSize, buf.byteLength);
<ide>
<ide> if (size === undefined) {
<ide> size = buf.byteLength - offset;
<ide> } else {
<del> size *= elementSize;
<add> size = assertSize(size, elementSize, offset, buf.byteLength);
<ide> }
<ide>
<del> assertSize(size, offset, buf.byteLength);
<del>
<ide> return _randomFill(buf, offset, size);
<ide> }
<ide>
<ide> function randomFill(buf, offset, size, cb) {
<ide> size = buf.bytesLength;
<ide> } else if (typeof size === 'function') {
<ide> cb = size;
<del> offset *= elementSize;
<ide> size = buf.byteLength - offset;
<ide> } else if (typeof cb !== 'function') {
<ide> throw new ERR_INVALID_CALLBACK();
<ide> }
<add>
<add> offset = assertOffset(offset, elementSize, buf.byteLength);
<add>
<ide> if (size === undefined) {
<ide> size = buf.byteLength - offset;
<ide> } else {
<del> size *= elementSize;
<add> size = assertSize(size, elementSize, offset, buf.byteLength);
<ide> }
<ide>
<del> assertOffset(offset, buf.byteLength);
<del> assertSize(size, offset, buf.byteLength);
<del>
<ide> return _randomFill(buf, offset, size, cb);
<ide> }
<ide>
<ide><path>test/parallel/test-crypto-random.js
<ide> if (!common.hasCrypto)
<ide>
<ide> const assert = require('assert');
<ide> const crypto = require('crypto');
<add>const { kMaxLength } = require('buffer');
<add>
<add>const kMaxUint32 = Math.pow(2, 32) - 1;
<add>const kMaxPossibleLength = Math.min(kMaxLength, kMaxUint32);
<ide>
<ide> crypto.DEFAULT_ENCODING = 'buffer';
<ide>
<ide> // bump, we register a lot of exit listeners
<ide> process.setMaxListeners(256);
<ide>
<del>[crypto.randomBytes, crypto.pseudoRandomBytes].forEach(function(f) {
<del> [-1, undefined, null, false, true, {}, []].forEach(function(value) {
<del>
<del> common.expectsError(
<del> () => f(value),
<del> {
<add>{
<add> [crypto.randomBytes, crypto.pseudoRandomBytes].forEach((f) => {
<add> [undefined, null, false, true, {}, []].forEach((value) => {
<add> const errObj = {
<ide> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: /^The "size" argument must be of type (number|uint32)$/
<del> }
<del> );
<add> name: 'TypeError [ERR_INVALID_ARG_TYPE]',
<add> message: 'The "size" argument must be of type number. ' +
<add> `Received type ${typeof value}`
<add> };
<add> assert.throws(() => f(value), errObj);
<add> assert.throws(() => f(value, common.mustNotCall()), errObj);
<add> });
<ide>
<del> common.expectsError(
<del> () => f(value, common.mustNotCall()),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: /^The "size" argument must be of type (number|uint32)$/
<del> }
<del> );
<del> });
<add> [-1, NaN, 2 ** 32].forEach((value) => {
<add> const errObj = {
<add> code: 'ERR_OUT_OF_RANGE',
<add> name: 'RangeError [ERR_OUT_OF_RANGE]',
<add> message: 'The value of "size" is out of range. It must be >= 0 && <= ' +
<add> `${kMaxPossibleLength}. Received ${value}`
<add> };
<add> assert.throws(() => f(value), errObj);
<add> assert.throws(() => f(value, common.mustNotCall()), errObj);
<add> });
<ide>
<del> [0, 1, 2, 4, 16, 256, 1024, 101.2].forEach(function(len) {
<del> f(len, common.mustCall(function(ex, buf) {
<del> assert.strictEqual(ex, null);
<del> assert.strictEqual(buf.length, Math.floor(len));
<del> assert.ok(Buffer.isBuffer(buf));
<del> }));
<add> [0, 1, 2, 4, 16, 256, 1024, 101.2].forEach((len) => {
<add> f(len, common.mustCall((ex, buf) => {
<add> assert.strictEqual(ex, null);
<add> assert.strictEqual(buf.length, Math.floor(len));
<add> assert.ok(Buffer.isBuffer(buf));
<add> }));
<add> });
<ide> });
<del>});
<add>}
<ide>
<ide> {
<ide> const buf = Buffer.alloc(10);
<ide> process.setMaxListeners(256);
<ide> }
<ide>
<ide> {
<del> const bufs = [
<add> [
<ide> Buffer.alloc(10),
<ide> new Uint8Array(new Array(10).fill(0))
<del> ];
<del>
<del> const max = require('buffer').kMaxLength + 1;
<del>
<del> for (const buf of bufs) {
<add> ].forEach((buf) => {
<ide> const len = Buffer.byteLength(buf);
<ide> assert.strictEqual(len, 10, `Expected byteLength of 10, got ${len}`);
<ide>
<del> common.expectsError(
<del> () => crypto.randomFillSync(buf, 'test'),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "offset" argument must be of type number'
<del> }
<del> );
<add> const typeErrObj = {
<add> code: 'ERR_INVALID_ARG_TYPE',
<add> name: 'TypeError [ERR_INVALID_ARG_TYPE]',
<add> message: 'The "offset" argument must be of type number. ' +
<add> 'Received type string'
<add> };
<ide>
<del> common.expectsError(
<del> () => crypto.randomFillSync(buf, NaN),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "offset" argument must be of type number'
<del> }
<del> );
<add> assert.throws(() => crypto.randomFillSync(buf, 'test'), typeErrObj);
<ide>
<del> common.expectsError(
<add> assert.throws(
<ide> () => crypto.randomFill(buf, 'test', common.mustNotCall()),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "offset" argument must be of type number'
<del> }
<del> );
<del>
<del> common.expectsError(
<del> () => crypto.randomFill(buf, NaN, common.mustNotCall()),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "offset" argument must be of type number'
<del> }
<del> );
<del>
<del> common.expectsError(
<del> () => crypto.randomFillSync(buf, 11),
<del> {
<del> code: 'ERR_OUT_OF_RANGE',
<del> type: RangeError,
<del> message: 'The value of "offset" is out of range.'
<del> }
<del> );
<del>
<del> common.expectsError(
<del> () => crypto.randomFillSync(buf, max),
<del> {
<del> code: 'ERR_OUT_OF_RANGE',
<del> type: RangeError,
<del> message: 'The value of "offset" is out of range.'
<del> }
<del> );
<del>
<del> common.expectsError(
<del> () => crypto.randomFill(buf, 11, common.mustNotCall()),
<del> {
<del> code: 'ERR_OUT_OF_RANGE',
<del> type: RangeError,
<del> message: 'The value of "offset" is out of range.'
<del> }
<del> );
<del>
<del> common.expectsError(
<del> () => crypto.randomFill(buf, max, common.mustNotCall()),
<del> {
<del> code: 'ERR_OUT_OF_RANGE',
<del> type: RangeError,
<del> message: 'The value of "offset" is out of range.'
<del> }
<del> );
<add> typeErrObj);
<ide>
<del> common.expectsError(
<del> () => crypto.randomFillSync(buf, 0, 'test'),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "size" argument must be of type number'
<del> }
<del> );
<del>
<del> common.expectsError(
<del> () => crypto.randomFillSync(buf, 0, NaN),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "size" argument must be of type number'
<del> }
<del> );
<add> typeErrObj.message = 'The "size" argument must be of type number. ' +
<add> 'Received type string';
<add> assert.throws(() => crypto.randomFillSync(buf, 0, 'test'), typeErrObj);
<ide>
<del> common.expectsError(
<add> assert.throws(
<ide> () => crypto.randomFill(buf, 0, 'test', common.mustNotCall()),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "size" argument must be of type number'
<del> }
<add> typeErrObj
<ide> );
<ide>
<del> common.expectsError(
<del> () => crypto.randomFill(buf, 0, NaN, common.mustNotCall()),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "size" argument must be of type number'
<del> }
<del> );
<add> [NaN, kMaxPossibleLength + 1, -10, (-1 >>> 0) + 1].forEach((offsetSize) => {
<add> const errObj = {
<add> code: 'ERR_OUT_OF_RANGE',
<add> name: 'RangeError [ERR_OUT_OF_RANGE]',
<add> message: 'The value of "offset" is out of range. ' +
<add> `It must be >= 0 && <= 10. Received ${offsetSize}`
<add> };
<ide>
<del> {
<del> const size = (-1 >>> 0) + 1;
<del>
<del> common.expectsError(
<del> () => crypto.randomFillSync(buf, 0, -10),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "size" argument must be of type uint32'
<del> }
<del> );
<add> assert.throws(() => crypto.randomFillSync(buf, offsetSize), errObj);
<ide>
<del> common.expectsError(
<del> () => crypto.randomFillSync(buf, 0, size),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "size" argument must be of type uint32'
<del> }
<del> );
<add> assert.throws(
<add> () => crypto.randomFill(buf, offsetSize, common.mustNotCall()),
<add> errObj);
<ide>
<del> common.expectsError(
<del> () => crypto.randomFill(buf, 0, -10, common.mustNotCall()),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "size" argument must be of type uint32'
<del> }
<del> );
<add> errObj.message = 'The value of "size" is out of range. It must be >= ' +
<add> `0 && <= ${kMaxPossibleLength}. Received ${offsetSize}`;
<add> assert.throws(() => crypto.randomFillSync(buf, 1, offsetSize), errObj);
<ide>
<del> common.expectsError(
<del> () => crypto.randomFill(buf, 0, size, common.mustNotCall()),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "size" argument must be of type uint32'
<del> }
<add> assert.throws(
<add> () => crypto.randomFill(buf, 1, offsetSize, common.mustNotCall()),
<add> errObj
<ide> );
<del> }
<del>
<del> common.expectsError(
<del> () => crypto.randomFillSync(buf, -10),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "offset" argument must be of type uint32'
<del> }
<del> );
<del>
<del> common.expectsError(
<del> () => crypto.randomFill(buf, -10, common.mustNotCall()),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "offset" argument must be of type uint32'
<del> }
<del> );
<add> });
<ide>
<del> common.expectsError(
<del> () => crypto.randomFillSync(buf, 1, 10),
<del> {
<del> code: 'ERR_OUT_OF_RANGE',
<del> type: RangeError,
<del> message: 'The value of "size" is out of range.'
<del> }
<del> );
<add> const rangeErrObj = {
<add> code: 'ERR_OUT_OF_RANGE',
<add> name: 'RangeError [ERR_OUT_OF_RANGE]',
<add> message: 'The value of "size + offset" is out of range. ' +
<add> 'It must be <= 10. Received 11'
<add> };
<add> assert.throws(() => crypto.randomFillSync(buf, 1, 10), rangeErrObj);
<ide>
<del> common.expectsError(
<add> assert.throws(
<ide> () => crypto.randomFill(buf, 1, 10, common.mustNotCall()),
<del> {
<del> code: 'ERR_OUT_OF_RANGE',
<del> type: RangeError,
<del> message: 'The value of "size" is out of range.'
<del> }
<add> rangeErrObj
<ide> );
<del>
<del> common.expectsError(
<del> () => crypto.randomFillSync(buf, 0, 12),
<del> {
<del> code: 'ERR_OUT_OF_RANGE',
<del> type: RangeError,
<del> message: 'The value of "size" is out of range.'
<del> }
<del> );
<del>
<del> common.expectsError(
<del> () => crypto.randomFill(buf, 0, 12, common.mustNotCall()),
<del> {
<del> code: 'ERR_OUT_OF_RANGE',
<del> type: RangeError,
<del> message: 'The value of "size" is out of range.'
<del> }
<del> );
<del>
<del> {
<del> // Offset is too big
<del> const offset = (-1 >>> 0) + 1;
<del> common.expectsError(
<del> () => crypto.randomFillSync(buf, offset, 10),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "offset" argument must be of type uint32'
<del> }
<del> );
<del>
<del> common.expectsError(
<del> () => crypto.randomFill(buf, offset, 10, common.mustNotCall()),
<del> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "offset" argument must be of type uint32'
<del> }
<del> );
<del> }
<del> }
<add> });
<ide> }
<ide>
<ide> // https://github.com/nodejs/node-v0.x-archive/issues/5126,
<ide> // "FATAL ERROR: v8::Object::SetIndexedPropertiesToExternalArrayData() length
<ide> // exceeds max acceptable value"
<del>common.expectsError(
<add>assert.throws(
<ide> () => crypto.randomBytes((-1 >>> 0) + 1),
<ide> {
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> type: TypeError,
<del> message: 'The "size" argument must be of type uint32'
<add> code: 'ERR_OUT_OF_RANGE',
<add> name: 'RangeError [ERR_OUT_OF_RANGE]',
<add> message: 'The value of "size" is out of range. ' +
<add> `It must be >= 0 && <= ${kMaxPossibleLength}. Received 4294967296`
<ide> }
<ide> );
<ide> | 2 |
Java | Java | remove unnecessary @suppresswarnings | d836fb4a7a8952ee1de3df9567eec4052349cedb | <ide><path>spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java
<ide> private void registerBeanDefinitionForImportedConfigurationClass(ConfigurationCl
<ide> * Read the given {@link BeanMethod}, registering bean definitions
<ide> * with the BeanDefinitionRegistry based on its contents.
<ide> */
<del> @SuppressWarnings("deprecation") // for RequiredAnnotationBeanPostProcessor.SKIP_REQUIRED_CHECK_ATTRIBUTE
<ide> private void loadBeanDefinitionsForBeanMethod(BeanMethod beanMethod) {
<ide> ConfigurationClass configClass = beanMethod.getConfigurationClass();
<ide> MethodMetadata metadata = beanMethod.getMetadata(); | 1 |
Text | Text | remove section on "recent" ecdh changes | 6b428e72f92192f255f9c9364073593a52ee0e5b | <ide><path>doc/api/crypto.md
<ide> and returned `'latin1'` encoded strings by default rather than `Buffer`s. This
<ide> default was changed after Node.js v0.8 to use [`Buffer`][] objects by default
<ide> instead.
<ide>
<del>### Recent ECDH changes
<del>
<del>Usage of `ECDH` with non-dynamically generated key pairs has been simplified.
<del>Now, [`ecdh.setPrivateKey()`][] can be called with a preselected private key
<del>and the associated public point (key) will be computed and stored in the object.
<del>This allows code to only store and provide the private part of the EC key pair.
<del>[`ecdh.setPrivateKey()`][] now also validates that the private key is valid for
<del>the selected curve.
<del>
<del>The [`ecdh.setPublicKey()`][] method is now deprecated as its inclusion in the
<del>API is not useful. Either a previously stored private key should be set, which
<del>automatically generates the associated public key, or [`ecdh.generateKeys()`][]
<del>should be called. The main drawback of using [`ecdh.setPublicKey()`][] is that
<del>it can be used to put the ECDH key pair into an inconsistent state.
<del>
<ide> ### Support for weak or compromised algorithms
<ide>
<ide> The `crypto` module still supports some algorithms which are already
<ide> See the [list of SSL OP Flags][] for details.
<ide> [`diffieHellman.setPublicKey()`]: #diffiehellmansetpublickeypublickey-encoding
<ide> [`ecdh.generateKeys()`]: #ecdhgeneratekeysencoding-format
<ide> [`ecdh.setPrivateKey()`]: #ecdhsetprivatekeyprivatekey-encoding
<del>[`ecdh.setPublicKey()`]: #ecdhsetpublickeypublickey-encoding
<ide> [`hash.digest()`]: #hashdigestencoding
<ide> [`hash.update()`]: #hashupdatedata-inputencoding
<ide> [`hmac.digest()`]: #hmacdigestencoding | 1 |
Javascript | Javascript | convert react native builds to named exports | 3e809bf5d46dbabdc2ccbec41e030c5cb1efeac4 | <ide><path>packages/react-native-renderer/fabric.js
<ide> * @flow
<ide> */
<ide>
<del>'use strict';
<add>import type {ReactFabricType} from './src/ReactNativeTypes';
<add>import * as ReactFabric from './src/ReactFabric';
<add>// Assert that the exports line up with the type we're going to expose.
<add>// eslint-disable-next-line no-unused-expressions
<add>(ReactFabric: ReactFabricType);
<ide>
<del>const ReactFabric = require('./src/ReactFabric');
<del>
<del>// TODO: decide on the top-level export form.
<del>// This is hacky but makes it work with both Rollup and Jest.
<del>module.exports = ReactFabric.default || ReactFabric;
<add>export * from './src/ReactFabric';
<ide><path>packages/react-native-renderer/index.js
<ide> * @flow
<ide> */
<ide>
<del>'use strict';
<add>import type {ReactNativeType} from './src/ReactNativeTypes';
<add>import * as ReactNative from './src/ReactNativeRenderer';
<add>// Assert that the exports line up with the type we're going to expose.
<add>// eslint-disable-next-line no-unused-expressions
<add>(ReactNative: ReactNativeType);
<ide>
<del>const ReactNativeRenderer = require('./src/ReactNativeRenderer');
<del>
<del>// TODO: decide on the top-level export form.
<del>// This is hacky but makes it work with both Rollup and Jest.
<del>module.exports = ReactNativeRenderer.default || ReactNativeRenderer;
<add>export * from './src/ReactNativeRenderer';
<ide><path>packages/react-native-renderer/src/ReactFabric.js
<ide> * @flow
<ide> */
<ide>
<del>import type {ReactFabricType, HostComponent} from './ReactNativeTypes';
<add>import type {HostComponent} from './ReactNativeTypes';
<ide> import type {ReactNodeList} from 'shared/ReactTypes';
<ide> import type {ElementRef} from 'react';
<ide>
<ide> import {
<ide> getPublicRootInstance,
<ide> } from 'react-reconciler/inline.fabric';
<ide>
<del>import {createPortal} from 'shared/ReactPortal';
<add>import {createPortal as createPortalImpl} from 'shared/ReactPortal';
<ide> import {setBatchingImplementation} from 'legacy-events/ReactGenericBatching';
<ide> import ReactVersion from 'shared/ReactVersion';
<ide>
<ide> function findNodeHandle(componentOrHandle: any): ?number {
<ide> return hostInstance._nativeTag;
<ide> }
<ide>
<add>function dispatchCommand(handle: any, command: string, args: Array<any>) {
<add> if (handle._nativeTag == null) {
<add> if (__DEV__) {
<add> console.error(
<add> "dispatchCommand was called with a ref that isn't a " +
<add> 'native component. Use React.forwardRef to get access to the underlying native component',
<add> );
<add> }
<add>
<add> return;
<add> }
<add>
<add> if (handle._internalInstanceHandle) {
<add> nativeFabricUIManager.dispatchCommand(
<add> handle._internalInstanceHandle.stateNode.node,
<add> command,
<add> args,
<add> );
<add> } else {
<add> UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args);
<add> }
<add>}
<add>
<add>function render(
<add> element: React$Element<any>,
<add> containerTag: any,
<add> callback: ?Function,
<add>) {
<add> let root = roots.get(containerTag);
<add>
<add> if (!root) {
<add> // TODO (bvaughn): If we decide to keep the wrapper component,
<add> // We could create a wrapper for containerTag as well to reduce special casing.
<add> root = createContainer(containerTag, LegacyRoot, false, null);
<add> roots.set(containerTag, root);
<add> }
<add> updateContainer(element, root, null, callback);
<add>
<add> return getPublicRootInstance(root);
<add>}
<add>
<add>function unmountComponentAtNode(containerTag: number) {
<add> this.stopSurface(containerTag);
<add>}
<add>
<add>function stopSurface(containerTag: number) {
<add> const root = roots.get(containerTag);
<add> if (root) {
<add> // TODO: Is it safe to reset this now or should I wait since this unmount could be deferred?
<add> updateContainer(null, root, null, () => {
<add> roots.delete(containerTag);
<add> });
<add> }
<add>}
<add>
<add>function createPortal(
<add> children: ReactNodeList,
<add> containerTag: number,
<add> key: ?string = null,
<add>) {
<add> return createPortalImpl(children, containerTag, null, key);
<add>}
<add>
<ide> setBatchingImplementation(
<ide> batchedUpdatesImpl,
<ide> discreteUpdates,
<ide> setBatchingImplementation(
<ide>
<ide> const roots = new Map();
<ide>
<del>const ReactFabric: ReactFabricType = {
<add>export {
<ide> // This is needed for implementation details of TouchableNativeFeedback
<ide> // Remove this once TouchableNativeFeedback doesn't use cloneElement
<ide> findHostInstance_DEPRECATED,
<ide> findNodeHandle,
<del>
<del> dispatchCommand(handle: any, command: string, args: Array<any>) {
<del> if (handle._nativeTag == null) {
<del> if (__DEV__) {
<del> console.error(
<del> "dispatchCommand was called with a ref that isn't a " +
<del> 'native component. Use React.forwardRef to get access to the underlying native component',
<del> );
<del> }
<del>
<del> return;
<del> }
<del>
<del> if (handle._internalInstanceHandle) {
<del> nativeFabricUIManager.dispatchCommand(
<del> handle._internalInstanceHandle.stateNode.node,
<del> command,
<del> args,
<del> );
<del> } else {
<del> UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args);
<del> }
<del> },
<del>
<del> render(element: React$Element<any>, containerTag: any, callback: ?Function) {
<del> let root = roots.get(containerTag);
<del>
<del> if (!root) {
<del> // TODO (bvaughn): If we decide to keep the wrapper component,
<del> // We could create a wrapper for containerTag as well to reduce special casing.
<del> root = createContainer(containerTag, LegacyRoot, false, null);
<del> roots.set(containerTag, root);
<del> }
<del> updateContainer(element, root, null, callback);
<del>
<del> return getPublicRootInstance(root);
<del> },
<del>
<add> dispatchCommand,
<add> render,
<ide> // Deprecated - this function is being renamed to stopSurface, use that instead.
<ide> // TODO (T47576999): Delete this once it's no longer called from native code.
<del> unmountComponentAtNode(containerTag: number) {
<del> this.stopSurface(containerTag);
<del> },
<del>
<del> stopSurface(containerTag: number) {
<del> const root = roots.get(containerTag);
<del> if (root) {
<del> // TODO: Is it safe to reset this now or should I wait since this unmount could be deferred?
<del> updateContainer(null, root, null, () => {
<del> roots.delete(containerTag);
<del> });
<del> }
<del> },
<del>
<del> createPortal(
<del> children: ReactNodeList,
<del> containerTag: number,
<del> key: ?string = null,
<del> ) {
<del> return createPortal(children, containerTag, null, key);
<del> },
<del>
<del> __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {},
<add> unmountComponentAtNode,
<add> stopSurface,
<add> createPortal,
<ide> };
<ide>
<ide> injectIntoDevTools({
<ide> injectIntoDevTools({
<ide> version: ReactVersion,
<ide> rendererPackageName: 'react-native-renderer',
<ide> });
<del>
<del>export default ReactFabric;
<ide><path>packages/react-native-renderer/src/ReactNativeRenderer.js
<ide> * @flow
<ide> */
<ide>
<del>import type {ReactNativeType, HostComponent} from './ReactNativeTypes';
<add>import type {HostComponent} from './ReactNativeTypes';
<ide> import type {ReactNodeList} from 'shared/ReactTypes';
<ide>
<ide> import './ReactNativeInjection';
<ide> import {
<ide> } from 'react-reconciler/inline.native';
<ide> // TODO: direct imports like some-package/src/* are bad. Fix me.
<ide> import {getStackByFiberInDevAndProd} from 'react-reconciler/src/ReactCurrentFiber';
<del>import {createPortal} from 'shared/ReactPortal';
<add>import {createPortal as createPortalImpl} from 'shared/ReactPortal';
<ide> import {
<ide> setBatchingImplementation,
<ide> batchedUpdates,
<ide> function findNodeHandle(componentOrHandle: any): ?number {
<ide> return hostInstance._nativeTag;
<ide> }
<ide>
<add>function dispatchCommand(handle: any, command: string, args: Array<any>) {
<add> if (handle._nativeTag == null) {
<add> if (__DEV__) {
<add> console.error(
<add> "dispatchCommand was called with a ref that isn't a " +
<add> 'native component. Use React.forwardRef to get access to the underlying native component',
<add> );
<add> }
<add> return;
<add> }
<add>
<add> if (handle._internalInstanceHandle) {
<add> nativeFabricUIManager.dispatchCommand(
<add> handle._internalInstanceHandle.stateNode.node,
<add> command,
<add> args,
<add> );
<add> } else {
<add> UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args);
<add> }
<add>}
<add>
<add>function render(
<add> element: React$Element<any>,
<add> containerTag: any,
<add> callback: ?Function,
<add>) {
<add> let root = roots.get(containerTag);
<add>
<add> if (!root) {
<add> // TODO (bvaughn): If we decide to keep the wrapper component,
<add> // We could create a wrapper for containerTag as well to reduce special casing.
<add> root = createContainer(containerTag, LegacyRoot, false, null);
<add> roots.set(containerTag, root);
<add> }
<add> updateContainer(element, root, null, callback);
<add>
<add> return getPublicRootInstance(root);
<add>}
<add>
<add>function unmountComponentAtNode(containerTag: number) {
<add> const root = roots.get(containerTag);
<add> if (root) {
<add> // TODO: Is it safe to reset this now or should I wait since this unmount could be deferred?
<add> updateContainer(null, root, null, () => {
<add> roots.delete(containerTag);
<add> });
<add> }
<add>}
<add>
<add>function unmountComponentAtNodeAndRemoveContainer(containerTag: number) {
<add> unmountComponentAtNode(containerTag);
<add>
<add> // Call back into native to remove all of the subviews from this container
<add> UIManager.removeRootView(containerTag);
<add>}
<add>
<add>function createPortal(
<add> children: ReactNodeList,
<add> containerTag: number,
<add> key: ?string = null,
<add>) {
<add> return createPortalImpl(children, containerTag, null, key);
<add>}
<add>
<ide> setBatchingImplementation(
<ide> batchedUpdatesImpl,
<ide> discreteUpdates,
<ide> function computeComponentStackForErrorReporting(reactTag: number): string {
<ide>
<ide> const roots = new Map();
<ide>
<del>const ReactNativeRenderer: ReactNativeType = {
<add>const Internals = {
<add> computeComponentStackForErrorReporting,
<add>};
<add>
<add>export {
<ide> // This is needed for implementation details of TouchableNativeFeedback
<ide> // Remove this once TouchableNativeFeedback doesn't use cloneElement
<ide> findHostInstance_DEPRECATED,
<ide> findNodeHandle,
<del>
<del> dispatchCommand(handle: any, command: string, args: Array<any>) {
<del> if (handle._nativeTag == null) {
<del> if (__DEV__) {
<del> console.error(
<del> "dispatchCommand was called with a ref that isn't a " +
<del> 'native component. Use React.forwardRef to get access to the underlying native component',
<del> );
<del> }
<del> return;
<del> }
<del>
<del> if (handle._internalInstanceHandle) {
<del> nativeFabricUIManager.dispatchCommand(
<del> handle._internalInstanceHandle.stateNode.node,
<del> command,
<del> args,
<del> );
<del> } else {
<del> UIManager.dispatchViewManagerCommand(handle._nativeTag, command, args);
<del> }
<del> },
<del>
<del> render(element: React$Element<any>, containerTag: any, callback: ?Function) {
<del> let root = roots.get(containerTag);
<del>
<del> if (!root) {
<del> // TODO (bvaughn): If we decide to keep the wrapper component,
<del> // We could create a wrapper for containerTag as well to reduce special casing.
<del> root = createContainer(containerTag, LegacyRoot, false, null);
<del> roots.set(containerTag, root);
<del> }
<del> updateContainer(element, root, null, callback);
<del>
<del> return getPublicRootInstance(root);
<del> },
<del>
<del> unmountComponentAtNode(containerTag: number) {
<del> const root = roots.get(containerTag);
<del> if (root) {
<del> // TODO: Is it safe to reset this now or should I wait since this unmount could be deferred?
<del> updateContainer(null, root, null, () => {
<del> roots.delete(containerTag);
<del> });
<del> }
<del> },
<del>
<del> unmountComponentAtNodeAndRemoveContainer(containerTag: number) {
<del> ReactNativeRenderer.unmountComponentAtNode(containerTag);
<del>
<del> // Call back into native to remove all of the subviews from this container
<del> UIManager.removeRootView(containerTag);
<del> },
<del>
<del> createPortal(
<del> children: ReactNodeList,
<del> containerTag: number,
<del> key: ?string = null,
<del> ) {
<del> return createPortal(children, containerTag, null, key);
<del> },
<del>
<del> unstable_batchedUpdates: batchedUpdates,
<del>
<del> __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
<del> computeComponentStackForErrorReporting,
<del> },
<add> dispatchCommand,
<add> render,
<add> unmountComponentAtNode,
<add> unmountComponentAtNodeAndRemoveContainer,
<add> createPortal,
<add> batchedUpdates as unstable_batchedUpdates,
<add> Internals as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
<ide> };
<ide>
<ide> injectIntoDevTools({
<ide> injectIntoDevTools({
<ide> version: ReactVersion,
<ide> rendererPackageName: 'react-native-renderer',
<ide> });
<del>
<del>export default ReactNativeRenderer;
<ide><path>packages/react-native-renderer/src/ReactNativeTypes.js
<ide> type SecretInternalsType = {
<ide> ...
<ide> };
<ide>
<del>type SecretInternalsFabricType = {...};
<del>
<ide> /**
<ide> * Flat ReactNative renderer bundles are too big for Flow to parse efficiently.
<ide> * Provide minimal Flow typing for the high-level RN API and call it a day.
<ide> export type ReactFabricType = {
<ide> callback: ?Function,
<ide> ): any,
<ide> unmountComponentAtNode(containerTag: number): any,
<del> __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: SecretInternalsFabricType,
<ide> ...
<ide> };
<ide> | 5 |
Javascript | Javascript | change the api to this.resource/this.route | e4af09edd357cdccfddfa684247bc43a6eaae0fe | <ide><path>packages/ember-routing/lib/system.js
<add>require('ember-routing/system/dsl');
<ide> require('ember-routing/system/controller_for');
<ide> require('ember-routing/system/router');
<ide> require('ember-routing/system/route');
<ide><path>packages/ember-routing/lib/system/dsl.js
<add>function DSL(name) {
<add> this.parent = name;
<add> this.matches = [];
<add>}
<add>
<add>DSL.prototype = {
<add> resource: function(name, options, callback) {
<add> if (arguments.length === 2 && typeof options === 'function') {
<add> callback = options;
<add> options = {};
<add> }
<add>
<add> if (arguments.length === 1) {
<add> options = {};
<add> }
<add>
<add> if (typeof options.path !== 'string') {
<add> options.path = "/" + name;
<add> }
<add>
<add> if (callback) {
<add> var dsl = new DSL(name);
<add> callback.call(dsl);
<add> this.push(options.path, name, dsl.generate());
<add> } else {
<add> this.push(options.path, name);
<add> }
<add> },
<add>
<add> push: function(url, name, callback) {
<add> if (url === "" || url === "/") { this.explicitIndex = true; }
<add>
<add> this.matches.push([url, name, callback]);
<add> },
<add>
<add> route: function(name, options) {
<add> Ember.assert("You must use `this.resource` to nest", typeof options !== 'function');
<add>
<add> options = options || {};
<add>
<add> if (typeof options.path !== 'string') {
<add> options.path = "/" + name;
<add> }
<add>
<add> if (this.parent && this.parent !== 'application') {
<add> name = this.parent + "." + name;
<add> }
<add>
<add> this.push(options.path, name);
<add> },
<add>
<add> generate: function() {
<add> var dslMatches = this.matches;
<add>
<add> if (!this.explicitIndex) {
<add> this.route("index", { path: "/" });
<add> }
<add>
<add> return function(match) {
<add> for (var i=0, l=dslMatches.length; i<l; i++) {
<add> var dslMatch = dslMatches[i];
<add> match(dslMatch[0]).to(dslMatch[1], dslMatch[2]);
<add> }
<add> };
<add> }
<add>};
<add>
<add>DSL.map = function(callback) {
<add> var dsl = new DSL();
<add> callback.call(dsl);
<add> return dsl;
<add>};
<add>
<add>Ember.RouterDSL = DSL;
<ide><path>packages/ember-routing/lib/system/router.js
<ide> var get = Ember.get, set = Ember.set, classify = Ember.String.classify;
<ide>
<ide> var DefaultView = Ember.View.extend(Ember._Metamorph);
<ide>
<add>require("ember-routing/system/dsl");
<add>
<ide> function setupLocation(router) {
<ide> var location = get(router, 'location'),
<ide> rootURL = get(router, 'rootURL');
<ide> Ember.Router = Ember.Object.extend({
<ide> },
<ide>
<ide> startRouting: function() {
<del> this.router = this.router || this.constructor.map();
<add> this.router = this.router || this.constructor.map(Ember.K);
<ide>
<ide> var router = this.router,
<ide> location = get(this, 'location'),
<ide> function setupRouter(emberRouter, router, location) {
<ide> };
<ide> }
<ide>
<del>function setupRouterDelegate(router, namespace) {
<del> router.delegate = {
<del> willAddRoute: function(context, handler) {
<del> if (!context) { return handler; }
<del>
<del> if (context === 'application' || context === undefined) {
<del> return handler;
<del> } else if (handler.indexOf('.') === -1) {
<del> context = context.split('.').slice(-1)[0];
<del> return context + '.' + handler;
<del> } else {
<del> return handler;
<del> }
<del> },
<del>
<del> contextEntered: function(target, match) {
<del> match('/').to('index');
<del> }
<del> };
<del>}
<del>
<del>var emptyMatcherCallback = function(match) { };
<del>
<ide> Ember.Router.reopenClass({
<ide> map: function(callback) {
<ide> var router = this.router = new Router();
<del> setupRouterDelegate(router, this.namespace);
<del> router.map(function(match) {
<del> match("/").to("application", callback || emptyMatcherCallback);
<add>
<add> var dsl = Ember.RouterDSL.map(function() {
<add> this.resource('application', { path: "/" }, function() {
<add> callback.call(this);
<add> });
<ide> });
<add>
<add> router.map(dsl.generate());
<ide> return router;
<ide> }
<ide> });
<ide><path>packages/ember/tests/helpers/link_to_test.js
<ide> module("The {{linkTo}} helper", {
<ide>
<ide> test("The {{linkTo}} helper moves into the named route", function() {
<ide> Router.map(function(match) {
<del> match("/about").to("about");
<add> this.route("about");
<ide> });
<ide>
<ide> bootApplication();
<ide> test("The {{linkTo}} helper supports URL replacement", function() {
<ide> })
<ide> });
<ide>
<del> Router.map(function(match) {
<del> match("/about").to("about");
<add> Router.map(function() {
<add> this.route("about");
<ide> });
<ide>
<ide> bootApplication();
<ide> test("The {{linkTo}} helper supports URL replacement", function() {
<ide> test("The {{linkTo}} helper supports a custom activeClass", function() {
<ide> Ember.TEMPLATES.index = Ember.Handlebars.compile("<h3>Home</h3>{{#linkTo about id='about-link'}}About{{/linkTo}}{{#linkTo index id='self-link' activeClass='zomg-active'}}Self{{/linkTo}}");
<ide>
<del> Router.map(function(match) {
<del> match("/about").to("about");
<add> Router.map(function() {
<add> this.route("about");
<ide> });
<ide>
<ide> bootApplication();
<ide> test("The {{linkTo}} helper supports a custom activeClass", function() {
<ide> });
<ide>
<ide> test("The {{linkTo}} helper supports leaving off .index for nested routes", function() {
<del> Router.map(function(match) {
<del> match("/about").to("about", function(match) {
<del> match("/item").to("item");
<add> Router.map(function() {
<add> this.resource("about", function() {
<add> this.route("item");
<ide> });
<ide> });
<ide>
<ide> test("The {{linkTo}} helper supports leaving off .index for nested routes", func
<ide>
<ide> test("The {{linkTo}} helper supports custom, nested, currentWhen", function() {
<ide> Router.map(function(match) {
<del> match("/").to("index", function(match) {
<del> match("/about").to("about");
<add> this.resource("index", { path: "/" }, function() {
<add> this.route("about");
<ide> });
<del> match("/item").to("item");
<add>
<add> this.route("item");
<ide> });
<ide>
<ide> Ember.TEMPLATES.index = Ember.Handlebars.compile("<h3>Home</h3>{{outlet}}");
<ide> test("The {{linkTo}} helper defaults to bubbling", function() {
<ide> Ember.TEMPLATES.about = Ember.Handlebars.compile("<button {{action 'hide'}}>{{#linkTo 'about.contact' id='about-contact'}}About{{/linkTo}}</button>{{outlet}}");
<ide> Ember.TEMPLATES['about/contact'] = Ember.Handlebars.compile("<h1 id='contact'>Contact</h1>");
<ide>
<del> Router.map(function(match) {
<del> match("/about").to("about", function(match) {
<del> match("/contact").to("contact");
<add> Router.map(function() {
<add> this.resource("about", function() {
<add> this.route("contact");
<ide> });
<ide> });
<ide>
<ide> test("The {{linkTo}} helper supports bubbles=false", function() {
<ide> Ember.TEMPLATES.about = Ember.Handlebars.compile("<button {{action 'hide'}}>{{#linkTo 'about.contact' id='about-contact' bubbles=false}}About{{/linkTo}}</button>{{outlet}}");
<ide> Ember.TEMPLATES['about/contact'] = Ember.Handlebars.compile("<h1 id='contact'>Contact</h1>");
<ide>
<del> Router.map(function(match) {
<del> match("/about").to("about", function(match) {
<del> match("/contact").to("contact");
<add> Router.map(function() {
<add> this.resource("about", function() {
<add> this.route("contact");
<ide> });
<ide> });
<ide>
<ide> test("The {{linkTo}} helper supports bubbles=false", function() {
<ide>
<ide> test("The {{linkTo}} helper moves into the named route with context", function() {
<ide> Router.map(function(match) {
<del> match("/about").to("about");
<del> match("/item/:id").to("item");
<add> this.route("about");
<add> this.resource("item", { path: "/item/:id" });
<ide> });
<ide>
<ide> Ember.TEMPLATES.about = Ember.Handlebars.compile("<h3>List</h3><ul>{{#each controller}}<li>{{#linkTo item this}}{{name}}{{/linkTo}}<li>{{/each}}</ul>{{#linkTo index id='home-link'}}Home{{/linkTo}}");
<ide><path>packages/ember/tests/routing/basic_test.js
<ide> module("Basic Routing", {
<ide>
<ide> test("The Homepage", function() {
<ide> Router.map(function(match) {
<del> match("/").to("home");
<add> this.route("home", { path: "/" });
<ide> });
<ide>
<ide> App.HomeRoute = Ember.Route.extend({
<ide> test("The Homepage", function() {
<ide>
<ide> test("The Homepage register as activeView", function() {
<ide> Router.map(function(match) {
<del> match("/").to("home");
<del> match("/homepage").to("homepage");
<add> this.route("home", { path: "/" });
<add> this.route("homepage");
<ide> });
<ide>
<ide> App.HomeRoute = Ember.Route.extend({
<ide> test("The Homepage register as activeView", function() {
<ide>
<ide> test("The Homepage with explicit template name in renderTemplate", function() {
<ide> Router.map(function(match) {
<del> match("/").to("home");
<add> this.route("home", { path: "/" });
<ide> });
<ide>
<ide> App.HomeRoute = Ember.Route.extend({
<ide> test("The Homepage with explicit template name in renderTemplate", function() {
<ide>
<ide> test("The Homepage with explicit template name in renderTemplate", function() {
<ide> Router.map(function(match) {
<del> match("/").to("home");
<add> this.route("home", { path: "/" });
<ide> });
<ide>
<ide> App.HomeController = Ember.Route.extend({
<ide> test('render does not replace templateName if user provided', function() {
<ide>
<ide> test("The Homepage with a `setupController` hook", function() {
<ide> Router.map(function(match) {
<del> match("/").to("home");
<add> this.route("home", { path: "/" });
<ide> });
<ide>
<ide> App.HomeRoute = Ember.Route.extend({
<ide> test("The Homepage with a `setupController` hook", function() {
<ide>
<ide> test("The Homepage with a `setupController` hook modifying other controllers", function() {
<ide> Router.map(function(match) {
<del> match("/").to("home");
<add> this.route("home", { path: "/" });
<ide> });
<ide>
<ide> App.HomeRoute = Ember.Route.extend({
<ide> test("The Homepage with a `setupController` hook modifying other controllers", f
<ide>
<ide> test("The Homepage getting its controller context via model", function() {
<ide> Router.map(function(match) {
<del> match("/").to("home");
<add> this.route("home", { path: "/" });
<ide> });
<ide>
<ide> App.HomeRoute = Ember.Route.extend({
<ide> test("The Homepage getting its controller context via model", function() {
<ide>
<ide> test("The Specials Page getting its controller context by deserializing the params hash", function() {
<ide> Router.map(function(match) {
<del> match("/").to("home");
<del> match("/specials/:menu_item_id").to("special");
<add> this.route("home", { path: "/" });
<add> this.resource("special", { path: "/specials/:menu_item_id" });
<ide> });
<ide>
<ide> App.SpecialRoute = Ember.Route.extend({
<ide> test("The Specials Page getting its controller context by deserializing the para
<ide>
<ide> test("The Specials Page defaults to looking models up via `find`", function() {
<ide> Router.map(function(match) {
<del> match("/").to("home");
<del> match("/specials/:menu_item_id").to("special");
<add> this.route("home", { path: "/" });
<add> this.resource("special", { path: "/specials/:menu_item_id" });
<ide> });
<ide>
<ide> App.MenuItem = Ember.Object.extend();
<ide> test("The Special Page returning a promise puts the app into a loading state unt
<ide> stop();
<ide>
<ide> Router.map(function(match) {
<del> match("/").to("home");
<del> match("/specials/:menu_item_id").to("special");
<add> this.route("home", { path: "/" });
<add> this.resource("special", { path: "/specials/:menu_item_id" });
<ide> });
<ide>
<ide> var menuItem;
<ide> test("The Special page returning an error puts the app into the failure state",
<ide> stop();
<ide>
<ide> Router.map(function(match) {
<del> match("/").to("home");
<del> match("/specials/:menu_item_id").to("special");
<add> this.route("home", { path: "/" });
<add> this.resource("special", { path: "/specials/:menu_item_id" });
<ide> });
<ide>
<ide> var menuItem;
<ide> test("The Special page returning an error puts the app into a default failure st
<ide> stop();
<ide>
<ide> Router.map(function(match) {
<del> match("/").to("home");
<del> match("/specials/:menu_item_id").to("special");
<add> this.route("home", { path: "/" });
<add> this.resource("special", { path: "/specials/:menu_item_id" });
<ide> });
<ide>
<ide> var lastFailure;
<ide> test("The Special page returning an error puts the app into a default failure st
<ide>
<ide> test("Moving from one page to another triggers the correct callbacks", function() {
<ide> Router.map(function(match) {
<del> match("/").to("home");
<del> match("/specials/:menu_item_id").to("special");
<add> this.route("home", { path: "/" });
<add> this.resource("special", { path: "/specials/:menu_item_id" });
<ide> });
<ide>
<ide> var menuItem;
<ide> test("Moving from one page to another triggers the correct callbacks", function(
<ide>
<ide> test("Nested callbacks are not exited when moving to siblings", function() {
<ide> Router.map(function(match) {
<del> match("/").to("root", function(match) {
<del> match("/specials/:menu_item_id").to("special");
<add> this.resource("root", { path: "/" }, function(match) {
<add> this.resource("special", { path: "/specials/:menu_item_id" });
<ide> });
<ide> });
<ide>
<ide> test("Nested callbacks are not exited when moving to siblings", function() {
<ide>
<ide> });
<ide>
<del> App.RootSpecialRoute = Ember.Route.extend({
<add> App.SpecialRoute = Ember.Route.extend({
<ide> setupController: function(controller, model) {
<ide> set(controller, 'content', model);
<ide> }
<ide> test("Nested callbacks are not exited when moving to siblings", function() {
<ide> "<h3>Home</h3>"
<ide> );
<ide>
<del> Ember.TEMPLATES['root/special'] = Ember.Handlebars.compile(
<add> Ember.TEMPLATES.special = Ember.Handlebars.compile(
<ide> "<p>{{content.id}}</p>"
<ide> );
<ide>
<ide> test("Nested callbacks are not exited when moving to siblings", function() {
<ide> router = container.lookup('router:main');
<ide>
<ide> Ember.run(function() {
<del> router.transitionTo('root.special', App.MenuItem.create({ id: 1 }));
<add> router.transitionTo('special', App.MenuItem.create({ id: 1 }));
<ide> });
<ide> equal(rootSetup, 1, "The root setup was not triggered again");
<ide> equal(rootRender, 1, "The root render was not triggered again");
<ide> test("Nested callbacks are not exited when moving to siblings", function() {
<ide>
<ide> asyncTest("Events are triggered on the controller if a matching action name is implemented", function() {
<ide> Router.map(function(match) {
<del> match("/").to("home");
<add> this.route("home", { path: "/" });
<ide> });
<ide>
<ide> var model = { name: "Tom Dale" };
<ide> asyncTest("Events are triggered on the controller if a matching action name is i
<ide>
<ide> asyncTest("Events are triggered on the current state", function() {
<ide> Router.map(function(match) {
<del> match("/").to("home");
<add> this.route("home", { path: "/" });
<ide> });
<ide>
<ide> var model = { name: "Tom Dale" };
<ide> asyncTest("Events are triggered on the current state", function() {
<ide>
<ide> asyncTest("Events are triggered on the current state when routes are nested", function() {
<ide> Router.map(function(match) {
<del> match("/").to("root", function(match) {
<add> this.resource("root", { path: "/" }, function() {
<add> this.route("index", { path: "/" });
<ide> });
<ide> });
<ide>
<ide> asyncTest("Events are triggered on the current state when routes are nested", fu
<ide>
<ide> test("transitioning multiple times in a single run loop only sets the URL once", function() {
<ide> Router.map(function(match) {
<del> match("/").to("root");
<del> match("/foo").to("foo");
<del> match("/bar").to("bar");
<add> this.route("root", { path: "/" });
<add> this.route("foo");
<add> this.route("bar");
<ide> });
<ide>
<ide> bootApplication();
<ide> test("using replaceWith calls location.replaceURL if available", function() {
<ide> });
<ide>
<ide> Router.map(function(match) {
<del> match("/").to("root");
<del> match("/foo").to("foo");
<add> this.route("root", { path: "/" });
<add> this.route("foo");
<ide> });
<ide>
<ide> bootApplication();
<ide> test("using replaceWith calls setURL if location.replaceURL is not defined", fun
<ide> });
<ide>
<ide> Router.map(function(match) {
<del> match("/").to("root");
<del> match("/foo").to("foo");
<add> this.route("root", { path: "/" });
<add> this.route("foo");
<ide> });
<ide>
<ide> bootApplication();
<ide> test("It is possible to get the model from a parent route", function() {
<ide> expect(3);
<ide>
<ide> Router.map(function(match) {
<del> match("/").to("index");
<del> match("/posts/:post_id").to("post", function(match) {
<del> match("/comments").to("comments");
<add> this.resource("post", { path: "/posts/:post_id" }, function() {
<add> this.resource("comments");
<ide> });
<ide> });
<ide>
<ide> test("It is possible to get the model from a parent route", function() {
<ide> }
<ide> });
<ide>
<del> App.PostCommentsRoute = Ember.Route.extend({
<add> App.CommentsRoute = Ember.Route.extend({
<ide> model: function() {
<ide> equal(this.modelFor('post'), currentPost);
<ide> }
<ide> test("It is possible to get the model from a parent route", function() {
<ide>
<ide> test("A redirection hook is provided", function() {
<ide> Router.map(function(match) {
<del> match("/").to("choose");
<del> match("/home").to("home");
<add> this.route("choose", { path: "/" });
<add> this.route("home");
<ide> });
<ide>
<ide> var chooseFollowed = 0, destination;
<ide> test("Generated names can be customized when providing routes with dot notation"
<ide>
<ide> Ember.TEMPLATES.index = compile("<div>Index</div>");
<ide> Ember.TEMPLATES.application = compile("<h1>Home</h1><div class='main'>{{outlet}}</div>");
<del> Ember.TEMPLATES.top = compile("<div class='middle'>{{outlet}}</div>");
<del> Ember.TEMPLATES['foo/bar'] = compile("<div class='bottom'>{{outlet}}</div>");
<del> Ember.TEMPLATES['baz/bang'] = compile("<p>{{name}}Bottom!</p>");
<add> Ember.TEMPLATES.foo = compile("<div class='middle'>{{outlet}}</div>");
<add> Ember.TEMPLATES.bar = compile("<div class='bottom'>{{outlet}}</div>");
<add> Ember.TEMPLATES['bar/baz'] = compile("<p>{{name}}Bottom!</p>");
<ide>
<ide> Router.map(function(match) {
<del> match("/top").to("top", function(match) {
<del> match("/middle").to("foo.bar", function(match) {
<del> match("/bottom").to("baz.bang");
<add> this.resource("foo", { path: "/top" }, function() {
<add> this.resource("bar", { path: "/middle" }, function() {
<add> this.route("baz", { path: "/bottom" });
<ide> });
<ide> });
<ide> });
<ide>
<del> App.FooBarRoute = Ember.Route.extend({
<add> App.FooRoute = Ember.Route.extend({
<ide> renderTemplate: function() {
<ide> ok(true, "FooBarRoute was called");
<ide> return this._super.apply(this, arguments);
<ide> }
<ide> });
<ide>
<del> App.BazBangRoute = Ember.Route.extend({
<add> App.BarBazRoute = Ember.Route.extend({
<ide> renderTemplate: function() {
<del> ok(true, "BazBangRoute was called");
<add> ok(true, "BarBazRoute was called");
<ide> return this._super.apply(this, arguments);
<ide> }
<ide> });
<ide>
<del> App.FooBarController = Ember.Controller.extend({
<del> name: "FooBar"
<add> App.BarController = Ember.Controller.extend({
<add> name: "Bar"
<ide> });
<ide>
<del> App.BazBangController = Ember.Controller.extend({
<del> name: "BazBang"
<add> App.BarBazController = Ember.Controller.extend({
<add> name: "BarBaz"
<ide> });
<ide>
<ide> bootApplication();
<ide> test("Generated names can be customized when providing routes with dot notation"
<ide> router.handleURL("/top/middle/bottom");
<ide> });
<ide>
<del> equal(Ember.$('.main .middle .bottom p', '#qunit-fixture').text(), "BazBangBottom!", "The templates were rendered into their appropriate parents");
<add> equal(Ember.$('.main .middle .bottom p', '#qunit-fixture').text(), "BarBazBottom!", "The templates were rendered into their appropriate parents");
<ide> });
<ide>
<ide> test("Child routes render into their parent route's template by default", function() {
<ide> Ember.TEMPLATES.index = compile("<div>Index</div>");
<ide> Ember.TEMPLATES.application = compile("<h1>Home</h1><div class='main'>{{outlet}}</div>");
<ide> Ember.TEMPLATES.top = compile("<div class='middle'>{{outlet}}</div>");
<del> Ember.TEMPLATES['top/middle'] = compile("<div class='bottom'>{{outlet}}</div>");
<add> Ember.TEMPLATES.middle = compile("<div class='bottom'>{{outlet}}</div>");
<ide> Ember.TEMPLATES['middle/bottom'] = compile("<p>Bottom!</p>");
<ide>
<ide> Router.map(function(match) {
<del> match("/top").to("top", function(match) {
<del> match("/middle").to("middle", function(match) {
<del> match("/bottom").to("bottom");
<add> this.resource("top", function() {
<add> this.resource("middle", function() {
<add> this.route("bottom");
<ide> });
<ide> });
<ide> });
<ide> test("Parent route context change", function() {
<ide>
<ide> Ember.TEMPLATES.application = compile("{{outlet}}");
<ide> Ember.TEMPLATES.posts = compile("{{outlet}}");
<del> Ember.TEMPLATES['posts/post'] = compile("{{outlet}}");
<add> Ember.TEMPLATES.post = compile("{{outlet}}");
<ide> Ember.TEMPLATES['post/index'] = compile("showing");
<ide> Ember.TEMPLATES['post/edit'] = compile("editing");
<ide>
<del> Router.map(function(match) {
<del> match("/posts").to("posts", function(match) {
<del> match("/:postId").to('post', function(match) {
<del> match("/edit").to('edit');
<add> Router.map(function() {
<add> this.resource("posts", function() {
<add> this.resource("post", { path: "/:postId" }, function() {
<add> this.route("edit");
<ide> });
<ide> });
<ide> });
<ide> test("Parent route context change", function() {
<ide> }
<ide> });
<ide>
<del> App.PostsPostRoute = Ember.Route.extend({
<add> App.PostRoute = Ember.Route.extend({
<ide> model: function(params) {
<ide> return {id: params.postId};
<ide> }, | 5 |
Javascript | Javascript | add missin create permission for faunadb example | 5e23e3545655307576e7d2f827ba2b402889d69d | <ide><path>examples/with-graphql-faunadb/scripts/setup.js
<ide> readline.question(`Please provide the FaunaDB admin key\n`, adminKey => {
<ide> privileges: [
<ide> {
<ide> resource: q.Collection('GuestbookEntry'),
<del> actions: { read: true, write: true },
<add> actions: { read: true, write: true, create: true },
<ide> },
<ide> {
<ide> resource: q.Index('entries'), | 1 |
Javascript | Javascript | remove unreachable code | df8af88e366114adc676e9d05f863e0446d018a3 | <ide><path>lib/buffer.js
<ide> function _copyActual(source, target, targetStart, sourceStart, sourceEnd) {
<ide> sourceEnd = sourceStart + target.length - targetStart;
<ide>
<ide> let nb = sourceEnd - sourceStart;
<del> const targetLen = target.length - targetStart;
<ide> const sourceLen = source.length - sourceStart;
<del> if (nb > targetLen)
<del> nb = targetLen;
<ide> if (nb > sourceLen)
<ide> nb = sourceLen;
<ide> | 1 |
PHP | PHP | refactor the inflector class | afc80dd4d1710d1c4481fad87c6e9c1ddf7adb8e | <ide><path>system/inflector.php
<ide> class Inflector {
<ide> */
<ide> public static function plural($value)
<ide> {
<del> if (array_key_exists($value, static::$plural_cache)) return static::$plural_cache[$value];
<add> if (array_key_exists($value, static::$plural_cache))
<add> {
<add> return static::$plural_cache[$value];
<add> }
<ide>
<del> if (in_array(strtolower($value), static::$uncountable)) return static::$plural_cache[$value] = $value;
<add> if (in_array(strtolower($value), static::$uncountable))
<add> {
<add> return static::$plural_cache[$value] = $value;
<add> }
<ide>
<ide> foreach (static::$irregular as $pattern => $irregular)
<ide> {
<ide> public static function plural($value)
<ide> */
<ide> public static function singular($value)
<ide> {
<del> if (array_key_exists($value, static::$singular_cache)) return static::$singular_cache[$value];
<add> if (array_key_exists($value, static::$singular_cache))
<add> {
<add> return static::$singular_cache[$value];
<add> }
<ide>
<del> if (in_array(strtolower($value), static::$uncountable)) return static::$singular_cache[$value] = $value;
<add> if (in_array(strtolower($value), static::$uncountable))
<add> {
<add> return static::$singular_cache[$value] = $value;
<add> }
<ide>
<ide> foreach (static::$irregular as $irregular => $pattern)
<ide> { | 1 |
Ruby | Ruby | document the rest of lib | 92536c08d53c5d54f6c526bfdc5d854dd00a7a88 | <ide><path>lib/active_storage/attached.rb
<ide> require "action_dispatch/http/upload"
<ide> require "active_support/core_ext/module/delegation"
<ide>
<del># Abstract baseclass for the particular `ActiveStorage::Attached::One` and `ActiveStorage::Attached::Many`
<add># Abstract baseclass for the concrete `ActiveStorage::Attached::One` and `ActiveStorage::Attached::Many`
<ide> # classes that both provide proxy access to the blob association for a record.
<ide> class ActiveStorage::Attached
<ide> attr_reader :name, :record
<ide><path>lib/active_storage/attached/macros.rb
<ide> module ActiveStorage::Attached::Macros
<ide> # There is no column defined on the model side, Active Storage takes
<ide> # care of the mapping between your records and the attachment.
<ide> #
<add> # Under the covers, this relationship is implemented as a `has_one` association to a
<add> # `ActiveStorage::Attachment` record and a `has_one-through` association to a
<add> # `ActiveStorage::Blob` record. These associations are available as `avatar_attachment`
<add> # and `avatar_blob`. But you shouldn't need to work with these associations directly in
<add> # most circumstances.
<add> #
<add> # The system has been designed to having you go through the `ActiveStorage::Attached::One`
<add> # proxy that provides the dynamic proxy to the associations and factory methods, like `#attach`.
<add> #
<ide> # If the +:dependent+ option isn't set, the attachment will be purged
<ide> # (i.e. destroyed) whenever the record is destroyed.
<ide> def has_one_attached(name, dependent: :purge_later)
<ide> def has_one_attached(name, dependent: :purge_later)
<ide> #
<ide> # Gallery.where(user: Current.user).with_attached_photos
<ide> #
<add> # Under the covers, this relationship is implemented as a `has_many` association to a
<add> # `ActiveStorage::Attachment` record and a `has_many-through` association to a
<add> # `ActiveStorage::Blob` record. These associations are available as `photos_attachments`
<add> # and `photos_blobs`. But you shouldn't need to work with these associations directly in
<add> # most circumstances.
<add> #
<add> # The system has been designed to having you go through the `ActiveStorage::Attached::Many`
<add> # proxy that provides the dynamic proxy to the associations and factory methods, like `#attach`.
<add> #
<ide> # If the +:dependent+ option isn't set, all the attachments will be purged
<ide> # (i.e. destroyed) whenever the record is destroyed.
<ide> def has_many_attached(name, dependent: :purge_later)
<ide><path>lib/active_storage/attached/many.rb
<del># Representation of multiple attachments to a model.
<add># Decorated proxy object representing of multiple attachments to a model.
<ide> class ActiveStorage::Attached::Many < ActiveStorage::Attached
<ide> delegate_missing_to :attachments
<ide>
<ide> # Returns all the associated attachment records.
<ide> #
<del> # You don't have to call this method to access the attachments' methods as
<del> # they are all available at the model level.
<add> # All methods called on this proxy object that aren't listed here will automatically be delegated to `attachments`.
<ide> def attachments
<ide> record.public_send("#{name}_attachments")
<ide> end
<ide>
<del> # Associates one or several attachments with the current record, saving
<del> # them to the database.
<add> # Associates one or several attachments with the current record, saving them to the database.
<add> # Examples:
<add> #
<add> # document.images.attach(params[:images]) # Array of ActionDispatch::Http::UploadedFile objects
<add> # document.images.attach(params[:signed_blob_id]) # Signed reference to blob from direct upload
<add> # document.images.attach(io: File.open("~/racecar.jpg"), filename: "racecar.jpg", content_type: "image/jpg")
<add> # document.images.attach([ first_blob, second_blob ])
<ide> def attach(*attachables)
<ide> attachables.flatten.collect do |attachable|
<ide> attachments.create!(name: name, blob: create_blob_from(attachable))
<ide> end
<ide> end
<ide>
<del> # Checks the presence of attachments.
<add> # Returns true if any attachments has been made.
<ide> #
<ide> # class Gallery < ActiveRecord::Base
<ide> # has_many_attached :photos
<ide><path>lib/active_storage/attached/one.rb
<ide> def attachment
<ide> record.public_send("#{name}_attachment")
<ide> end
<ide>
<del> # Associates a given attachment with the current record, saving it to the
<del> # database.
<add> # Associates a given attachment with the current record, saving it to the database.
<add> # Examples:
<add> #
<add> # person.avatar.attach(params[:avatar]) # ActionDispatch::Http::UploadedFile object
<add> # person.avatar.attach(params[:signed_blob_id]) # Signed reference to blob from direct upload
<add> # person.avatar.attach(io: File.open("~/face.jpg"), filename: "face.jpg", content_type: "image/jpg")
<add> # person.avatar.attach(avatar_blob) # ActiveStorage::Blob object
<ide> def attach(attachable)
<ide> write_attachment \
<ide> ActiveStorage::Attachment.create!(record: record, name: name, blob: create_blob_from(attachable))
<ide> end
<ide>
<del> # Checks the presence of the attachment.
<add> # Returns true if an attachment has been made.
<ide> #
<ide> # class User < ActiveRecord::Base
<ide> # has_one_attached :avatar
<ide><path>lib/active_storage/service.rb
<ide> def build(configurator:, service: nil, **service_config) #:nodoc:
<ide> end
<ide> end
<ide>
<add> # Upload the `io` to the `key` specified. If a `checksum` is provided, the service will
<add> # ensure a match when the upload has completed or raise an `ActiveStorage::IntegrityError`.
<ide> def upload(key, io, checksum: nil)
<ide> raise NotImplementedError
<ide> end
<ide>
<add> # Return the content of the file at the `key`.
<ide> def download(key)
<ide> raise NotImplementedError
<ide> end
<ide>
<add> # Delete the file at the `key`.
<ide> def delete(key)
<ide> raise NotImplementedError
<ide> end
<ide>
<add> # Return true if a file exists at the `key`.
<ide> def exist?(key)
<ide> raise NotImplementedError
<ide> end
<ide>
<add> # Returns a signed, temporary URL for the file at the `key`. The URL will be valid for the amount
<add> # of seconds specified in `expires_in`. You most also provide the `disposition` (`:inline` or `:attachment`),
<add> # `filename`, and `content_type` that you wish the file to be served with on request.
<ide> def url(key, expires_in:, disposition:, filename:, content_type:)
<ide> raise NotImplementedError
<ide> end
<ide>
<add> # Returns a signed, temporary URL that a direct upload file can be PUT to on the `key`.
<add> # The URL will be valid for the amount of seconds specified in `expires_in`.
<add> # You most also provide the `content_type`, `content_length`, and `checksum` of the file
<add> # that will be uploaded. All these attributes will be validated by the service upon upload.
<ide> def url_for_direct_upload(key, expires_in:, content_type:, content_length:, checksum:)
<ide> raise NotImplementedError
<ide> end
<ide><path>lib/active_storage/service/disk_service.rb
<ide> require "digest/md5"
<ide> require "active_support/core_ext/numeric/bytes"
<ide>
<add># Wraps a local disk path as a Active Storage service. See `ActiveStorage::Service` for the generic API
<add># documentation that applies to all services.
<ide> class ActiveStorage::Service::DiskService < ActiveStorage::Service
<ide> attr_reader :root
<ide>
<ide><path>lib/active_storage/service/gcs_service.rb
<ide> require "google/cloud/storage"
<ide> require "active_support/core_ext/object/to_query"
<ide>
<add># Wraps the Google Cloud Storage as a Active Storage service. See `ActiveStorage::Service` for the generic API
<add># documentation that applies to all services.
<ide> class ActiveStorage::Service::GCSService < ActiveStorage::Service
<ide> attr_reader :client, :bucket
<ide>
<ide><path>lib/active_storage/service/mirror_service.rb
<ide> require "active_support/core_ext/module/delegation"
<ide>
<add># Wraps a set of mirror services and provides a single `ActiveStorage::Service` object that will all
<add># have the files uploaded to them. A `primary` service is designated to answer calls to `download`, `exists?`,
<add># and `url`.
<ide> class ActiveStorage::Service::MirrorService < ActiveStorage::Service
<ide> attr_reader :primary, :mirrors
<ide>
<ide> def initialize(primary:, mirrors:)
<ide> @primary, @mirrors = primary, mirrors
<ide> end
<ide>
<add> # Upload the `io` to the `key` specified to all services. If a `checksum` is provided, all services will
<add> # ensure a match when the upload has completed or raise an `ActiveStorage::IntegrityError`.
<ide> def upload(key, io, checksum: nil)
<ide> each_service.collect do |service|
<ide> service.upload key, io.tap(&:rewind), checksum: checksum
<ide> end
<ide> end
<ide>
<add> # Delete the file at the `key` on all services.
<ide> def delete(key)
<ide> perform_across_services :delete, key
<ide> end
<ide><path>lib/active_storage/service/s3_service.rb
<ide> require "aws-sdk"
<ide> require "active_support/core_ext/numeric/bytes"
<ide>
<add># Wraps the Amazon Simple Storage Service (S3) as a Active Storage service.
<add># See `ActiveStorage::Service` for the generic API documentation that applies to all services.
<ide> class ActiveStorage::Service::S3Service < ActiveStorage::Service
<ide> attr_reader :client, :bucket, :upload_options
<ide> | 9 |
Ruby | Ruby | document the remaining parts of the channel setup | 81bbf9ecba35e04de4081494941c2f69c9e8784e | <ide><path>lib/action_cable/channel/callbacks.rb
<ide> module Callbacks
<ide> end
<ide>
<ide> module ClassMethods
<add> # Name methods that should be called when the channel is subscribed to.
<add> # (These methods should be private, so they're not callable by the user).
<ide> def on_subscribe(*methods)
<ide> self.on_subscribe_callbacks += methods
<ide> end
<ide>
<add> # Name methods that should be called when the channel is unsubscribed from.
<add> # (These methods should be private, so they're not callable by the user).
<ide> def on_unsubscribe(*methods)
<ide> self.on_unsubscribe_callbacks += methods
<ide> end
<ide><path>lib/action_cable/channel/periodic_timers.rb
<ide> module PeriodicTimers
<ide> end
<ide>
<ide> module ClassMethods
<add> # Allow you to call a private method <tt>every</tt> so often seconds. This periodic timer can be useful
<add> # for sending a steady flow of updates to a client based off an object that was configured on subscription.
<add> # It's an alternative to using streams if the channel is able to do the work internally.
<ide> def periodically(callback, every:)
<ide> self.periodic_timers += [ [ callback, every: every ] ]
<ide> end
<ide><path>lib/action_cable/channel/streams.rb
<ide> module ActionCable
<ide> module Channel
<add> # Streams allow channels to route broadcastings to the subscriber. A broadcasting is an discussed elsewhere a pub/sub queue where any data
<add> # put into it is automatically sent to the clients that are connected at that time. It's purely an online queue, though. If you're not
<add> # streaming a broadcasting at the very moment it sends out an update, you'll not get that update when connecting later.
<add> #
<add> # Most commonly, the streamed broadcast is sent straight to the subscriber on the client-side. The channel just acts as a connector between
<add> # the two parties (the broadcaster and the channel subscriber). Here's an example of a channel that allows subscribers to get all new
<add> # comments on a given page:
<add> #
<add> # class CommentsChannel < ApplicationCable::Channel
<add> # def follow(data)
<add> # stream_from "comments_for_#{data['recording_id']}"
<add> # end
<add> #
<add> # def unfollow
<add> # stop_all_streams
<add> # end
<add> # end
<add> #
<add> # So the subscribers of this channel will get whatever data is put into the, let's say, `comments_for_45` broadcasting as soon as it's put there.
<add> # That looks like so from that side of things:
<add> #
<add> # ActionCable.server.broadcast "comments_for_45", author: 'DHH', content: 'Rails is just swell'
<add> #
<add> # If you don't just want to parlay the broadcast unfiltered to the subscriber, you can supply a callback that let's you alter what goes out.
<add> # Example below shows how you can use this to provide performance introspection in the process:
<add> #
<add> # class ChatChannel < ApplicationCable::Channel
<add> # def subscribed
<add> # @room = Chat::Room[params[:room_number]]
<add> #
<add> # stream_from @room.channel, -> (message) do
<add> # message = ActiveSupport::JSON.decode(m)
<add> #
<add> # if message['originated_at'].present?
<add> # elapsed_time = (Time.now.to_f - message['originated_at']).round(2)
<add> #
<add> # ActiveSupport::Notifications.instrument :performance, measurement: 'Chat.message_delay', value: elapsed_time, action: :timing
<add> # logger.info "Message took #{elapsed_time}s to arrive"
<add> # end
<add> #
<add> # transmit message
<add> # end
<add> # end
<add> #
<add> # You can stop streaming from all broadcasts by calling #stop_all_streams.
<ide> module Streams
<ide> extend ActiveSupport::Concern
<ide>
<ide> included do
<ide> on_unsubscribe :stop_all_streams
<ide> end
<ide>
<add> # Start streaming from the named <tt>broadcasting</tt> pubsub queue. Optionally, you can pass a <tt>callback</tt> that'll be used
<add> # instead of the default of just transmitting the updates straight to the subscriber.
<ide> def stream_from(broadcasting, callback = nil)
<ide> callback ||= default_stream_callback(broadcasting)
<ide> | 3 |
PHP | PHP | remove inherited logic | 25ce1cc82396eefb829cb97b07eea39c52f06560 | <ide><path>lib/Cake/Console/Command/TestsuiteShell.php
<ide> * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
<ide> */
<ide>
<del>App::uses('Shell', 'Console');
<del>App::uses('CakeTestSuiteDispatcher', 'TestSuite');
<del>App::uses('CakeTestSuiteCommand', 'TestSuite');
<del>App::uses('CakeTestLoader', 'TestSuite');
<add>App::uses('TestShell', 'Console/Command');
<ide>
<ide> /**
<ide> * Provides a CakePHP wrapper around PHPUnit.
<ide> * Adds in CakePHP's fixtures and gives access to plugin, app and core test cases
<ide> *
<ide> * @package Cake.Console.Command
<ide> */
<del>class TestsuiteShell extends Shell {
<del>
<del>/**
<del> * Dispatcher object for the run.
<del> *
<del> * @var CakeTestDispatcher
<del> */
<del> protected $_dispatcher = null;
<add>class TestsuiteShell extends TestShell {
<ide>
<ide> /**
<ide> * get the option parser for the test suite.
<ide> public function getOptionParser() {
<ide> return $parser;
<ide> }
<ide>
<del>/**
<del> * Initialization method installs PHPUnit and loads all plugins
<del> *
<del> * @return void
<del> * @throws Exception
<del> */
<del> public function initialize() {
<del> $this->_dispatcher = new CakeTestSuiteDispatcher();
<del> $sucess = $this->_dispatcher->loadTestFramework();
<del> if (!$sucess) {
<del> throw new Exception(__d('cake_dev', 'Please install PHPUnit framework <info>(http://www.phpunit.de)</info>'));
<del> }
<del> }
<del>
<ide> /**
<ide> * Parse the CLI options into an array CakeTestDispatcher can use.
<ide> *
<ide> protected function _parseArgs() {
<ide> return $params;
<ide> }
<ide>
<del>/**
<del> * Converts the options passed to the shell as options for the PHPUnit cli runner
<del> *
<del> * @return array Array of params for CakeTestDispatcher
<del> */
<del> protected function _runnerOptions() {
<del> $options = array();
<del> $params = $this->params;
<del> unset($params['help']);
<del>
<del> if (!empty($params['no-colors'])) {
<del> unset($params['no-colors'], $params['colors']);
<del> } else {
<del> $params['colors'] = true;
<del> }
<del>
<del> foreach ($params as $param => $value) {
<del> if ($value === false) {
<del> continue;
<del> }
<del> $options[] = '--' . $param;
<del> if (is_string($value)) {
<del> $options[] = $value;
<del> }
<del> }
<del> return $options;
<del> }
<del>
<ide> /**
<ide> * Main entry point to this shell
<ide> *
<ide> public function main() {
<ide>
<ide> $this->_run($args, $this->_runnerOptions());
<ide> }
<del>
<del>/**
<del> * Runs the test case from $runnerArgs
<del> *
<del> * @param array $runnerArgs list of arguments as obtained from _parseArgs()
<del> * @param array $options list of options as constructed by _runnerOptions()
<del> * @return void
<del> */
<del> protected function _run($runnerArgs, $options = array()) {
<del> restore_error_handler();
<del> restore_error_handler();
<del>
<del> $testCli = new CakeTestSuiteCommand('CakeTestLoader', $runnerArgs);
<del> $testCli->run($options);
<del> }
<del>
<del>/**
<del> * Shows a list of available test cases and gives the option to run one of them
<del> *
<del> * @return void
<del> */
<del> public function available() {
<del> $params = $this->_parseArgs();
<del> $testCases = CakeTestLoader::generateTestList($params);
<del> $app = $params['app'];
<del> $plugin = $params['plugin'];
<del>
<del> $title = "Core Test Cases:";
<del> $category = 'core';
<del> if ($app) {
<del> $title = "App Test Cases:";
<del> $category = 'app';
<del> } elseif ($plugin) {
<del> $title = Inflector::humanize($plugin) . " Test Cases:";
<del> $category = $plugin;
<del> }
<del>
<del> if (empty($testCases)) {
<del> $this->out(__d('cake_console', "No test cases available \n\n"));
<del> return $this->out($this->OptionParser->help());
<del> }
<del>
<del> $this->out($title);
<del> $i = 1;
<del> $cases = array();
<del> foreach ($testCases as $testCaseFile => $testCase) {
<del> $case = str_replace('Test.php', '', $testCase);
<del> $this->out("[$i] $case");
<del> $cases[$i] = $case;
<del> $i++;
<del> }
<del>
<del> while ($choice = $this->in(__d('cake_console', 'What test case would you like to run?'), null, 'q')) {
<del> if (is_numeric($choice) && isset($cases[$choice])) {
<del> $this->args[0] = $category;
<del> $this->args[1] = $cases[$choice];
<del> $this->_run($this->_parseArgs(), $this->_runnerOptions());
<del> break;
<del> }
<del>
<del> if (is_string($choice) && in_array($choice, $cases)) {
<del> $this->args[0] = $category;
<del> $this->args[1] = $choice;
<del> $this->_run($this->_parseArgs(), $this->_runnerOptions());
<del> break;
<del> }
<del>
<del> if ($choice == 'q') {
<del> break;
<del> }
<del> }
<del> }
<ide> } | 1 |
Javascript | Javascript | fix config quickstart and download [ci skip] | e17ea88e542b2a4019e2aa552c2186bad03f52d7 | <ide><path>website/src/components/quickstart.js
<ide> const Quickstart = ({
<ide> )}
<ide> {download && (
<ide> <a
<del> href={`data:application/octet-stream,${getRawContent(contentRef)}`}
<add> href={`data:application/octet-stream,${encodeURIComponent(
<add> getRawContent(contentRef)
<add> )}`}
<ide> title="Download file"
<ide> download={download}
<ide> className={classes.iconButton}
<ide><path>website/src/widgets/quickstart-training.js
<ide> export default function QuickstartTraining({ id, title, download = 'base_config.
<ide> id="quickstart-widget"
<ide> Container="div"
<ide> download={download}
<del> rawContent={content}
<add> rawContent={rawContent}
<ide> data={DATA}
<ide> title={title}
<ide> id={id} | 2 |
Javascript | Javascript | change callback function to arrow function | 604578f47ea360980110e2cd7d4a636f9942b1f0 | <ide><path>test/parallel/test-http-default-encoding.js
<ide> const http = require('http');
<ide> const expected = 'This is a unicode text: سلام';
<ide> let result = '';
<ide>
<del>const server = http.Server(function(req, res) {
<add>const server = http.Server((req, res) => {
<ide> req.setEncoding('utf8');
<del> req.on('data', function(chunk) {
<add> req.on('data', (chunk) => {
<ide> result += chunk;
<del> }).on('end', function() {
<add> }).on('end', () => {
<ide> server.close();
<ide> res.writeHead(200);
<ide> res.end('hello world\n');
<ide> server.listen(0, function() {
<ide> port: this.address().port,
<ide> path: '/',
<ide> method: 'POST'
<del> }, function(res) {
<add> }, (res) => {
<ide> console.log(res.statusCode);
<ide> res.resume();
<del> }).on('error', function(e) {
<add> }).on('error', (e) => {
<ide> console.log(e.message);
<ide> process.exit(1);
<ide> }).end(expected);
<ide> });
<ide>
<del>process.on('exit', function() {
<add>process.on('exit', () => {
<ide> assert.strictEqual(expected, result);
<ide> }); | 1 |
Javascript | Javascript | avoid invoking noop | b6389eedda4f24cf23d994fc22f030067c4ab13d | <ide><path>src/auto/injector.js
<ide> function createInjector(modulesToLoad, strictDi) {
<ide> }));
<ide>
<ide>
<del> forEach(loadModules(modulesToLoad), function(fn) { instanceInjector.invoke(fn || noop); });
<add> forEach(loadModules(modulesToLoad), function(fn) { if (fn) instanceInjector.invoke(fn); });
<ide>
<ide> return instanceInjector;
<ide> | 1 |
Python | Python | fix deprecation warning due to using query.value | 921ccedf7f90f15e8d18c27a77b29d232be3c8cb | <ide><path>airflow/models/dag.py
<ide> def concurrency_reached(self):
<ide> @provide_session
<ide> def get_is_active(self, session=NEW_SESSION) -> Optional[None]:
<ide> """Returns a boolean indicating whether this DAG is active"""
<del> qry = session.query(DagModel).filter(DagModel.dag_id == self.dag_id)
<del> return qry.value(DagModel.is_active)
<add> return session.query(DagModel.is_active).filter(DagModel.dag_id == self.dag_id).scalar()
<ide>
<ide> @provide_session
<ide> def get_is_paused(self, session=NEW_SESSION) -> Optional[None]:
<ide> """Returns a boolean indicating whether this DAG is paused"""
<del> qry = session.query(DagModel).filter(DagModel.dag_id == self.dag_id)
<del> return qry.value(DagModel.is_paused)
<add> return session.query(DagModel.is_paused).filter(DagModel.dag_id == self.dag_id).scalar()
<ide>
<ide> @property
<ide> def is_paused(self): | 1 |
Text | Text | remove badges from title | 3efb4a5c59c80e5d4c6775553585e0ca15fca787 | <ide><path>README.md
<del># [Redux](http://gaearon.github.io/redux) [](https://travis-ci.org/gaearon/redux) [](https://www.npmjs.com/package/redux) [](http://www.reactiflux.com)
<add># [Redux](http://gaearon.github.io/redux)
<add>[](https://travis-ci.org/gaearon/redux) [](https://www.npmjs.com/package/redux) [](http://www.reactiflux.com)
<ide>
<ide> Redux is a predictable state container for JavaScript apps.
<ide> | 1 |
Text | Text | add small doc | 26feb09fac7cfcafef36cc71df1176301c70eb53 | <ide><path>docs/sources/articles/networking.md
<ide> usual containers. But unless you have very specific networking needs
<ide> that drive you to such a solution, it is probably far preferable to use
<ide> `--icc=false` to lock down inter-container communication, as we explored
<ide> earlier.
<add>
<add>## Editing networking config files
<add>
<add>Starting with Docker v.1.2.0, you can now edit `/etc/hosts`, `/etc/hostname`
<add>and `/etc/resolve.conf` in a running container. This is useful if you need
<add>to install bind or other services that might override one of those files.
<add>
<add>Note, however, that changes to these files will not be saved by
<add>`docker commit`, nor will they be saved during `docker run`.
<add>That means they won't be saved in the image, nor will they persist when a
<add>container is restarted; they will only "stick" in a running container. | 1 |
Javascript | Javascript | fix alphatest and cleanup | 5da506d3c960e81b89d859c404092a7f5313fe1f | <ide><path>examples/js/nodes/core/NodeBuilder.js
<ide> function NodeBuilder() {
<ide> this.attributes = {};
<ide>
<ide> this.prefixCode = [
<del> "#ifdef GL_EXT_shader_texture_lod",
<add> "#ifdef TEXTURE_LOD_EXT",
<ide>
<ide> " #define texCube(a, b) textureCube(a, b)",
<ide> " #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)",
<ide> function NodeBuilder() {
<ide>
<ide> "#endif",
<ide>
<del> "#include <packing>"
<add> "#include <packing>",
<add> "#include <common>"
<ide>
<ide> ].join( "\n" );
<ide>
<ide> NodeBuilder.prototype = {
<ide>
<ide> switch ( typeToType ) {
<ide>
<del> case 'f <- v2': return code + '.x';
<del> case 'f <- v3': return code + '.x';
<del> case 'f <- v4': return code + '.x';
<del> case 'f <- i': return 'float( ' + code + ' )';
<add> case 'f <- v2' : return code + '.x';
<add> case 'f <- v3' : return code + '.x';
<add> case 'f <- v4' : return code + '.x';
<add> case 'f <- i' : return 'float( ' + code + ' )';
<ide>
<del> case 'v2 <- f': return 'vec2( ' + code + ' )';
<add> case 'v2 <- f' : return 'vec2( ' + code + ' )';
<ide> case 'v2 <- v3': return code + '.xy';
<ide> case 'v2 <- v4': return code + '.xy';
<del> case 'v2 <- i': return 'vec2( float( ' + code + ' ) )';
<add> case 'v2 <- i' : return 'vec2( float( ' + code + ' ) )';
<ide>
<del> case 'v3 <- f': return 'vec3( ' + code + ' )';
<add> case 'v3 <- f' : return 'vec3( ' + code + ' )';
<ide> case 'v3 <- v2': return 'vec3( ' + code + ', 0.0 )';
<ide> case 'v3 <- v4': return code + '.xyz';
<del> case 'v3 <- i': return 'vec2( float( ' + code + ' ) )';
<add> case 'v3 <- i' : return 'vec2( float( ' + code + ' ) )';
<ide>
<del> case 'v4 <- f': return 'vec4( ' + code + ' )';
<add> case 'v4 <- f' : return 'vec4( ' + code + ' )';
<ide> case 'v4 <- v2': return 'vec4( ' + code + ', 0.0, 1.0 )';
<ide> case 'v4 <- v3': return 'vec4( ' + code + ', 1.0 )';
<del> case 'v4 <- i': return 'vec4( float( ' + code + ' ) )';
<add> case 'v4 <- i' : return 'vec4( float( ' + code + ' ) )';
<ide>
<del> case 'i <- f': return 'int( ' + code + ' )';
<del> case 'i <- v2': return 'int( ' + code + '.x )';
<del> case 'i <- v3': return 'int( ' + code + '.x )';
<del> case 'i <- v4': return 'int( ' + code + '.x )';
<add> case 'i <- f' : return 'int( ' + code + ' )';
<add> case 'i <- v2' : return 'int( ' + code + '.x )';
<add> case 'i <- v3' : return 'int( ' + code + '.x )';
<add> case 'i <- v4' : return 'int( ' + code + '.x )';
<ide>
<ide> }
<ide>
<ide><path>examples/js/nodes/materials/nodes/MeshStandardNode.js
<ide> MeshStandardNode.prototype.build = function ( builder ) {
<ide> this.normal = new NormalMapNode( builder.resolve( props.normalMap ) );
<ide> this.normal.scale = builder.findNode( props.normalScale, inputs.normalScale );
<ide>
<add> } else {
<add>
<add> this.normal = undefined;
<add>
<ide> }
<ide>
<ide> // slots
<ide><path>examples/js/nodes/materials/nodes/PhongNode.js
<ide> PhongNode.prototype.build = function ( builder ) {
<ide> var code;
<ide>
<ide> builder.define( 'PHONG' );
<del> builder.define( 'ALPHATEST', '0.0' );
<ide>
<ide> builder.requires.lights = true;
<ide>
<ide> PhongNode.prototype.build = function ( builder ) {
<ide>
<ide> "#endif",
<ide>
<del> "#include <common>",
<ide> //"#include <encodings_pars_fragment>", // encoding functions
<ide> "#include <fog_pars_vertex>",
<ide> "#include <morphtarget_pars_vertex>",
<ide> PhongNode.prototype.build = function ( builder ) {
<ide> builder.requires.transparent = alpha != undefined;
<ide>
<ide> builder.addParsCode( [
<del> "#include <common>",
<ide> "#include <fog_pars_fragment>",
<ide> "#include <bsdfs>",
<ide> "#include <lights_pars_begin>",
<ide> PhongNode.prototype.build = function ( builder ) {
<ide>
<ide> output.push(
<ide> alpha.code,
<del> 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;'
<add> '#ifdef ALPHATEST',
<add>
<add> 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;',
<add>
<add> '#endif'
<ide> );
<ide>
<ide> }
<ide><path>examples/js/nodes/materials/nodes/SpriteNode.js
<ide> SpriteNode.prototype.build = function ( builder ) {
<ide> var output, code;
<ide>
<ide> builder.define( 'SPRITE' );
<del> builder.define( 'ALPHATEST', '0.0' );
<ide>
<ide> builder.requires.lights = false;
<ide> builder.requires.transparent = this.alpha !== undefined;
<ide> SpriteNode.prototype.build = function ( builder ) {
<ide> ] ) );
<ide>
<ide> builder.addParsCode( [
<del> "#include <common>",
<ide> "#include <fog_pars_vertex>",
<ide> "#include <logdepthbuf_pars_vertex>",
<ide> "#include <clipping_planes_pars_vertex>"
<ide> SpriteNode.prototype.build = function ( builder ) {
<ide> } else {
<ide>
<ide> builder.addParsCode( [
<del> "#include <common>",
<ide> "#include <fog_pars_fragment>",
<ide> "#include <logdepthbuf_pars_fragment>",
<ide> "#include <clipping_planes_pars_fragment>"
<ide> SpriteNode.prototype.build = function ( builder ) {
<ide>
<ide> output = [
<ide> alpha.code,
<del> 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;',
<add> '#ifdef ALPHATEST',
<add>
<add> 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;',
<add>
<add> '#endif',
<ide> color.code,
<ide> "gl_FragColor = vec4( " + color.result + ", " + alpha.result + " );"
<ide> ];
<ide><path>examples/js/nodes/materials/nodes/StandardNode.js
<ide> StandardNode.prototype.build = function ( builder ) {
<ide> var code;
<ide>
<ide> builder.define( this.clearCoat || this.clearCoatRoughness ? 'PHYSICAL' : 'STANDARD' );
<del> builder.define( 'ALPHATEST', '0.0' );
<ide>
<ide> builder.requires.lights = true;
<ide>
<ide> StandardNode.prototype.build = function ( builder ) {
<ide>
<ide> "#endif",
<ide>
<del> "#include <common>",
<ide> //"#include <encodings_pars_fragment>", // encoding functions
<ide> "#include <fog_pars_vertex>",
<ide> "#include <morphtarget_pars_vertex>",
<ide> StandardNode.prototype.build = function ( builder ) {
<ide>
<ide> "#endif",
<ide>
<del> "#include <common>",
<ide> "#include <dithering_pars_fragment>",
<ide> "#include <fog_pars_fragment>",
<ide> "#include <bsdfs>",
<ide> StandardNode.prototype.build = function ( builder ) {
<ide>
<ide> output.push(
<ide> alpha.code,
<del> 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;'
<add> '#ifdef ALPHATEST',
<add>
<add> 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;',
<add>
<add> '#endif'
<ide> );
<ide>
<ide> }
<ide><path>examples/js/nodes/math/CondNode.js
<ide> function CondNode( a, b, ifNode, elseNode, op ) {
<ide> this.ifNode = ifNode;
<ide> this.elseNode = elseNode;
<ide>
<del> this.op = op || CondNode.EQUAL;
<add> this.op = op;
<ide>
<ide> };
<ide>
<ide><path>examples/js/nodes/math/Math1Node.js
<ide> function Math1Node( a, method ) {
<ide>
<ide> this.a = a;
<ide>
<del> this.method = method || Math1Node.SIN;
<add> this.method = method;
<ide>
<ide> };
<ide>
<ide><path>examples/js/nodes/math/Math2Node.js
<ide> function Math2Node( a, b, method ) {
<ide> this.a = a;
<ide> this.b = b;
<ide>
<del> this.method = method || Math2Node.DISTANCE;
<add> this.method = method;
<ide>
<ide> };
<ide>
<ide><path>examples/js/nodes/math/Math3Node.js
<ide> function Math3Node( a, b, c, method ) {
<ide> this.b = b;
<ide> this.c = c;
<ide>
<del> this.method = method || Math3Node.MIX;
<add> this.method = method;
<ide>
<ide> };
<ide>
<ide><path>examples/js/nodes/math/OperatorNode.js
<ide> function OperatorNode( a, b, op ) {
<ide>
<ide> this.a = a;
<ide> this.b = b;
<del> this.op = op || OperatorNode.ADD;
<add> this.op = op;
<ide>
<ide> };
<ide> | 10 |
Go | Go | improve robustness of /stats api test | 4d7707e183e8dcb8e0ab1415e401cb530df17c92 | <ide><path>integration-cli/docker_api_containers_test.go
<ide> func TestVolumesFromHasPriority(t *testing.T) {
<ide>
<ide> func TestGetContainerStats(t *testing.T) {
<ide> defer deleteAllContainers()
<del> name := "statscontainer"
<del>
<del> runCmd := exec.Command(dockerBinary, "run", "-d", "--name", name, "busybox", "top")
<add> var (
<add> name = "statscontainer"
<add> runCmd = exec.Command(dockerBinary, "run", "-d", "--name", name, "busybox", "top")
<add> )
<ide> out, _, err := runCommandWithOutput(runCmd)
<ide> if err != nil {
<ide> t.Fatalf("Error on container creation: %v, output: %q", err, out)
<ide> }
<add> type b struct {
<add> body []byte
<add> err error
<add> }
<add> bc := make(chan b, 1)
<ide> go func() {
<del> time.Sleep(4 * time.Second)
<del> runCommand(exec.Command(dockerBinary, "kill", name))
<del> runCommand(exec.Command(dockerBinary, "rm", name))
<add> body, err := sockRequest("GET", "/containers/"+name+"/stats", nil)
<add> bc <- b{body, err}
<ide> }()
<ide>
<del> body, err := sockRequest("GET", "/containers/"+name+"/stats", nil)
<del> if err != nil {
<del> t.Fatalf("GET containers/stats sockRequest failed: %v", err)
<add> // allow some time to stream the stats from the container
<add> time.Sleep(4 * time.Second)
<add> if _, err := runCommand(exec.Command(dockerBinary, "rm", "-f", name)); err != nil {
<add> t.Fatal(err)
<ide> }
<ide>
<del> dec := json.NewDecoder(bytes.NewBuffer(body))
<del> var s *stats.Stats
<del> if err := dec.Decode(&s); err != nil {
<del> t.Fatal(err)
<add> // collect the results from the stats stream or timeout and fail
<add> // if the stream was not disconnected.
<add> select {
<add> case <-time.After(2 * time.Second):
<add> t.Fatal("stream was not closed after container was removed")
<add> case sr := <-bc:
<add> if sr.err != nil {
<add> t.Fatal(err)
<add> }
<add>
<add> dec := json.NewDecoder(bytes.NewBuffer(sr.body))
<add> var s *stats.Stats
<add> // decode only one object from the stream
<add> if err := dec.Decode(&s); err != nil {
<add> t.Fatal(err)
<add> }
<ide> }
<ide> logDone("container REST API - check GET containers/stats")
<ide> } | 1 |
Text | Text | add @daviwil highlights and focus items | 409a2913ab7b2a3ac746d76a4108722ddffc1115 | <ide><path>docs/focus/2018-03-05.md
<ide> - Implemented anchors, selections, and basic selection movement.
<ide> - Partially implemented selection rendering.
<ide> - For more details, see the [detailed update](https://github.com/atom/xray/blob/master/docs/updates/2018_03_05.md) in the Xray repository.
<add>- Engineering Improvements
<add> - Automated Linux package repository publishing as part of Atom release process
<ide> - Reactor Duty
<del>
<add> - Shipped node-keytar update, primary feature being prebuilt node modules ([atom/node-keytar#67](https://github.com/atom/node-keytar/pull/67))
<add> - Merged community pull requests to atom/atom-select-list, atom/command-palette, and atom/tree-view
<add>
<ide> ## Focus for week ahead
<ide>
<ide> - Atom IDE
<ide> - Console logging completion
<add> - Investigate language server process hanging on deactivation in ide-typescript
<add> - Investigate using the new native LSP support in omnisharp-roslyn in ide-csharp
<ide> - @atom/watcher
<ide> - Diagnose crashes and lockups on Atom launch (@smashwilson)
<ide> - GitHub Package
<ide> - Wire up enough of the key bindings / commands system to move cursors/selections
<ide> - Start on editing
<ide> - For more details, see [the detailed update](https://github.com/atom/xray/blob/master/docs/updates/2018_03_05.md)
<add>- Engineering Improvements
<add> - Finish new Atom release publishing automation
<ide> - Reactor Duty
<add> | 1 |
Java | Java | update copyright header | 3b8b3502a84714bd01594fca10e0afabcd2e48e4 | <ide><path>spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java
<ide> /*
<del> * Copyright 2002-2016 the original author or authors.
<add> * Copyright 2002-2017 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. | 1 |
PHP | PHP | fix missing check | c1958d51005f768122caba6bcb0be9e58d31d28c | <ide><path>src/Console/CommandRunner.php
<ide> public function run(array $argv, ConsoleIo $io = null)
<ide> 'help' => HelpCommand::class,
<ide> ]);
<ide> $commands = $this->app->console($commands);
<add> $this->checkCollection($commands, 'console');
<add>
<ide> if ($this->app instanceof PluginApplicationInterface) {
<ide> $commands = $this->app->pluginConsole($commands);
<ide> }
<del>
<del> if (!($commands instanceof CommandCollection)) {
<del> $type = getTypeName($commands);
<del> throw new RuntimeException(
<del> "The application's `console` method did not return a CommandCollection." .
<del> " Got '{$type}' instead."
<del> );
<del> }
<add> $this->checkCollection($commands, 'pluginConsole');
<ide> $this->dispatchEvent('Console.buildCommands', ['commands' => $commands]);
<ide>
<ide> if (empty($argv)) {
<ide> protected function bootstrap()
<ide> }
<ide> }
<ide>
<add> /**
<add> * Check the created CommandCollection
<add> *
<add> * @param mixed $commands The CommandCollection to check, could be anything though.
<add> * @param string $method The method that was used.
<add> * @return void
<add> * @throws \RuntimeException
<add> * @deprecated 3.6.0 This method should be replaced with return types in 4.x
<add> */
<add> protected function checkCollection($commands, $method)
<add> {
<add> if (!($commands instanceof CommandCollection)) {
<add> $type = getTypeName($commands);
<add> throw new RuntimeException(
<add> "The application's `{$method}` method did not return a CommandCollection." .
<add> " Got '{$type}' instead."
<add> );
<add> }
<add> }
<add>
<ide> /**
<ide> * Get the application's event manager or the global one.
<ide> *
<ide><path>tests/TestCase/Console/CommandCollectionTest.php
<ide> public function testAutoDiscoverCore()
<ide> */
<ide> public function testDiscoverPluginUnknown()
<ide> {
<del> $this->assertSame([], $collection = new CommandCollection());
<add> $collection = new CommandCollection();
<add> $this->assertSame([], $collection->discoverPlugin('Nope'));
<ide> }
<ide>
<ide> /**
<ide><path>tests/TestCase/Console/CommandRunnerTest.php
<ide> public function testRunConsoleHookFailure()
<ide> $runner->run(['cake', '-h']);
<ide> }
<ide>
<add> /**
<add> * Test that the console hook not returning a command collection
<add> * raises an error.
<add> *
<add> * @return void
<add> */
<add> public function testRunPluginConsoleHookFailure()
<add> {
<add> $this->expectException(\RuntimeException::class);
<add> $this->expectExceptionMessage('The application\'s `pluginConsole` method did not return a CommandCollection.');
<add> $app = $this->getMockBuilder(BaseApplication::class)
<add> ->setMethods(['pluginConsole', 'middleware', 'bootstrap'])
<add> ->setConstructorArgs([$this->config])
<add> ->getMock();
<add> $runner = new CommandRunner($app);
<add> $runner->run(['cake', '-h']);
<add> }
<add>
<ide> /**
<ide> * Test that running with empty argv fails
<ide> * | 3 |
Text | Text | fix broken link | f4d614aa31bbb616e225c418e4bbe57ad2f4ae5b | <ide><path>docs/HandlingTouches.md
<ide> In some cases, you may want to detect when a user presses and holds a view for a
<ide>
<ide> ## Scrolling lists and swiping views
<ide>
<del>A common pattern to many mobile apps is the scrollable list of items. Users interact with these using panning or swiping gestures. The [ScrollView](/react-native/docs/basics-component-scrollview.html) component displays a list of items that can be scrolled using these gestures.
<add>A common pattern to many mobile apps is the scrollable list of items. Users interact with these using panning or swiping gestures. The [ScrollView](/react-native/docs/using-a-scrollview.html) component displays a list of items that can be scrolled using these gestures.
<ide>
<ide> ScrollViews can scroll vertically or horizontally, and can be configured to allow paging through views using swiping gestures by using the `pagingEnabled` props. Swiping horizontally between views can also be implemented on Android using the [ViewPagerAndroid](/react-native/docs/viewpagerandroid.html) component.
<ide>
<del>A [ListView](/react-native/docs/basics-component-listview.html) is a special kind of ScrollView that is best suited for displaying long vertical lists of items. It can also display section headers and footers, similar to `UITableView`s on iOS.
<add>A [ListView](/react-native/docs/using-a-listview.html) is a special kind of ScrollView that is best suited for displaying long vertical lists of items. It can also display section headers and footers, similar to `UITableView`s on iOS.
<ide>
<ide> ### Pinch-to-zoom
<ide> | 1 |
Text | Text | fix documentation links | bbedf2da9a3a091eeb687d43029f7d2450cf2612 | <ide><path>react-native-git-upgrade/README.md
<ide> It uses Git under the hood to automatically resolve merge conflicts in project t
<ide>
<ide> ## Usage
<ide>
<del>See the [Upgrading docs](https://facebook.github.io/react-native/releases/next/docs/upgrading.html) on the React Native website.
<add>See the [Upgrading docs](https://facebook.github.io/react-native/docs/upgrading.html) on the React Native website.
<ide>
<ide> Basic usage:
<ide> | 1 |
Ruby | Ruby | add tests for formula list methods | f8ff0f465f44943c470a2e683519d2b5459f109e | <ide><path>Library/Homebrew/test/spec_helper.rb
<ide> def find_files
<ide> CoreTap.instance.path/".git",
<ide> CoreTap.instance.alias_dir,
<ide> CoreTap.instance.path/"formula_renames.json",
<add> CoreTap.instance.path/"tap_migrations.json",
<add> CoreTap.instance.path/"audit_exceptions",
<add> CoreTap.instance.path/"style_exceptions",
<add> CoreTap.instance.path/"pypi_formula_mappings.json",
<ide> *Pathname.glob("#{HOMEBREW_CELLAR}/*/"),
<ide> ]
<ide>
<ide><path>Library/Homebrew/test/tap_spec.rb
<ide>
<ide> before do
<ide> path.mkpath
<add> (path/"audit_exceptions").mkpath
<add> (path/"style_exceptions").mkpath
<ide> end
<ide>
<ide> def setup_tap_files
<ide> class Foo < Formula
<ide> { "removed-formula": "homebrew/foo" }
<ide> JSON
<ide>
<add> %w[audit_exceptions style_exceptions].each do |exceptions_directory|
<add> (path/"#{exceptions_directory}/formula_list.json").write <<~JSON
<add> [ "foo", "bar" ]
<add> JSON
<add>
<add> (path/"#{exceptions_directory}/formula_hash.json").write <<~JSON
<add> { "foo": "foo1", "bar": "bar1" }
<add> JSON
<add> end
<add>
<add> (path/"pypi_formula_mappings.json").write <<~JSON
<add> {
<add> "formula1": "foo",
<add> "formula2": {
<add> "package_name": "foo",
<add> "extra_packages": ["bar"],
<add> "exclude_packages": ["baz"]
<add> }
<add> }
<add> JSON
<add>
<ide> [
<ide> cmd_file,
<ide> manpage_file,
<ide> def setup_git_repo
<ide> expect(described_class.each).to be_an_instance_of(Enumerator)
<ide> end
<ide> end
<add>
<add> describe "Formula Lists" do
<add> describe "#formula_renames" do
<add> it "returns the formula_renames hash" do
<add> setup_tap_files
<add>
<add> expected_result = { "oldname" => "foo" }
<add> expect(subject.formula_renames).to eq expected_result
<add> end
<add> end
<add>
<add> describe "#tap_migrations" do
<add> it "returns the tap_migrations hash" do
<add> setup_tap_files
<add>
<add> expected_result = { "removed-formula" => "homebrew/foo" }
<add> expect(subject.tap_migrations).to eq expected_result
<add> end
<add> end
<add>
<add> describe "#audit_exceptions" do
<add> it "returns the audit_exceptions hash" do
<add> setup_tap_files
<add>
<add> expected_result = {
<add> formula_list: ["foo", "bar"],
<add> formula_hash: { "foo" => "foo1", "bar" => "bar1" },
<add> }
<add> expect(subject.audit_exceptions).to eq expected_result
<add> end
<add> end
<add>
<add> describe "#style_exceptions" do
<add> it "returns the style_exceptions hash" do
<add> setup_tap_files
<add>
<add> expected_result = {
<add> formula_list: ["foo", "bar"],
<add> formula_hash: { "foo" => "foo1", "bar" => "bar1" },
<add> }
<add> expect(subject.style_exceptions).to eq expected_result
<add> end
<add> end
<add>
<add> describe "#pypi_formula_mappings" do
<add> it "returns the pypi_formula_mappings hash" do
<add> setup_tap_files
<add>
<add> expected_result = {
<add> "formula1" => "foo",
<add> "formula2" => {
<add> "package_name" => "foo",
<add> "extra_packages" => ["bar"],
<add> "exclude_packages" => ["baz"],
<add> },
<add> }
<add> expect(subject.pypi_formula_mappings).to eq expected_result
<add> end
<add> end
<add> end
<ide> end
<ide>
<ide> describe CoreTap do
<ide> def setup_git_repo
<ide> end
<ide>
<ide> specify "files" do
<add> path = CoreTap::TAP_DIRECTORY/"homebrew/homebrew-core"
<ide> formula_file = subject.formula_dir/"foo.rb"
<ide> formula_file.write <<~RUBY
<ide> class Foo < Formula
<ide> url "https://brew.sh/foo-1.0.tar.gz"
<ide> end
<ide> RUBY
<ide>
<add> formula_list_file_json = '{ "foo": "foo1", "bar": "bar1" }'
<add> formula_list_file_contents = { "foo" => "foo1", "bar" => "bar1" }
<add> %w[
<add> formula_renames.json
<add> tap_migrations.json
<add> audit_exceptions/formula_list.json
<add> style_exceptions/formula_hash.json
<add> pypi_formula_mappings.json
<add> ].each do |file|
<add> (path/file).write formula_list_file_json
<add> end
<add>
<ide> alias_file = subject.alias_dir/"bar"
<ide> alias_file.parent.mkpath
<ide> ln_s formula_file, alias_file
<ide> class Foo < Formula
<ide> expect(subject.aliases).to eq(["bar"])
<ide> expect(subject.alias_table).to eq("bar" => "foo")
<ide> expect(subject.alias_reverse_table).to eq("foo" => ["bar"])
<add>
<add> expect(subject.formula_renames).to eq formula_list_file_contents
<add> expect(subject.tap_migrations).to eq formula_list_file_contents
<add> expect(subject.audit_exceptions).to eq({ formula_list: formula_list_file_contents })
<add> expect(subject.style_exceptions).to eq({ formula_hash: formula_list_file_contents })
<add> expect(subject.pypi_formula_mappings).to eq formula_list_file_contents
<ide> end
<ide> end | 2 |
Python | Python | use tf.select instead of tf.where (compat tf 0.11) | 30fa61d4576d103872a28ea8ae2281100a470388 | <ide><path>keras/backend/tensorflow_backend.py
<ide> def rnn(step_function, inputs, initial_states,
<ide> for input, mask_t in zip(input_list, mask_list):
<ide> output, new_states = step_function(input, states + constants)
<ide>
<del> # tf.where needs its condition tensor
<add> # tf.select needs its condition tensor
<ide> # to be the same shape as its two
<ide> # result tensors, but in our case
<ide> # the condition (mask) tensor is
<ide> def rnn(step_function, inputs, initial_states,
<ide> else:
<ide> prev_output = successive_outputs[-1]
<ide>
<del> output = tf.where(tiled_mask_t, output, prev_output)
<add> output = tf.select(tiled_mask_t, output, prev_output)
<ide>
<ide> return_states = []
<ide> for state, new_state in zip(states, new_states):
<ide> # (see earlier comment for tile explanation)
<ide> tiled_mask_t = tf.tile(mask_t,
<ide> stack([1, tf.shape(new_state)[1]]))
<del> return_states.append(tf.where(tiled_mask_t,
<del> new_state,
<del> state))
<add> return_states.append(tf.select(tiled_mask_t,
<add> new_state,
<add> state))
<ide> states = return_states
<ide> successive_outputs.append(output)
<ide> successive_states.append(states)
<ide> def _step(time, output_ta_t, *states):
<ide> new_state.set_shape(state.get_shape())
<ide> tiled_mask_t = tf.tile(mask_t,
<ide> stack([1, tf.shape(output)[1]]))
<del> output = tf.where(tiled_mask_t, output, states[0])
<del> new_states = [tf.where(tiled_mask_t, new_states[i], states[i]) for i in range(len(states))]
<add> output = tf.select(tiled_mask_t, output, states[0])
<add> new_states = [tf.select(tiled_mask_t, new_states[i], states[i]) for i in range(len(states))]
<ide> output_ta_t = output_ta_t.write(time, output)
<ide> return (time + 1, output_ta_t) + tuple(new_states)
<ide> else:
<ide> def elu(x, alpha=1.):
<ide> if alpha == 1:
<ide> return res
<ide> else:
<del> return tf.where(x > 0, res, alpha * res)
<add> return tf.select(x > 0, res, alpha * res)
<ide>
<ide>
<ide> def softmax(x):
<ide> def random_uniform(shape, low=0.0, high=1.0, dtype=_FLOATX, seed=None):
<ide> def random_binomial(shape, p=0.0, dtype=_FLOATX, seed=None):
<ide> if seed is None:
<ide> seed = np.random.randint(10e6)
<del> return tf.where(tf.random_uniform(shape, dtype=dtype, seed=seed) <= p,
<del> tf.ones(shape, dtype=dtype),
<del> tf.zeros(shape, dtype=dtype))
<add> return tf.select(tf.random_uniform(shape, dtype=dtype, seed=seed) <= p,
<add> tf.ones(shape, dtype=dtype),
<add> tf.zeros(shape, dtype=dtype))
<ide>
<ide>
<ide> # CTC | 1 |
Ruby | Ruby | fix syntax error | 393df7425f9bd51efcb7d6e56864d1221af3254c | <ide><path>activestorage/lib/active_storage/service/s3_service.rb
<ide> def exist?(key)
<ide> def url_for_direct_upload(key, expires_in:, content_type:, content_length:, checksum:)
<ide> instrument :url, key: key do |payload|
<ide> generated_url = object_for(key).presigned_url :put, expires_in: expires_in.to_i,
<del> content_type: content_type, content_length: content_length, content_md5: checksum
<del> whitelist_headers: ['content-length'], **upload_options
<add> content_type: content_type, content_length: content_length, content_md5: checksum,
<add> whitelist_headers: ["content-length"], **upload_options
<ide>
<ide> payload[:url] = generated_url
<ide> | 1 |
Javascript | Javascript | detect all types of aborts in windows | 6914aeaefd55b0b57364e70d0ef4374040539792 | <ide><path>test/common/index.js
<ide> exports.nodeProcessAborted = function nodeProcessAborted(exitCode, signal) {
<ide> // or SIGABRT (depending on the compiler).
<ide> const expectedSignals = ['SIGILL', 'SIGTRAP', 'SIGABRT'];
<ide>
<del> // On Windows, v8's base::OS::Abort triggers an access violation,
<add> // On Windows, 'aborts' are of 2 types, depending on the context:
<add> // (i) Forced access violation, if --abort-on-uncaught-exception is on
<ide> // which corresponds to exit code 3221225477 (0xC0000005)
<add> // (ii) raise(SIGABRT) or abort(), which lands up in CRT library calls
<add> // which corresponds to exit code 3.
<ide> if (exports.isWindows)
<del> expectedExitCodes = [3221225477];
<add> expectedExitCodes = [3221225477, 3];
<ide>
<ide> // When using --abort-on-uncaught-exception, V8 will use
<ide> // base::OS::Abort to terminate the process. | 1 |
Text | Text | remove inspector experimental warning | a7286f6af260ac3fe391507a734cf08710c124b1 | <ide><path>doc/api/debugger.md
<ide> flag instead of `--inspect`.
<ide>
<ide> ```txt
<ide> $ node --inspect index.js
<del>Debugger listening on port 9229.
<del>Warning: This is an experimental feature and could change at any time.
<add>Debugger listening on 127.0.0.1:9229.
<ide> To start debugging, open the following URL in Chrome:
<ide> chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/dc9010dd-f8b8-4ac5-a510-c1a114ec7d29
<ide> ``` | 1 |
Ruby | Ruby | add pin info to tap-info | f3f8ca953fde402f39feab57b5809a28594b690a | <ide><path>Library/Homebrew/cmd/tap-info.rb
<ide> def print_tap_info(taps)
<ide> puts unless i == 0
<ide> info = "#{tap}: "
<ide> if tap.installed?
<add> info += tap.pinned? ? "pinned, " : "unpinned, "
<ide> formula_count = tap.formula_files.size
<ide> info += "#{formula_count} formula#{plural(formula_count, "e")} " if formula_count > 0
<ide> command_count = tap.command_files.size | 1 |
Python | Python | remove unicode prefix that snuck in | b1fc8c19b20a12f30d0b3cc3eaa0a354551b8a6e | <ide><path>tests/migrations/test_operations.py
<ide> def test_create_model_inheritance(self):
<ide> ('pony_ptr', models.OneToOneField(
<ide> auto_created=True,
<ide> primary_key=True,
<del> to_field=u'id',
<add> to_field='id',
<ide> serialize=False,
<ide> to='test_crmoih.Pony',
<ide> )), | 1 |
PHP | PHP | add total() to orm\query | 613a25aa4f614e48a7cd982eeff73e2dd4b35371 | <ide><path>Cake/ORM/Query.php
<ide> public function first() {
<ide> return $this->_results->one();
<ide> }
<ide>
<add>/**
<add> * Return the COUNT(*) for for the query.
<add> *
<add> * This method will replace the selected fields with a COUNT(*)
<add> * and execute the queries returning the number of rows.
<add> *
<add> * @return integer
<add> */
<add> public function total() {
<add> return $this->select(['count' => $this->count('*')], true)
<add> ->hydrate(false)
<add> ->first()['count'];
<add> }
<add>
<ide> /**
<ide> * Toggle hydrating entites.
<ide> *
<ide><path>Cake/Test/TestCase/ORM/QueryTest.php
<ide> public function testHydrateBelongsToCustomEntity() {
<ide> $this->assertInstanceOf($authorEntity, $first->author);
<ide> }
<ide>
<add>/**
<add> * Test getting totals from queries.
<add> *
<add> * @return void
<add> */
<add> public function testTotal() {
<add> $table = TableRegistry::get('articles');
<add> $result = $table->find('all')->total();
<add> $this->assertEquals(3, $result);
<add>
<add> $query = $table->find('all')
<add> ->where(['id >' => 1]);
<add> $result = $query->total();
<add> $this->assertEquals(2, $result);
<add>
<add> $result = $query->execute();
<add> $this->assertEquals(['count' => 2], $result->one());
<add> }
<add>
<ide> } | 2 |
PHP | PHP | fix method description leftovers | 653dc3db32a09797797e788d879367f9de67d52d | <ide><path>src/Illuminate/Validation/Factory.php
<ide> public function extendImplicit($rule, $extension, $message = null)
<ide> }
<ide>
<ide> /**
<del> * Register a custom implicit validator extension.
<add> * Register a custom dependent validator extension.
<ide> *
<ide> * @param string $rule
<ide> * @param \Closure|string $extension
<ide> public function extendDependent($rule, $extension, $message = null)
<ide> }
<ide>
<ide> /**
<del> * Register a custom implicit validator message replacer.
<add> * Register a custom validator message replacer.
<ide> *
<ide> * @param string $rule
<ide> * @param \Closure|string $replacer | 1 |
Javascript | Javascript | simplify force calculations | 51b8e023c1fdceb92141d0d496676d8ac950b261 | <ide><path>d3.js
<del>(function(){d3 = {version: "1.13.2"}; // semver
<add>(function(){d3 = {version: "1.13.3"}; // semver
<ide> if (!Date.now) Date.now = function() {
<ide> return +new Date();
<ide> };
<ide><path>d3.layout.js
<ide> d3.layout.force = function() {
<ide> links,
<ide> distances;
<ide>
<del> function accumulate(quad) {
<del> var cx = 0,
<del> cy = 0;
<del> quad.count = 0;
<del> if (!quad.leaf) {
<del> quad.nodes.forEach(function(c) {
<del> accumulate(c);
<del> quad.count += c.count;
<del> cx += c.count * c.cx;
<del> cy += c.count * c.cy;
<del> });
<del> }
<del> if (quad.point) {
<del> quad.count++;
<del> cx += quad.point.x;
<del> cy += quad.point.y;
<del> }
<del> quad.cx = cx / quad.count;
<del> quad.cy = cy / quad.count;
<del> }
<del>
<ide> function repulse(node, kc) {
<ide> return function(quad, x1, y1, x2, y2) {
<ide> if (quad.point != node) {
<ide> d3.layout.force = function() {
<ide> /* Barnes-Hut criterion. */
<ide> if ((x2 - x1) * dn < theta) {
<ide> var k = kc * quad.count * dn * dn;
<del> node.fx += dx * k;
<del> node.fy += dy * k;
<add> node.x += dx * k;
<add> node.y += dy * k;
<ide> return true;
<ide> }
<ide>
<ide> if (quad.point) {
<ide> var k = kc * dn * dn;
<del> node.fx += dx * k;
<del> node.fy += dy * k;
<add> node.x += dx * k;
<add> node.y += dy * k;
<ide> }
<ide> }
<ide> };
<ide> d3.layout.force = function() {
<ide> x, // x-distance
<ide> y; // y-distance
<ide>
<del> // reset forces
<del> i = -1; while (++i < n) {
<del> (o = nodes[i]).fx = o.fy = 0;
<del> }
<del>
<ide> // gauss-seidel relaxation for links
<ide> for (i = 0; i < m; ++i) {
<ide> o = links[i];
<ide> s = o.source;
<ide> t = o.target;
<ide> x = t.x - s.x;
<ide> y = t.y - s.y;
<del> if (l = Math.sqrt(x * x + y * y)) {
<del> l = alpha * (l - distance) / l;
<add> if (l = (x * x + y * y)) {
<add> l = alpha * ((l = Math.sqrt(l)) - distance) / l;
<ide> x *= l;
<ide> y *= l;
<ide> t.x -= x;
<ide> d3.layout.force = function() {
<ide> }
<ide> }
<ide>
<del> // compute quadtree center of mass
<del> accumulate(q);
<del>
<ide> // apply gravity forces
<ide> var kg = alpha * gravity;
<ide> x = size[0] / 2;
<ide> y = size[1] / 2;
<ide> i = -1; while (++i < n) {
<ide> o = nodes[i];
<del> o.fx += (x - o.x) * kg;
<del> o.fy += (y - o.y) * kg;
<add> o.x += (x - o.x) * kg;
<add> o.y += (y - o.y) * kg;
<ide> }
<ide>
<add> // compute quadtree center of mass
<add> d3_layout_forceAccumulate(q);
<add>
<ide> // apply charge forces
<ide> var kc = alpha * charge;
<ide> i = -1; while (++i < n) {
<ide> d3.layout.force = function() {
<ide> o.x = o.px;
<ide> o.y = o.py;
<ide> } else {
<del> x = o.px - (o.px = o.x);
<del> y = o.py - (o.py = o.y);
<del> o.x += o.fx - x * drag;
<del> o.y += o.fy - y * drag;
<add> o.x -= (o.px - (o.px = o.x)) * drag;
<add> o.y -= (o.py - (o.py = o.y)) * drag;
<ide> }
<ide> }
<ide>
<del> event.tick.dispatch({type: "tick"});
<add> event.tick.dispatch({type: "tick", alpha: alpha});
<ide>
<ide> // simulated annealing, basically
<ide> return (alpha *= .99) < .005;
<ide> function d3_layout_forceCancel() {
<ide> d3.event.stopPropagation();
<ide> d3.event.preventDefault();
<ide> }
<add>
<add>function d3_layout_forceAccumulate(quad) {
<add> var cx = 0,
<add> cy = 0;
<add> quad.count = 0;
<add> if (!quad.leaf) {
<add> quad.nodes.forEach(function(c) {
<add> d3_layout_forceAccumulate(c);
<add> quad.count += c.count;
<add> cx += c.count * c.cx;
<add> cy += c.count * c.cy;
<add> });
<add> }
<add> if (quad.point) {
<add> quad.count++;
<add> cx += quad.point.x;
<add> cy += quad.point.y;
<add> }
<add> quad.cx = cx / quad.count;
<add> quad.cy = cy / quad.count;
<add>}
<ide> d3.layout.partition = function() {
<ide> var hierarchy = d3.layout.hierarchy(),
<ide> size = [1, 1]; // width, height
<ide><path>d3.layout.min.js
<del>(function(){function R(a,b,c){return a._tree.ancestor.parent==b.parent?a._tree.ancestor:c}function Q(a,b,c){a=a._tree,b=b._tree;var d=c/(b.number-a.number);a.change+=d,b.change-=d,b.shift+=c,b.prelim+=c,b.mod+=c}function P(a){var b=0,c=0,d=a.children,e=d.length,f;while(--e>=0)f=d[e]._tree,f.prelim+=b,f.mod+=b,b+=f.shift+(c+=f.change)}function O(a,b){function c(a,d){var e=a.children;if(e){var f,g=null,h=-1,i=e.length;while(++h<i)f=e[h],c(f,g),g=f}b(a,d)}c(a,null)}function N(a,b){return a.depth-b.depth}function M(a,b){return b.x-a.x}function L(a,b){return a.x-b.x}function K(a,b){var c=a.children;if(c){var d,e=c.length,f=-1;while(++f<e)b(d=K(c[f],b),a)>0&&(a=d)}return a}function J(a){return a.children?a.children[a.children.length-1]:a._tree.thread}function I(a){return a.children?a.children[0]:a._tree.thread}function H(a,b){return a.parent==b.parent?1:2}function G(a){return d3.merge(a.map(function(a){return(a.children||[]).map(function(b){return{source:a,target:b}})}))}function F(a){var b=a.children;return b?F(b[b.length-1]):a}function E(a){var b=a.children;return b?E(b[0]):a}function D(a){return a.reduce(function(a,b){return a+b.x},0)/a.length}function C(a){return 1+d3.max(a,function(a){return a.y})}function B(a,b,c){var d=b.r+c.r,e=a.r+c.r,f=b.x-a.x,g=b.y-a.y,h=Math.sqrt(f*f+g*g),i=(e*e+h*h-d*d)/(2*e*h),j=Math.acos(i),k=i*e,l=Math.sin(j)*e;f/=h,g/=h,c.x=a.x+k*f+l*g,c.y=a.y+k*g-l*f}function A(a,b,c,d){var e=a.children;a.x=b+=d*a.x,a.y=c+=d*a.y,a.r*=d;if(e){var f=-1,g=e.length;while(++f<g)A(e[f],b,c,d)}}function z(a){var b=a.children;b?(b.forEach(z),a.r=w(b)):a.r=Math.sqrt(a.value)}function y(a){delete a._pack_next,delete a._pack_prev}function x(a){a._pack_next=a._pack_prev=a}function w(a){function l(a){b=Math.min(a.x-a.r,b),c=Math.max(a.x+a.r,c),d=Math.min(a.y-a.r,d),e=Math.max(a.y+a.r,e)}var b=Infinity,c=-Infinity,d=Infinity,e=-Infinity,f=a.length,g,h,i,j,k;a.forEach(x),g=a[0],g.x=-g.r,g.y=0,l(g);if(f>1){h=a[1],h.x=h.r,h.y=0,l(h);if(f>2){i=a[2],B(g,h,i),l(i),t(g,i),g._pack_prev=i,t(i,h),h=g._pack_next;for(var m=3;m<f;m++){B(g,h,i=a[m]);var n=0,o=1,p=1;for(j=h._pack_next;j!=h;j=j._pack_next,o++)if(v(j,i)){n=1;break}if(n==1)for(k=g._pack_prev;k!=j._pack_prev;k=k._pack_prev,p++)if(v(k,i)){p<o&&(n=-1,j=k);break}n==0?(t(g,i),h=i,l(i)):n>0?(u(g,j),h=j,m--):(u(j,h),g=j,m--)}}}var q=(b+c)/2,r=(d+e)/2,s=0;for(var m=0;m<f;m++){var w=a[m];w.x-=q,w.y-=r,s=Math.max(s,w.r+Math.sqrt(w.x*w.x+w.y*w.y))}a.forEach(y);return s}function v(a,b){var c=b.x-a.x,d=b.y-a.y,e=a.r+b.r;return e*e-c*c-d*d>.001}function u(a,b){a._pack_next=b,b._pack_prev=a}function t(a,b){var c=a._pack_next;a._pack_next=b,b._pack_prev=a,b._pack_next=c,c._pack_prev=b}function s(a,b){return a.value-b.value}function r(a,b){return b.value-a.value}function q(a){return a.value}function p(a){return a.children}function o(a,b){return a+b.y}function n(a){var b=1,c=0,d=a[0].y,e,f=a.length;for(;b<f;++b)(e=a[b].y)>d&&(c=b,d=e);return c}function m(a){return a.reduce(o,0)}function j(){d3.event.stopPropagation(),d3.event.preventDefault()}function i(){c&&(j(),c=!1)}function h(c,d){(a=c).fixed=!0,b=!1,e=this,j()}function g(b){b!==a&&(b.fixed=!1)}function f(a){a.fixed=!0}d3.layout={},d3.layout.chord=function(){function k(){b.sort(function(a,b){a=Math.min(a.source.value,a.target.value),b=Math.min(b.source.value,b.target.value);return i(a,b)})}function j(){var a={},j=[],l=d3.range(e),m=[],n,o,p,q,r;b=[],c=[],n=0,q=-1;while(++q<e){o=0,r=-1;while(++r<e)o+=d[q][r];j.push(o),m.push(d3.range(e)),n+=o}g&&l.sort(function(a,b){return g(j[a],j[b])}),h&&m.forEach(function(a,b){a.sort(function(a,c){return h(d[b][a],d[b][c])})}),n=(2*Math.PI-f*e)/n,o=0,q=-1;while(++q<e){p=o,r=-1;while(++r<e){var s=l[q],t=m[q][r],u=d[s][t];a[s+"-"+t]={index:s,subindex:t,startAngle:o,endAngle:o+=u*n,value:u}}c.push({index:s,startAngle:p,endAngle:o,value:(o-p)/n}),o+=f}q=-1;while(++q<e){r=q-1;while(++r<e){var v=a[q+"-"+r],w=a[r+"-"+q];(v.value||w.value)&&b.push({source:v,target:w})}}i&&k()}var a={},b,c,d,e,f=0,g,h,i;a.matrix=function(f){if(!arguments.length)return d;e=(d=f)&&d.length,b=c=null;return a},a.padding=function(d){if(!arguments.length)return f;f=d,b=c=null;return a},a.sortGroups=function(d){if(!arguments.length)return g;g=d,b=c=null;return a},a.sortSubgroups=function(c){if(!arguments.length)return h;h=c,b=null;return a},a.sortChords=function(c){if(!arguments.length)return i;i=c,b&&k();return a},a.chords=function(){b||j();return b},a.groups=function(){c||j();return c};return a},d3.layout.force=function(){function A(){!a||(b&&(c=!0,j()),z(),a.fixed=!1,a=e=null)}function z(){if(!!a){if(!e.parentNode){a.fixed=!1,a=e=null;return}var c=d3.svg.mouse(e);b=!0,a.px=c[0],a.py=c[1],d.resume()}}function y(){var a=t.length,b=u.length,c=d3.geom.quadtree(t),d,e,f,g,h,i,j;d=-1;while(++d<a)(e=t[d]).fx=e.fy=0;for(d=0;d<b;++d){e=u[d],f=e.source,g=e.target,i=g.x-f.x,j=g.y-f.y;if(h=Math.sqrt(i*i+j*j))h=m*(h-o)/h,i*=h,j*=h,g.x-=i,g.y-=j,f.x+=i,f.y+=j}w(c);var r=m*q;i=l[0]/2,j=l[1]/2,d=-1;while(++d<a)e=t[d],e.fx+=(i-e.x)*r,e.fy+=(j-e.y)*r;var s=m*p;d=-1;while(++d<a)c.visit(x(t[d],s));d=-1;while(++d<a)e=t[d],e.fixed?(e.x=e.px,e.y=e.py):(i=e.px-(e.px=e.x),j=e.py-(e.py=e.y),e.x+=e.fx-i*n,e.y+=e.fy-j*n);k.tick.dispatch({type:"tick"});return(m*=.99)<.005}function x(a,b){return function(c,d,e,f,g){if(c.point!=a){var h=c.cx-a.x||Math.random(),i=c.cy-a.y||Math.random(),j=1/Math.sqrt(h*h+i*i);if((f-d)*j<r){var k=b*c.count*j*j;a.fx+=h*k,a.fy+=i*k;return!0}if(c.point){var k=b*j*j;a.fx+=h*k,a.fy+=i*k}}}}function w(a){var b=0,c=0;a.count=0,a.leaf||a.nodes.forEach(function(d){w(d),a.count+=d.count,b+=d.count*d.cx,c+=d.count*d.cy}),a.point&&(a.count++,b+=a.point.x,c+=a.point.y),a.cx=b/a.count,a.cy=c/a.count}var d={},k=d3.dispatch("tick"),l=[1,1],m,n=.9,o=20,p=-30,q=.1,r=.8,s,t,u,v;d.on=function(a,b){k[a].add(b);return d},d.nodes=function(a){if(!arguments.length)return t;t=a;return d},d.links=function(a){if(!arguments.length)return u;u=a;return d},d.size=function(a){if(!arguments.length)return l;l=a;return d},d.distance=function(a){if(!arguments.length)return o;o=a;return d},d.drag=function(a){if(!arguments.length)return n;n=a;return d},d.charge=function(a){if(!arguments.length)return p;p=a;return d},d.gravity=function(a){if(!arguments.length)return q;q=a;return d},d.theta=function(a){if(!arguments.length)return r;r=a;return d},d.start=function(){function k(){if(!h){h=[];for(b=0;b<c;++b)h[b]=[];for(b=0;b<e;++b){var d=u[b];h[d.source.index].push(d.target),h[d.target.index].push(d.source)}}return h[a]}function j(b,c){var d=k(a),e=-1,f=d.length,g;while(++e<f)if(!isNaN(g=d[e][b]))return g;return Math.random()*c}var a,b,c=t.length,e=u.length,f=l[0],g=l[1],h,i;for(a=0;a<c;++a)(i=t[a]).index=a;for(a=0;a<e;++a)i=u[a],typeof i.source=="number"&&(i.source=t[i.source]),typeof i.target=="number"&&(i.target=t[i.target]);for(a=0;a<c;++a)i=t[a],isNaN(i.x)&&(i.x=j("x",f)),isNaN(i.y)&&(i.y=j("y",g)),isNaN(i.px)&&(i.px=i.x),isNaN(i.py)&&(i.py=i.y);return d.resume()},d.resume=function(){m=.1,d3.timer(y);return d},d.stop=function(){m=0;return d},d.drag=function(){this.on("mouseover.force",f).on("mouseout.force",g).on("mousedown.force",h),d3.select(window).on("mousemove.force",z).on("mouseup.force",A,!0).on("click.force",i,!0);return d};return d};var a,b,c,e;d3.layout.partition=function(){function e(e,f){var g=a.call(this,e,f);c(g[0],0,b[0],b[1]/d(g[0]));return g}function d(a){var b=a.children,c=0;if(b){var e=-1,f=b.length;while(++e<f)c=Math.max(c,d(b[e]))}return 1+c}function c(a,b,d,e){var f=a.children;a.x=b,a.y=a.depth*e,a.dx=d,a.dy=e;if(f){var g=-1,h=f.length,i,j;d/=a.value;while(++g<h)c(i=f[g],b,j=i.value*d,e),b+=j}}var a=d3.layout.hierarchy(),b=[1,1];e.sort=d3.rebind(e,a.sort),e.children=d3.rebind(e,a.children),e.value=d3.rebind(e,a.value),e.size=function(a){if(!arguments.length)return b;b=a;return e};return e},d3.layout.pie=function(){function f(f,g){var h=+(typeof c=="function"?c.apply(this,arguments):c),i=(typeof e=="function"?e.apply(this,arguments):e)-c,j=d3.range(f.length);b!=null&&j.sort(function(a,c){return b(f[a],f[c])});var k=f.map(a);i/=k.reduce(function(a,b){return a+b},0);var l=j.map(function(a){return{value:d=k[a],startAngle:h,endAngle:h+=d*i}});return f.map(function(a,b){return l[j[b]]})}var a=Number,b=null,c=0,e=2*Math.PI;f.value=function(b){if(!arguments.length)return a;a=b;return f},f.sort=function(a){if(!arguments.length)return b;b=a;return f},f.startAngle=function(a){if(!arguments.length)return c;c=a;return f},f.endAngle=function(a){if(!arguments.length)return e;e=a;return f};return f},d3.layout.stack=function(){function c(c){var d=c.length,e=c[0].length,f,g,h,i=k[a](c);l[b](c,i);for(g=0;g<e;++g)for(f=1,h=c[i[0]][g].y0;f<d;++f)c[i[f]][g].y0=h+=c[i[f-1]][g].y;return c}var a="default",b="zero";c.order=function(b){if(!arguments.length)return a;a=b;return c},c.offset=function(a){if(!arguments.length)return b;b=a;return c};return c};var k={"inside-out":function(a){var b=a.length,c,d,e=a.map(n),f=a.map(m),g=d3.range(b).sort(function(a,b){return e[a]-e[b]}),h=0,i=0,j=[],k=[];for(c=0;c<b;c++)d=g[c],h<i?(h+=f[d],j.push(d)):(i+=f[d],k.push(d));return k.reverse().concat(j)},reverse:function(a){return d3.range(a.length).reverse()},"default":function(a){return d3.range(a.length)}},l={silhouette:function(a,b){var c=a.length,d=a[0].length,e=[],f=0,g,h,i;for(h=0;h<d;++h){for(g=0,i=0;g<c;g++)i+=a[g][h].y;i>f&&(f=i),e.push(i)}for(h=0,g=b[0];h<d;++h)a[g][h].y0=(f-e[h])/2},wiggle:function(a,b){var c=a.length,d=a[0],e=d.length,f=0,g,h,i,j,k,l=b[0],m,n,o,p,q,r;a[l][0].y0=q=r=0;for(h=1;h<e;++h){for(g=0,m=0;g<c;++g)m+=a[g][h].y;for(g=0,n=0,p=d[h].x-d[h-1].x;g<c;++g){for(i=0,j=b[g],o=(a[j][h].y-a[j][h-1].y)/(2*p);i<g;++i)o+=(a[k=b[i]][h].y-a[k][h-1].y)/p;n+=o*a[j][h].y}a[l][h].y0=q-=m?n/m*p:0,q<r&&(r=q)}for(h=0;h<e;++h)a[l][h].y0-=r},zero:function(a,b){var c=0,d=a[0].length,e=b[0];for(;c<d;++c)a[e][c].y0=0}};d3.layout.hierarchy=function(){function g(a){var b=[];e(a,0,b);return b}function f(a,b){var d=a.children,e=0;if(d){var h=-1,i=d.length,j=b+1;while(++h<i)e+=f(d[h],j)}else c&&(e=c.call(g,a.data,b));c&&(a.value=e);return e}function e(f,h,i){var j=b.call(g,f,h),k={depth:h,data:f};i.push(k);if(j){var l=-1,m=j.length,n=k.children=[],o=0,p=h+1;while(++l<m)d=e(j[l],p,i),d.parent=k,n.push(d),o+=d.value;a&&n.sort(a),c&&(k.value=o)}else c&&(k.value=c.call(g,f,h));return k}var a=r,b=p,c=q;g.sort=function(b){if(!arguments.length)return a;a=b;return g},g.children=function(a){if(!arguments.length)return b;b=a;return g},g.value=function(a){if(!arguments.length)return c;c=a;return g},g.revalue=function(a){f(a,0);return a};return g},d3.layout.pack=function(){function c(c,d){var e=a.call(this,c,d),f=e[0];f.x=0,f.y=0,z(f);var g=b[0],h=b[1],i=1/Math.max(2*f.r/g,2*f.r/h);A(f,g/2,h/2,i);return e}var a=d3.layout.hierarchy(),b=[1,1];c.sort=d3.rebind(c,a.sort),c.children=d3.rebind(c,a.children),c.value=d3.rebind(c,a.value),c.size=function(a){if(!arguments.length)return b;b=a;return c};return c.sort(s)},d3.layout.cluster=function(){function d(d,e){var f=a.call(this,d,e),g=f[0],h,i=0,j,k;O(g,function(a){a.children?(a.x=D(a.children),a.y=C(a.children)):(a.x=h?i+=b(a,h):0,a.y=0,h=a)});var l=E(g),m=F(g),n=l.x-b(l,m)/2,o=m.x+b(m,l)/2;O(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=(1-a.y/g.y)*c[1]});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=H,c=[1,1];d.sort=d3.rebind(d,a.sort),d.children=d3.rebind(d,a.children),d.links=G,d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return d},d3.layout.tree=function(){function d(d,e){function j(a,c,d){if(c){var e=a,f=a,g=c,h=a.parent.children[0],i=e._tree.mod,j=f._tree.mod,k=g._tree.mod,l=h._tree.mod,m;while(g=J(g),e=I(e),g&&e)h=I(h),f=J(f),f._tree.ancestor=a,m=g._tree.prelim+k-e._tree.prelim-i+b(g,e),m>0&&(Q(R(g,a,d),a,m),i+=m,j+=m),k+=g._tree.mod,i+=e._tree.mod,l+=h._tree.mod,j+=f._tree.mod;g&&!J(f)&&(f._tree.thread=g,f._tree.mod+=k-j),e&&!I(h)&&(h._tree.thread=e,h._tree.mod+=i-l,d=a)}return d}function i(a,b){a.x=a._tree.prelim+b;var c=a.children;if(c){var d=-1,e=c.length;b+=a._tree.mod;while(++d<e)i(c[d],b)}}function h(a,c){var d=a.children,e=a._tree;if(d){var f=d.length,g=d[0],i,k=g,l,m=-1;while(++m<f)l=d[m],h(l,i),k=j(l,i,k),i=l;P(a);var n=.5*(g._tree.prelim+l._tree.prelim);c?(e.prelim=c._tree.prelim+b(a,c),e.mod=e.prelim-n):e.prelim=n}else c&&(e.prelim=c._tree.prelim+b(a,c))}var f=a.call(this,d,e),g=f[0];O(g,function(a,b){a._tree={ancestor:a,prelim:0,mod:0,change:0,shift:0,number:b?b._tree.number+1:0}}),h(g),i(g,-g._tree.prelim);var k=K(g,M),l=K(g,L),m=K(g,N),n=k.x-b(k,l)/2,o=l.x+b(l,k)/2,p=m.depth;O(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=a.depth/p*c[1],delete a._tree});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=H,c=[1,1];d.sort=d3.rebind(d,a.sort),d.children=d3.rebind(d,a.children),d.links=G,d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return d},d3.layout.treemap=function(){function k(b){var i=e||a(b),j=i[0];j.x=0,j.y=0,j.dx=c[0],j.dy=c[1],e&&a.revalue(j),f(j,c[0]*c[1]/j.value),(e?h:g)(j),d&&(e=i);return i}function j(a,c,d,e){var f=-1,g=a.length,h=d.x,i=d.y,j=c?b(a.area/c):0,k;if(c==d.dx){if(e||j>d.dy)j=d.dy;while(++f<g)k=a[f],k.x=h,k.y=i,k.dy=j,h+=k.dx=b(k.area/j);k.z=!0,k.dx+=d.x+d.dx-h,d.y+=j,d.dy-=j}else{if(e||j>d.dx)j=d.dx;while(++f<g)k=a[f],k.x=h,k.y=i,k.dx=j,i+=k.dy=b(k.area/j);k.z=!1,k.dy+=d.y+d.dy-i,d.x+=j,d.dx-=j}}function i(a,b){var c=a.area,d,e=0,f=Infinity,g=-1,h=a.length;while(++g<h)d=a[g].area,d<f&&(f=d),d>e&&(e=d);c*=c,b*=b;return Math.max(b*e/c,c/(b*f))}function h(a){if(!!a.children){var b={x:a.x,y:a.y,dx:a.dx,dy:a.dy},c=a.children.slice(),d,e=[];e.area=0;while(d=c.pop())e.push(d),e.area+=d.area,d.z!=null&&(j(e,d.z?b.dx:b.dy,b,!c.length),e.length=e.area=0);a.children.forEach(h)}}function g(a){if(!!a.children){var b={x:a.x,y:a.y,dx:a.dx,dy:a.dy},c=[],d=a.children.slice(),e,f=Infinity,h,k=Math.min(b.dx,b.dy),l;c.area=0;while((l=d.length)>0)c.push(e=d[l-1]),c.area+=e.area,(h=i(c,k))<=f?(d.pop(),f=h):(c.area-=c.pop().area,j(c,k,b,!1),k=Math.min(b.dx,b.dy),c.length=c.area=0,f=Infinity);c.length&&(j(c,k,b,!0),c.length=c.area=0),a.children.forEach(g)}}function f(a,b){var c=a.children;a.area=a.value*b;if(c){var d=-1,e=c.length;while(++d<e)f(c[d],b)}}var a=d3.layout.hierarchy(),b=Math.round,c=[1,1],d=!1,e;k.sort=d3.rebind(k,a.sort),k.children=d3.rebind(k,a.children),k.value=d3.rebind(k,a.value),k.size=function(a){if(!arguments.length)return c;c=a;return k},k.round=function(a){if(!arguments.length)return b!=Number;b=a?Math.round:Number;return k},k.sticky=function(a){if(!arguments.length)return d;d=a,e=null;return k};return k}})()
<ide>\ No newline at end of file
<add>(function(){function S(a,b,c){return a._tree.ancestor.parent==b.parent?a._tree.ancestor:c}function R(a,b,c){a=a._tree,b=b._tree;var d=c/(b.number-a.number);a.change+=d,b.change-=d,b.shift+=c,b.prelim+=c,b.mod+=c}function Q(a){var b=0,c=0,d=a.children,e=d.length,f;while(--e>=0)f=d[e]._tree,f.prelim+=b,f.mod+=b,b+=f.shift+(c+=f.change)}function P(a,b){function c(a,d){var e=a.children;if(e){var f,g=null,h=-1,i=e.length;while(++h<i)f=e[h],c(f,g),g=f}b(a,d)}c(a,null)}function O(a,b){return a.depth-b.depth}function N(a,b){return b.x-a.x}function M(a,b){return a.x-b.x}function L(a,b){var c=a.children;if(c){var d,e=c.length,f=-1;while(++f<e)b(d=L(c[f],b),a)>0&&(a=d)}return a}function K(a){return a.children?a.children[a.children.length-1]:a._tree.thread}function J(a){return a.children?a.children[0]:a._tree.thread}function I(a,b){return a.parent==b.parent?1:2}function H(a){return d3.merge(a.map(function(a){return(a.children||[]).map(function(b){return{source:a,target:b}})}))}function G(a){var b=a.children;return b?G(b[b.length-1]):a}function F(a){var b=a.children;return b?F(b[0]):a}function E(a){return a.reduce(function(a,b){return a+b.x},0)/a.length}function D(a){return 1+d3.max(a,function(a){return a.y})}function C(a,b,c){var d=b.r+c.r,e=a.r+c.r,f=b.x-a.x,g=b.y-a.y,h=Math.sqrt(f*f+g*g),i=(e*e+h*h-d*d)/(2*e*h),j=Math.acos(i),k=i*e,l=Math.sin(j)*e;f/=h,g/=h,c.x=a.x+k*f+l*g,c.y=a.y+k*g-l*f}function B(a,b,c,d){var e=a.children;a.x=b+=d*a.x,a.y=c+=d*a.y,a.r*=d;if(e){var f=-1,g=e.length;while(++f<g)B(e[f],b,c,d)}}function A(a){var b=a.children;b?(b.forEach(A),a.r=x(b)):a.r=Math.sqrt(a.value)}function z(a){delete a._pack_next,delete a._pack_prev}function y(a){a._pack_next=a._pack_prev=a}function x(a){function l(a){b=Math.min(a.x-a.r,b),c=Math.max(a.x+a.r,c),d=Math.min(a.y-a.r,d),e=Math.max(a.y+a.r,e)}var b=Infinity,c=-Infinity,d=Infinity,e=-Infinity,f=a.length,g,h,i,j,k;a.forEach(y),g=a[0],g.x=-g.r,g.y=0,l(g);if(f>1){h=a[1],h.x=h.r,h.y=0,l(h);if(f>2){i=a[2],C(g,h,i),l(i),u(g,i),g._pack_prev=i,u(i,h),h=g._pack_next;for(var m=3;m<f;m++){C(g,h,i=a[m]);var n=0,o=1,p=1;for(j=h._pack_next;j!=h;j=j._pack_next,o++)if(w(j,i)){n=1;break}if(n==1)for(k=g._pack_prev;k!=j._pack_prev;k=k._pack_prev,p++)if(w(k,i)){p<o&&(n=-1,j=k);break}n==0?(u(g,i),h=i,l(i)):n>0?(v(g,j),h=j,m--):(v(j,h),g=j,m--)}}}var q=(b+c)/2,r=(d+e)/2,s=0;for(var m=0;m<f;m++){var t=a[m];t.x-=q,t.y-=r,s=Math.max(s,t.r+Math.sqrt(t.x*t.x+t.y*t.y))}a.forEach(z);return s}function w(a,b){var c=b.x-a.x,d=b.y-a.y,e=a.r+b.r;return e*e-c*c-d*d>.001}function v(a,b){a._pack_next=b,b._pack_prev=a}function u(a,b){var c=a._pack_next;a._pack_next=b,b._pack_prev=a,b._pack_next=c,c._pack_prev=b}function t(a,b){return a.value-b.value}function s(a,b){return b.value-a.value}function r(a){return a.value}function q(a){return a.children}function p(a,b){return a+b.y}function o(a){var b=1,c=0,d=a[0].y,e,f=a.length;for(;b<f;++b)(e=a[b].y)>d&&(c=b,d=e);return c}function n(a){return a.reduce(p,0)}function k(a){var b=0,c=0;a.count=0,a.leaf||a.nodes.forEach(function(d){k(d),a.count+=d.count,b+=d.count*d.cx,c+=d.count*d.cy}),a.point&&(a.count++,b+=a.point.x,c+=a.point.y),a.cx=b/a.count,a.cy=c/a.count}function j(){d3.event.stopPropagation(),d3.event.preventDefault()}function i(){c&&(j(),c=!1)}function h(c,d){(a=c).fixed=!0,b=!1,e=this,j()}function g(b){b!==a&&(b.fixed=!1)}function f(a){a.fixed=!0}d3.layout={},d3.layout.chord=function(){function k(){b.sort(function(a,b){a=Math.min(a.source.value,a.target.value),b=Math.min(b.source.value,b.target.value);return i(a,b)})}function j(){var a={},j=[],l=d3.range(e),m=[],n,o,p,q,r;b=[],c=[],n=0,q=-1;while(++q<e){o=0,r=-1;while(++r<e)o+=d[q][r];j.push(o),m.push(d3.range(e)),n+=o}g&&l.sort(function(a,b){return g(j[a],j[b])}),h&&m.forEach(function(a,b){a.sort(function(a,c){return h(d[b][a],d[b][c])})}),n=(2*Math.PI-f*e)/n,o=0,q=-1;while(++q<e){p=o,r=-1;while(++r<e){var s=l[q],t=m[q][r],u=d[s][t];a[s+"-"+t]={index:s,subindex:t,startAngle:o,endAngle:o+=u*n,value:u}}c.push({index:s,startAngle:p,endAngle:o,value:(o-p)/n}),o+=f}q=-1;while(++q<e){r=q-1;while(++r<e){var v=a[q+"-"+r],w=a[r+"-"+q];(v.value||w.value)&&b.push({source:v,target:w})}}i&&k()}var a={},b,c,d,e,f=0,g,h,i;a.matrix=function(f){if(!arguments.length)return d;e=(d=f)&&d.length,b=c=null;return a},a.padding=function(d){if(!arguments.length)return f;f=d,b=c=null;return a},a.sortGroups=function(d){if(!arguments.length)return g;g=d,b=c=null;return a},a.sortSubgroups=function(c){if(!arguments.length)return h;h=c,b=null;return a},a.sortChords=function(c){if(!arguments.length)return i;i=c,b&&k();return a},a.chords=function(){b||j();return b},a.groups=function(){c||j();return c};return a},d3.layout.force=function(){function A(){!a||(b&&(c=!0,j()),z(),a.fixed=!1,a=e=null)}function z(){if(!!a){if(!e.parentNode){a.fixed=!1,a=e=null;return}var c=d3.svg.mouse(e);b=!0,a.px=c[0],a.py=c[1],d.resume()}}function y(){var a=u.length,b=v.length,c=d3.geom.quadtree(u),d,e,f,g,h,i,j;for(d=0;d<b;++d){e=v[d],f=e.source,g=e.target,i=g.x-f.x,j=g.y-f.y;if(h=i*i+j*j)h=n*((h=Math.sqrt(h))-p)/h,i*=h,j*=h,g.x-=i,g.y-=j,f.x+=i,f.y+=j}var s=n*r;i=m[0]/2,j=m[1]/2,d=-1;while(++d<a)e=u[d],e.x+=(i-e.x)*s,e.y+=(j-e.y)*s;k(c);var t=n*q;d=-1;while(++d<a)c.visit(x(u[d],t));d=-1;while(++d<a)e=u[d],e.fixed?(e.x=e.px,e.y=e.py):(e.x-=(e.px-(e.px=e.x))*o,e.y-=(e.py-(e.py=e.y))*o);l.tick.dispatch({type:"tick",alpha:n});return(n*=.99)<.005}function x(a,b){return function(c,d,e,f,g){if(c.point!=a){var h=c.cx-a.x||Math.random(),i=c.cy-a.y||Math.random(),j=1/Math.sqrt(h*h+i*i);if((f-d)*j<s){var k=b*c.count*j*j;a.x+=h*k,a.y+=i*k;return!0}if(c.point){var k=b*j*j;a.x+=h*k,a.y+=i*k}}}}var d={},l=d3.dispatch("tick"),m=[1,1],n,o=.9,p=20,q=-30,r=.1,s=.8,t,u,v,w;d.on=function(a,b){l[a].add(b);return d},d.nodes=function(a){if(!arguments.length)return u;u=a;return d},d.links=function(a){if(!arguments.length)return v;v=a;return d},d.size=function(a){if(!arguments.length)return m;m=a;return d},d.distance=function(a){if(!arguments.length)return p;p=a;return d},d.drag=function(a){if(!arguments.length)return o;o=a;return d},d.charge=function(a){if(!arguments.length)return q;q=a;return d},d.gravity=function(a){if(!arguments.length)return r;r=a;return d},d.theta=function(a){if(!arguments.length)return s;s=a;return d},d.start=function(){function k(){if(!h){h=[];for(b=0;b<c;++b)h[b]=[];for(b=0;b<e;++b){var d=v[b];h[d.source.index].push(d.target),h[d.target.index].push(d.source)}}return h[a]}function j(b,c){var d=k(a),e=-1,f=d.length,g;while(++e<f)if(!isNaN(g=d[e][b]))return g;return Math.random()*c}var a,b,c=u.length,e=v.length,f=m[0],g=m[1],h,i;for(a=0;a<c;++a)(i=u[a]).index=a;for(a=0;a<e;++a)i=v[a],typeof i.source=="number"&&(i.source=u[i.source]),typeof i.target=="number"&&(i.target=u[i.target]);for(a=0;a<c;++a)i=u[a],isNaN(i.x)&&(i.x=j("x",f)),isNaN(i.y)&&(i.y=j("y",g)),isNaN(i.px)&&(i.px=i.x),isNaN(i.py)&&(i.py=i.y);return d.resume()},d.resume=function(){n=.1,d3.timer(y);return d},d.stop=function(){n=0;return d},d.drag=function(){this.on("mouseover.force",f).on("mouseout.force",g).on("mousedown.force",h),d3.select(window).on("mousemove.force",z).on("mouseup.force",A,!0).on("click.force",i,!0);return d};return d};var a,b,c,e;d3.layout.partition=function(){function e(e,f){var g=a.call(this,e,f);c(g[0],0,b[0],b[1]/d(g[0]));return g}function d(a){var b=a.children,c=0;if(b){var e=-1,f=b.length;while(++e<f)c=Math.max(c,d(b[e]))}return 1+c}function c(a,b,d,e){var f=a.children;a.x=b,a.y=a.depth*e,a.dx=d,a.dy=e;if(f){var g=-1,h=f.length,i,j;d/=a.value;while(++g<h)c(i=f[g],b,j=i.value*d,e),b+=j}}var a=d3.layout.hierarchy(),b=[1,1];e.sort=d3.rebind(e,a.sort),e.children=d3.rebind(e,a.children),e.value=d3.rebind(e,a.value),e.size=function(a){if(!arguments.length)return b;b=a;return e};return e},d3.layout.pie=function(){function f(f,g){var h=+(typeof c=="function"?c.apply(this,arguments):c),i=(typeof e=="function"?e.apply(this,arguments):e)-c,j=d3.range(f.length);b!=null&&j.sort(function(a,c){return b(f[a],f[c])});var k=f.map(a);i/=k.reduce(function(a,b){return a+b},0);var l=j.map(function(a){return{value:d=k[a],startAngle:h,endAngle:h+=d*i}});return f.map(function(a,b){return l[j[b]]})}var a=Number,b=null,c=0,e=2*Math.PI;f.value=function(b){if(!arguments.length)return a;a=b;return f},f.sort=function(a){if(!arguments.length)return b;b=a;return f},f.startAngle=function(a){if(!arguments.length)return c;c=a;return f},f.endAngle=function(a){if(!arguments.length)return e;e=a;return f};return f},d3.layout.stack=function(){function c(c){var d=c.length,e=c[0].length,f,g,h,i=l[a](c);m[b](c,i);for(g=0;g<e;++g)for(f=1,h=c[i[0]][g].y0;f<d;++f)c[i[f]][g].y0=h+=c[i[f-1]][g].y;return c}var a="default",b="zero";c.order=function(b){if(!arguments.length)return a;a=b;return c},c.offset=function(a){if(!arguments.length)return b;b=a;return c};return c};var l={"inside-out":function(a){var b=a.length,c,d,e=a.map(o),f=a.map(n),g=d3.range(b).sort(function(a,b){return e[a]-e[b]}),h=0,i=0,j=[],k=[];for(c=0;c<b;c++)d=g[c],h<i?(h+=f[d],j.push(d)):(i+=f[d],k.push(d));return k.reverse().concat(j)},reverse:function(a){return d3.range(a.length).reverse()},"default":function(a){return d3.range(a.length)}},m={silhouette:function(a,b){var c=a.length,d=a[0].length,e=[],f=0,g,h,i;for(h=0;h<d;++h){for(g=0,i=0;g<c;g++)i+=a[g][h].y;i>f&&(f=i),e.push(i)}for(h=0,g=b[0];h<d;++h)a[g][h].y0=(f-e[h])/2},wiggle:function(a,b){var c=a.length,d=a[0],e=d.length,f=0,g,h,i,j,k,l=b[0],m,n,o,p,q,r;a[l][0].y0=q=r=0;for(h=1;h<e;++h){for(g=0,m=0;g<c;++g)m+=a[g][h].y;for(g=0,n=0,p=d[h].x-d[h-1].x;g<c;++g){for(i=0,j=b[g],o=(a[j][h].y-a[j][h-1].y)/(2*p);i<g;++i)o+=(a[k=b[i]][h].y-a[k][h-1].y)/p;n+=o*a[j][h].y}a[l][h].y0=q-=m?n/m*p:0,q<r&&(r=q)}for(h=0;h<e;++h)a[l][h].y0-=r},zero:function(a,b){var c=0,d=a[0].length,e=b[0];for(;c<d;++c)a[e][c].y0=0}};d3.layout.hierarchy=function(){function g(a){var b=[];e(a,0,b);return b}function f(a,b){var d=a.children,e=0;if(d){var h=-1,i=d.length,j=b+1;while(++h<i)e+=f(d[h],j)}else c&&(e=c.call(g,a.data,b));c&&(a.value=e);return e}function e(f,h,i){var j=b.call(g,f,h),k={depth:h,data:f};i.push(k);if(j){var l=-1,m=j.length,n=k.children=[],o=0,p=h+1;while(++l<m)d=e(j[l],p,i),d.parent=k,n.push(d),o+=d.value;a&&n.sort(a),c&&(k.value=o)}else c&&(k.value=c.call(g,f,h));return k}var a=s,b=q,c=r;g.sort=function(b){if(!arguments.length)return a;a=b;return g},g.children=function(a){if(!arguments.length)return b;b=a;return g},g.value=function(a){if(!arguments.length)return c;c=a;return g},g.revalue=function(a){f(a,0);return a};return g},d3.layout.pack=function(){function c(c,d){var e=a.call(this,c,d),f=e[0];f.x=0,f.y=0,A(f);var g=b[0],h=b[1],i=1/Math.max(2*f.r/g,2*f.r/h);B(f,g/2,h/2,i);return e}var a=d3.layout.hierarchy(),b=[1,1];c.sort=d3.rebind(c,a.sort),c.children=d3.rebind(c,a.children),c.value=d3.rebind(c,a.value),c.size=function(a){if(!arguments.length)return b;b=a;return c};return c.sort(t)},d3.layout.cluster=function(){function d(d,e){var f=a.call(this,d,e),g=f[0],h,i=0,j,k;P(g,function(a){a.children?(a.x=E(a.children),a.y=D(a.children)):(a.x=h?i+=b(a,h):0,a.y=0,h=a)});var l=F(g),m=G(g),n=l.x-b(l,m)/2,o=m.x+b(m,l)/2;P(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=(1-a.y/g.y)*c[1]});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=I,c=[1,1];d.sort=d3.rebind(d,a.sort),d.children=d3.rebind(d,a.children),d.links=H,d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return d},d3.layout.tree=function(){function d(d,e){function j(a,c,d){if(c){var e=a,f=a,g=c,h=a.parent.children[0],i=e._tree.mod,j=f._tree.mod,k=g._tree.mod,l=h._tree.mod,m;while(g=K(g),e=J(e),g&&e)h=J(h),f=K(f),f._tree.ancestor=a,m=g._tree.prelim+k-e._tree.prelim-i+b(g,e),m>0&&(R(S(g,a,d),a,m),i+=m,j+=m),k+=g._tree.mod,i+=e._tree.mod,l+=h._tree.mod,j+=f._tree.mod;g&&!K(f)&&(f._tree.thread=g,f._tree.mod+=k-j),e&&!J(h)&&(h._tree.thread=e,h._tree.mod+=i-l,d=a)}return d}function i(a,b){a.x=a._tree.prelim+b;var c=a.children;if(c){var d=-1,e=c.length;b+=a._tree.mod;while(++d<e)i(c[d],b)}}function h(a,c){var d=a.children,e=a._tree;if(d){var f=d.length,g=d[0],i,k=g,l,m=-1;while(++m<f)l=d[m],h(l,i),k=j(l,i,k),i=l;Q(a);var n=.5*(g._tree.prelim+l._tree.prelim);c?(e.prelim=c._tree.prelim+b(a,c),e.mod=e.prelim-n):e.prelim=n}else c&&(e.prelim=c._tree.prelim+b(a,c))}var f=a.call(this,d,e),g=f[0];P(g,function(a,b){a._tree={ancestor:a,prelim:0,mod:0,change:0,shift:0,number:b?b._tree.number+1:0}}),h(g),i(g,-g._tree.prelim);var k=L(g,N),l=L(g,M),m=L(g,O),n=k.x-b(k,l)/2,o=l.x+b(l,k)/2,p=m.depth;P(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=a.depth/p*c[1],delete a._tree});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=I,c=[1,1];d.sort=d3.rebind(d,a.sort),d.children=d3.rebind(d,a.children),d.links=H,d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return d},d3.layout.treemap=function(){function k(b){var i=e||a(b),j=i[0];j.x=0,j.y=0,j.dx=c[0],j.dy=c[1],e&&a.revalue(j),f(j,c[0]*c[1]/j.value),(e?h:g)(j),d&&(e=i);return i}function j(a,c,d,e){var f=-1,g=a.length,h=d.x,i=d.y,j=c?b(a.area/c):0,k;if(c==d.dx){if(e||j>d.dy)j=d.dy;while(++f<g)k=a[f],k.x=h,k.y=i,k.dy=j,h+=k.dx=b(k.area/j);k.z=!0,k.dx+=d.x+d.dx-h,d.y+=j,d.dy-=j}else{if(e||j>d.dx)j=d.dx;while(++f<g)k=a[f],k.x=h,k.y=i,k.dx=j,i+=k.dy=b(k.area/j);k.z=!1,k.dy+=d.y+d.dy-i,d.x+=j,d.dx-=j}}function i(a,b){var c=a.area,d,e=0,f=Infinity,g=-1,h=a.length;while(++g<h)d=a[g].area,d<f&&(f=d),d>e&&(e=d);c*=c,b*=b;return Math.max(b*e/c,c/(b*f))}function h(a){if(!!a.children){var b={x:a.x,y:a.y,dx:a.dx,dy:a.dy},c=a.children.slice(),d,e=[];e.area=0;while(d=c.pop())e.push(d),e.area+=d.area,d.z!=null&&(j(e,d.z?b.dx:b.dy,b,!c.length),e.length=e.area=0);a.children.forEach(h)}}function g(a){if(!!a.children){var b={x:a.x,y:a.y,dx:a.dx,dy:a.dy},c=[],d=a.children.slice(),e,f=Infinity,h,k=Math.min(b.dx,b.dy),l;c.area=0;while((l=d.length)>0)c.push(e=d[l-1]),c.area+=e.area,(h=i(c,k))<=f?(d.pop(),f=h):(c.area-=c.pop().area,j(c,k,b,!1),k=Math.min(b.dx,b.dy),c.length=c.area=0,f=Infinity);c.length&&(j(c,k,b,!0),c.length=c.area=0),a.children.forEach(g)}}function f(a,b){var c=a.children;a.area=a.value*b;if(c){var d=-1,e=c.length;while(++d<e)f(c[d],b)}}var a=d3.layout.hierarchy(),b=Math.round,c=[1,1],d=!1,e;k.sort=d3.rebind(k,a.sort),k.children=d3.rebind(k,a.children),k.value=d3.rebind(k,a.value),k.size=function(a){if(!arguments.length)return c;c=a;return k},k.round=function(a){if(!arguments.length)return b!=Number;b=a?Math.round:Number;return k},k.sticky=function(a){if(!arguments.length)return d;d=a,e=null;return k};return k}})()
<ide>\ No newline at end of file
<ide><path>d3.min.js
<del>(function(){function bS(){return"circle"}function bR(){return 64}function bP(a){return[a.x,a.y]}function bO(a){return a.endAngle}function bN(a){return a.startAngle}function bM(a){return a.radius}function bL(a){return a.target}function bK(a){return a.source}function bJ(){return 0}function bI(a,b,c){a.push("C",bE(bF,b),",",bE(bF,c),",",bE(bG,b),",",bE(bG,c),",",bE(bH,b),",",bE(bH,c))}function bE(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}function bD(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=[bE(bH,g),",",bE(bH,h)],--c;while(++c<e)f=a[c%d],g.shift(),g.push(f[0]),h.shift(),h.push(f[1]),bI(b,g,h);return b.join("")}function bC(a){if(a.length<3)return bv(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),bI(b,h,i);while(++c<d)e=a[c],h.shift(),h.push(e[0]),i.shift(),i.push(e[1]),bI(b,h,i);c=-1;while(++c<2)h.shift(),h.push(e[0]),i.shift(),i.push(e[1]),bI(b,h,i);return b.join("")}function bB(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 bA(a,b){if(b.length<1||a.length!=b.length&&a.length!=b.length+2)return bv(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 bz(a,b,c){return a.length<3?bv(a):a[0]+bA(a,bB(a,b))}function by(a,b){return a.length<3?bv(a):a[0]+bA((a.push(a[0]),a),bB([a[a.length-2]].concat(a,[a[1]]),b))}function bx(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 bw(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 bv(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 bt(a){return a[1]}function bs(a){return a[0]}function br(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 bq(a){return a.endAngle}function bp(a){return a.startAngle}function bo(a){return a.outerRadius}function bn(a){return a.innerRadius}function bg(a){return function(b){return-Math.pow(-b,a)}}function bf(a){return function(b){return Math.pow(b,a)}}function be(a){return-Math.log(-a)/Math.LN10}function bd(a){return Math.log(a)/Math.LN10}function bb(){var a=null,b=Y,c=Infinity;while(b)b.flush?b=a?a.next=b.next:Y=b.next:(c=Math.min(c,b.then+b.delay),b=(a=b).next);return c}function ba(){var a,b=Date.now(),c=null,d=Y;while(d)a=b-d.then,a>d.delay&&(d.flush=d.callback(a)),d=(c=d).next;var e=bb()-b;e>24?(isFinite(e)&&(clearTimeout($),$=setTimeout(ba,e)),Z=0):(Z=1,bc(ba))}function _(a,b){var c=Date.now(),d=!1,e,f=Y;if(!!isFinite(b)){while(f){if(f.callback===a){f.then=c,f.delay=b,d=!0;break}e=f,f=f.next}d||(Y={callback:a,then:c,delay:b,next:Y}),Z||($=clearTimeout($),Z=1,bc(ba))}}function X(a){return typeof a=="function"?function(b,c,d){return d3.interpolate(d,String(a.call(this,b,c)))}:(a=String(a),function(b,c,d){return d3.interpolate(d,a)})}function W(a){function n(b){var g=!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){g=!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,h.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.removeChild(this)),V=c,h.end.dispatch.apply(this,arguments),V=0,n.owner=r}}}});return g}var b={},c=V||++U,d={},e=[],f=!1,h=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})),_(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 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 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,X(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 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,X(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=W(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=W(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){h[a].add(c);return b},b.call=g;return b.delay(0).duration(250)}function T(a){return{__data__:a}}function S(a){arguments.length||(a=d3.ascending);return function(b,c){return a(b&&b.__data__,c&&c.__data__)}}function R(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 Q(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),N(c,b))}function d(b){return b.insertBefore(document.createElement(a),N(c,b))}a=d3.ns.qualify(a);return b(a.local?e:d)};return a}function Q(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 Q(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 Q(c)}a.select=function(a){return b(function(b){return N(a,b)})},a.selectAll=function(a){return c(function(b){return O(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 Q(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++]=a[g]: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]=T(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]=T(p),l[g]=n[g]=null);for(;g<i;g++)m[g]=T(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=Q(e);k.enter=function(){return R(d)},k.exit=function(){return Q(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);if(arguments.length<2)return d(b.local?function(){return this.getAttributeNS(b.space,b.local)}:function(){return this.getAttribute(b)});return 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)?g:h).call(this)}function h(){var a=f(this.className.replace(e," "));this.className=a.length?a:null}function g(){var a=this.className;e.lastIndex=0,e.test(a)||(this.className=f(a+" "+b))}var e=new RegExp("(^|\\s+)"+d3.requote(b)+"(\\s+|$)","g");if(arguments.length<2)return d(function(){e.lastIndex=0;return e.test(this.className)});return a.each(typeof c=="function"?i:c?g: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="");if(arguments.length<2)return d(function(){return window.getComputedStyle(this,null).getPropertyValue(b)});return 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);if(arguments.length<2)return d(function(){return this[b]});return 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}if(arguments.length<1)return d(function(){return this.textContent});return a.each(typeof b=="function"?e:c)},a.html=function(b){function e(){this.innerHTML=b.apply(this,arguments)}function c(){this.innerHTML=b}if(arguments.length<1)return d(function(){return this.innerHTML});return 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),N(c,b))}function d(b){return b.insertBefore(document.createElement(a),N(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=S.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 e(d){var e=d3.event;d3.event=d;try{c.call(this,a,b)}finally{d3.event=e}}this[g]&&this.removeEventListener(f,this[g],d),c&&this.addEventListener(f,this[g]=e,d)})},a.transition=function(){return W(a)},a.call=g;return a}function M(a,b,c){function g(a){return Math.round(f(a)*255)}function f(a){a>360?a-=360:a<0&&(a+=360);if(a<60)return d+(e-d)*a/60;if(a<180)return e;if(a<240)return d+(e-d)*(240-a)/60;return 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 C(g(a+120),g(a),g(a-120))}function L(){return"hsl("+this.h+","+this.s*100+"%,"+this.l*100+"%)"}function K(a,b,c){return{h:a,s:b,l:c,toString:L}}function H(a){var b=parseFloat(a);return a.charAt(a.length-1)=="%"?Math.round(b*2.55):b}function G(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 K(g,h,i)}function F(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(H(h[0]),H(h[1]),H(h[2]))}}if(i=I[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 E(a){return a<16?"0"+a.toString(16):a.toString(16)}function D(){return"#"+E(this.r)+E(this.g)+E(this.b)}function C(a,b,c){return{r:a,g:b,b:c,toString:D}}function B(a){return a in A||/\bcolor\b/.test(a)?d3.interpolateRgb:d3.interpolate}function y(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 x(a){a||(a=1.70158);return function(b){return b*b*((a+1)*b-a)}}function w(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 v(a){return 1-Math.sqrt(1-a*a)}function u(a){return a?Math.pow(2,10*(a-1))-.001:0}function t(a){return 1-Math.cos(a*Math.PI/2)}function s(a){return function(b){return Math.pow(b,a)}}function r(a){return a}function q(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}}function p(a){return function(b){return 1-a(1-b)}}function k(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 i(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 g(a){a.apply(this,(arguments[0]=this,arguments));return this}function f(a){return a.replace(/(^\s+)|(\s+$)/g,"").replace(/\s+/g," ")}function e(a){return a==null}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.13.2"},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:0},d3.descending=function(a,b){return b<a?-1:b>a?1:0},d3.min=function(a,b){var c=0,d=a.length,e=a[0],f;if(arguments.length==1)while(++c<d)e>(f=a[c])&&(e=f);else{e=b(a[0]);while(++c<d)e>(f=b(a[c]))&&(e=f)}return e},d3.max=function(a,b){var c=0,d=a.length,e=a[0],f;if(arguments.length==1)while(++c<d)e<(f=a[c])&&(e=f);else{e=b(e);while(++c<d)e<(f=b(a[c]))&&(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.merge=function(a){return Array.prototype.concat.apply([],a)},d3.split=function(a,b){var c=[],d=[],f,g=-1,h=a.length;arguments.length<2&&(b=e);while(++g<h)b.call(d,f=a[g],g)?d=[]:(d.length||c.push(d),d.push(f));return c},d3.range=function(a,b,c){arguments.length==1&&(b=a,a=0),c==null&&(c=1);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(h,"\\$&")};var h=/[\\\^\$\*\+\?\[\]\(\)\.\{\}]/g;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]=i(c);return b},d3.format=function(a){var b=j.exec(a),c=b[1]||" ",d=b[3]||"",e=b[5],f=+b[6],g=b[7],h=b[8],i=b[9];h&&(h=h.substring(1)),e&&(c="0",g&&(f-=Math.floor((f-1)/4))),i=="d"&&(h="0");return function(a){var b=+a,j=b<0&&(b=-b)?"−":d;if(i=="d"&&b%1)return"";h?a=b.toFixed(h):a=""+b;if(e){var l=a.length+j.length;l<f&&(a=Array(f-l+1).join(c)+a),g&&(a=k(a)),a=j+a}else{g&&(a=k(a)),a=j+a;var l=a.length;l<f&&(a=Array(f-l+1).join(c)+a)}return a}};var j=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,l=s(2),m=s(3),n={linear:function(){return r},poly:s,quad:function(){return l},cubic:function(){return m},sin:function(){return t},exp:function(){return u},circle:function(){return v},elastic:w,back:x,bounce:function(){return y}},o={"in":function(a){return a},out:p,"in-out":q,"out-in":function(a){return q(p(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 o[d](n[c].apply(null,Array.prototype.slice.call(arguments,1)))},d3.event=null,d3.interpolate=function(a,b){if(typeof b=="number")return d3.interpolateNumber(+a,b);if(typeof b=="string")return b in I||/^(#|rgb\(|hsl\()/.test(b)?d3.interpolateRgb(String(a),b):d3.interpolateString(String(a),b);if(b instanceof Array)return d3.interpolateArray(a,b);return d3.interpolateObject(a,b)},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;z.lastIndex=0;for(d=0;c=z.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=z.lastIndex;f<b.length&&h.push(b.substring(f));for(d=0,j=i.length;(c=z.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--;if(h.length==1)return h[0]==null?i[0].x:function(){return b};return 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 M(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]=B(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 z=/[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g,A={background:1,fill:1,stroke:1};d3.rgb=function(a,b,c){return arguments.length==1?F(""+a,C,M):C(~~a,~~b,~~c)};var I={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",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 J in I)I[J]=F(I[J],C,M);d3.hsl=function(a,b,c){return arguments.length==1?F(""+a,G,K):K(+a,+b,+c)};var N=function(a,b){return b.querySelector(a)},O=function(b,c){return a(c.querySelectorAll(b))};typeof Sizzle=="function"&&(N=function(a,b){return Sizzle(a,b)[0]},O=function(a,b){return Sizzle.uniqueSort(Sizzle(a,b))});var P=Q([[document]]);P[0].parentNode=document.documentElement,d3.select=function(a){return typeof a=="string"?P.select(a):Q([[a]])},d3.selectAll=function(b){return typeof b=="string"?P.selectAll(b):Q([a(b)])},d3.transition=P.transition;var U=0,V=0,Y=null,Z,$;d3.timer=function(a){_(a,0)};var bc=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,17)};d3.scale={},d3.scale.linear=function(){function k(c){var d=Math.min(a,b),e=Math.max(a,b),f=e-d,g=Math.pow(10,Math.floor(Math.log(f/c)/Math.LN10)),h=c/(f/g);h<=.15?g*=10:h<=.35?g*=5:h<=.75&&(g*=2);return{start:Math.ceil(d/g)*g,stop:Math.floor(e/g)*g+g*.5,step:g}}function j(b){b=(b-a)*e;return h(i?Math.max(0,Math.min(1,b)):b)}var a=0,b=1,c=0,d=1,e=1,f=1,g=d3.interpolate,h=g(c,d),i=!1;j.invert=function(b){return(b-c)*f+a},j.domain=function(g){if(!arguments.length)return[a,b];a=+g[0],b=+g[1],e=1/(b-a),f=(b-a)/(d-c);return j},j.range=function(e){if(!arguments.length)return[c,d];c=e[0],d=e[1],f=(b-a)/(d-c),h=g(c,d);return j},j.rangeRound=function(a){return j.range(a).interpolate(d3.interpolateRound)},j.clamp=function(a){if(!arguments.length)return i;i=a;return j},j.interpolate=function(a){if(!arguments.length)return g;h=(g=a)(c,d);return j},j.ticks=function(a){var b=k(a);return d3.range(b.start,b.stop,b.step)},j.tickFormat=function(a){var b=Math.max(0,-Math.floor(Math.log(k(a).step)/Math.LN10+.01));return d3.format(",."+b+"f")};return j},d3.scale.log=function(){function d(c){return a(b(c))}var a=d3.scale.linear(),b=bd,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]||e[1])<0?be:bd,c=b.pow,a.domain(e.map(b));return d},d.range=d3.rebind(d,a.range),d.rangeRound=d3.rebind(d,a.rangeRound),d.interpolate=d3.rebind(d,a.interpolate),d.clamp=d3.rebind(d,a.clamp),d.ticks=function(){var d=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===be){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 function(a){return a.toPrecision(1)}};return d},bd.pow=function(a){return Math.pow(10,a)},be.pow=function(a){return-Math.pow(10,-a)},d3.scale.pow=function(){function f(b){return a(d(b))}var a=d3.scale.linear(),b=d3.scale.linear(),c=1,d=Number,e=d;f.invert=function(b){return e(a.invert(b))},f.domain=function(g){if(!arguments.length)return a.domain().map(e);var h=(g[0]||g[1])<0?bg:bf;d=h(c),e=h(1/c),a.domain(g.map(d)),b.domain(g);return f},f.range=d3.rebind(f,a.range),f.rangeRound=d3.rebind(f,a.rangeRound),f.interpolate=d3.rebind(f,a.interpolate),f.clamp=d3.rebind(f,a.clamp),f.ticks=b.ticks,f.tickFormat=b.tickFormat,f.exponent=function(a){if(!arguments.length)return c;var b=f.domain();c=a;return f.domain(b)};return f},d3.scale.sqrt=function(){return d3.scale.pow().exponent(.5)},d3.scale.ordinal=function(){function e(d){var e=d in b?b[d]:b[d]=a.push(d)-1;return c[e%c.length]}var a=[],b={},c=[],d=0;e.domain=function(c){if(!arguments.length)return a;a=c,b={};var d=-1,f=-1,g=a.length;while(++d<g)c=a[d],c in b||(b[c]=++f);return e},e.range=function(a){if(!arguments.length)return c;c=a;return e},e.rangePoints=function(b,f){arguments.length<2&&(f=0);var g=b[0],h=b[1],i=(h-g)/(a.length-1+f);c=a.length==1?[(g+h)/2]:d3.range(g+i*f/2,h+i/2,i),d=0;return e},e.rangeBands=function(b,f){arguments.length<2&&(f=0);var g=b[0],h=b[1],i=(h-g)/(a.length+f);c=d3.range(g+i*f,h,i),d=i*(1-f);return e},e.rangeRoundBands=function(b,f){arguments.length<2&&(f=0);var g=b[0],h=b[1],i=h-g,j=Math.floor(i/(a.length+f)),k=i-(a.length-f)*j;c=d3.range(g+Math.round(k/2),h,j),d=Math.round(j*(1-f));return e},e.rangeBand=function(){return d};return e},d3.scale.category10=function(){return d3.scale.ordinal().range(bh)},d3.scale.category20=function(){return d3.scale.ordinal().range(bi)},d3.scale.category20b=function(){return d3.scale.ordinal().range(bj)},d3.scale.category20c=function(){return d3.scale.ordinal().range(bk)};var bh=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],bi=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],bj=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],bk=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];d3.scale.quantile=function(){function f(a){return b[e(a)]}function e(a){if(isNaN(a=+a))return NaN;var b=0,d=c.length-1;while(b<=d){var e=b+d>>1,f=c[e];if(f<a)b=e+1;else if(f>a)d=e-1;else return e}return d<0?0:d}function d(){var d=-1,e=c.length=b.length,f=a.length/e;while(++d<e)c[d]=a[~~(d*f)]}var a=[],b=[],c=[];f.domain=function(b){if(!arguments.length)return a;a=b.filter(function(a){return!isNaN(a)}).sort(d3.ascending),d();return f},f.range=function(a){if(!arguments.length)return b;b=a,d();return f},f.quantiles=function(){return c};return f},d3.scale.quantize=function(){function f(b){return e[Math.max(0,Math.min(d,Math.floor(c*(b-a))))]}var a=0,b=1,c=2,d=1,e=[0,1];f.domain=function(d){if(!arguments.length)return[a,b];a=d[0],b=d[1],c=e.length/(b-a);return f},f.range=function(g){if(!arguments.length)return e;e=g,c=e.length/(b-a),d=e.length-1;return f};return f},d3.svg={},d3.svg.arc=function(){function e(){var e=a.apply(this,arguments),f=b.apply(this,arguments),g=c.apply(this,arguments)+bl,h=d.apply(this,arguments)+bl,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>=bm?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=bn,b=bo,c=bp,d=bq;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+bl;return[Math.cos(f)*e,Math.sin(f)*e]};return e};var bl=-Math.PI/2,bm=2*Math.PI-1e-6;d3.svg.line=function(){function f(c){return c.length<1?null:"M"+d(br(this,c,a,b),e)}var a=bs,b=bt,c="linear",d=bu[c],e=.7;f.x=function(b){if(!arguments.length)return a;a=b;return f},f.y=function(a){if(!arguments.length)return b;b=a;return f},f.interpolate=function(a){if(!arguments.length)return c;d=bu[c=a];return f},f.tension=function(a){if(!arguments.length)return e;e=a;return f};return f};var bu={linear:bv,"step-before":bw,"step-after":bx,basis:bC,"basis-closed"
<add>(function(){function bS(){return"circle"}function bR(){return 64}function bP(a){return[a.x,a.y]}function bO(a){return a.endAngle}function bN(a){return a.startAngle}function bM(a){return a.radius}function bL(a){return a.target}function bK(a){return a.source}function bJ(){return 0}function bI(a,b,c){a.push("C",bE(bF,b),",",bE(bF,c),",",bE(bG,b),",",bE(bG,c),",",bE(bH,b),",",bE(bH,c))}function bE(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}function bD(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=[bE(bH,g),",",bE(bH,h)],--c;while(++c<e)f=a[c%d],g.shift(),g.push(f[0]),h.shift(),h.push(f[1]),bI(b,g,h);return b.join("")}function bC(a){if(a.length<3)return bv(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),bI(b,h,i);while(++c<d)e=a[c],h.shift(),h.push(e[0]),i.shift(),i.push(e[1]),bI(b,h,i);c=-1;while(++c<2)h.shift(),h.push(e[0]),i.shift(),i.push(e[1]),bI(b,h,i);return b.join("")}function bB(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 bA(a,b){if(b.length<1||a.length!=b.length&&a.length!=b.length+2)return bv(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 bz(a,b,c){return a.length<3?bv(a):a[0]+bA(a,bB(a,b))}function by(a,b){return a.length<3?bv(a):a[0]+bA((a.push(a[0]),a),bB([a[a.length-2]].concat(a,[a[1]]),b))}function bx(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 bw(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 bv(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 bt(a){return a[1]}function bs(a){return a[0]}function br(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 bq(a){return a.endAngle}function bp(a){return a.startAngle}function bo(a){return a.outerRadius}function bn(a){return a.innerRadius}function bg(a){return function(b){return-Math.pow(-b,a)}}function bf(a){return function(b){return Math.pow(b,a)}}function be(a){return-Math.log(-a)/Math.LN10}function bd(a){return Math.log(a)/Math.LN10}function bb(){var a=null,b=Y,c=Infinity;while(b)b.flush?b=a?a.next=b.next:Y=b.next:(c=Math.min(c,b.then+b.delay),b=(a=b).next);return c}function ba(){var a,b=Date.now(),c=null,d=Y;while(d)a=b-d.then,a>d.delay&&(d.flush=d.callback(a)),d=(c=d).next;var e=bb()-b;e>24?(isFinite(e)&&(clearTimeout($),$=setTimeout(ba,e)),Z=0):(Z=1,bc(ba))}function _(a,b){var c=Date.now(),d=!1,e,f=Y;if(!!isFinite(b)){while(f){if(f.callback===a){f.then=c,f.delay=b,d=!0;break}e=f,f=f.next}d||(Y={callback:a,then:c,delay:b,next:Y}),Z||($=clearTimeout($),Z=1,bc(ba))}}function X(a){return typeof a=="function"?function(b,c,d){return d3.interpolate(d,String(a.call(this,b,c)))}:(a=String(a),function(b,c,d){return d3.interpolate(d,a)})}function W(a){function n(b){var g=!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){g=!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,h.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.removeChild(this)),V=c,h.end.dispatch.apply(this,arguments),V=0,n.owner=r}}}});return g}var b={},c=V||++U,d={},e=[],f=!1,h=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})),_(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 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 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,X(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 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,X(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=W(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=W(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){h[a].add(c);return b},b.call=g;return b.delay(0).duration(250)}function T(a){return{__data__:a}}function S(a){arguments.length||(a=d3.ascending);return function(b,c){return a(b&&b.__data__,c&&c.__data__)}}function R(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 Q(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),N(c,b))}function d(b){return b.insertBefore(document.createElement(a),N(c,b))}a=d3.ns.qualify(a);return b(a.local?e:d)};return a}function Q(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 Q(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 Q(c)}a.select=function(a){return b(function(b){return N(a,b)})},a.selectAll=function(a){return c(function(b){return O(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 Q(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++]=a[g]: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]=T(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]=T(p),l[g]=n[g]=null);for(;g<i;g++)m[g]=T(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=Q(e);k.enter=function(){return R(d)},k.exit=function(){return Q(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);if(arguments.length<2)return d(b.local?function(){return this.getAttributeNS(b.space,b.local)}:function(){return this.getAttribute(b)});return 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)?g:h).call(this)}function h(){var a=f(this.className.replace(e," "));this.className=a.length?a:null}function g(){var a=this.className;e.lastIndex=0,e.test(a)||(this.className=f(a+" "+b))}var e=new RegExp("(^|\\s+)"+d3.requote(b)+"(\\s+|$)","g");if(arguments.length<2)return d(function(){e.lastIndex=0;return e.test(this.className)});return a.each(typeof c=="function"?i:c?g: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="");if(arguments.length<2)return d(function(){return window.getComputedStyle(this,null).getPropertyValue(b)});return 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);if(arguments.length<2)return d(function(){return this[b]});return 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}if(arguments.length<1)return d(function(){return this.textContent});return a.each(typeof b=="function"?e:c)},a.html=function(b){function e(){this.innerHTML=b.apply(this,arguments)}function c(){this.innerHTML=b}if(arguments.length<1)return d(function(){return this.innerHTML});return 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),N(c,b))}function d(b){return b.insertBefore(document.createElement(a),N(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=S.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 e(d){var e=d3.event;d3.event=d;try{c.call(this,a,b)}finally{d3.event=e}}this[g]&&this.removeEventListener(f,this[g],d),c&&this.addEventListener(f,this[g]=e,d)})},a.transition=function(){return W(a)},a.call=g;return a}function M(a,b,c){function g(a){return Math.round(f(a)*255)}function f(a){a>360?a-=360:a<0&&(a+=360);if(a<60)return d+(e-d)*a/60;if(a<180)return e;if(a<240)return d+(e-d)*(240-a)/60;return 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 C(g(a+120),g(a),g(a-120))}function L(){return"hsl("+this.h+","+this.s*100+"%,"+this.l*100+"%)"}function K(a,b,c){return{h:a,s:b,l:c,toString:L}}function H(a){var b=parseFloat(a);return a.charAt(a.length-1)=="%"?Math.round(b*2.55):b}function G(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 K(g,h,i)}function F(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(H(h[0]),H(h[1]),H(h[2]))}}if(i=I[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 E(a){return a<16?"0"+a.toString(16):a.toString(16)}function D(){return"#"+E(this.r)+E(this.g)+E(this.b)}function C(a,b,c){return{r:a,g:b,b:c,toString:D}}function B(a){return a in A||/\bcolor\b/.test(a)?d3.interpolateRgb:d3.interpolate}function y(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 x(a){a||(a=1.70158);return function(b){return b*b*((a+1)*b-a)}}function w(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 v(a){return 1-Math.sqrt(1-a*a)}function u(a){return a?Math.pow(2,10*(a-1))-.001:0}function t(a){return 1-Math.cos(a*Math.PI/2)}function s(a){return function(b){return Math.pow(b,a)}}function r(a){return a}function q(a){return function(b){return.5*(b<.5?a(2*b):2-a(2-2*b))}}function p(a){return function(b){return 1-a(1-b)}}function k(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 i(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 g(a){a.apply(this,(arguments[0]=this,arguments));return this}function f(a){return a.replace(/(^\s+)|(\s+$)/g,"").replace(/\s+/g," ")}function e(a){return a==null}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.13.3"},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:0},d3.descending=function(a,b){return b<a?-1:b>a?1:0},d3.min=function(a,b){var c=0,d=a.length,e=a[0],f;if(arguments.length==1)while(++c<d)e>(f=a[c])&&(e=f);else{e=b(a[0]);while(++c<d)e>(f=b(a[c]))&&(e=f)}return e},d3.max=function(a,b){var c=0,d=a.length,e=a[0],f;if(arguments.length==1)while(++c<d)e<(f=a[c])&&(e=f);else{e=b(e);while(++c<d)e<(f=b(a[c]))&&(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.merge=function(a){return Array.prototype.concat.apply([],a)},d3.split=function(a,b){var c=[],d=[],f,g=-1,h=a.length;arguments.length<2&&(b=e);while(++g<h)b.call(d,f=a[g],g)?d=[]:(d.length||c.push(d),d.push(f));return c},d3.range=function(a,b,c){arguments.length==1&&(b=a,a=0),c==null&&(c=1);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(h,"\\$&")};var h=/[\\\^\$\*\+\?\[\]\(\)\.\{\}]/g;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]=i(c);return b},d3.format=function(a){var b=j.exec(a),c=b[1]||" ",d=b[3]||"",e=b[5],f=+b[6],g=b[7],h=b[8],i=b[9];h&&(h=h.substring(1)),e&&(c="0",g&&(f-=Math.floor((f-1)/4))),i=="d"&&(h="0");return function(a){var b=+a,j=b<0&&(b=-b)?"−":d;if(i=="d"&&b%1)return"";h?a=b.toFixed(h):a=""+b;if(e){var l=a.length+j.length;l<f&&(a=Array(f-l+1).join(c)+a),g&&(a=k(a)),a=j+a}else{g&&(a=k(a)),a=j+a;var l=a.length;l<f&&(a=Array(f-l+1).join(c)+a)}return a}};var j=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,l=s(2),m=s(3),n={linear:function(){return r},poly:s,quad:function(){return l},cubic:function(){return m},sin:function(){return t},exp:function(){return u},circle:function(){return v},elastic:w,back:x,bounce:function(){return y}},o={"in":function(a){return a},out:p,"in-out":q,"out-in":function(a){return q(p(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 o[d](n[c].apply(null,Array.prototype.slice.call(arguments,1)))},d3.event=null,d3.interpolate=function(a,b){if(typeof b=="number")return d3.interpolateNumber(+a,b);if(typeof b=="string")return b in I||/^(#|rgb\(|hsl\()/.test(b)?d3.interpolateRgb(String(a),b):d3.interpolateString(String(a),b);if(b instanceof Array)return d3.interpolateArray(a,b);return d3.interpolateObject(a,b)},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;z.lastIndex=0;for(d=0;c=z.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=z.lastIndex;f<b.length&&h.push(b.substring(f));for(d=0,j=i.length;(c=z.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--;if(h.length==1)return h[0]==null?i[0].x:function(){return b};return 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 M(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]=B(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 z=/[-+]?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-]?\d+)?/g,A={background:1,fill:1,stroke:1};d3.rgb=function(a,b,c){return arguments.length==1?F(""+a,C,M):C(~~a,~~b,~~c)};var I={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",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 J in I)I[J]=F(I[J],C,M);d3.hsl=function(a,b,c){return arguments.length==1?F(""+a,G,K):K(+a,+b,+c)};var N=function(a,b){return b.querySelector(a)},O=function(b,c){return a(c.querySelectorAll(b))};typeof Sizzle=="function"&&(N=function(a,b){return Sizzle(a,b)[0]},O=function(a,b){return Sizzle.uniqueSort(Sizzle(a,b))});var P=Q([[document]]);P[0].parentNode=document.documentElement,d3.select=function(a){return typeof a=="string"?P.select(a):Q([[a]])},d3.selectAll=function(b){return typeof b=="string"?P.selectAll(b):Q([a(b)])},d3.transition=P.transition;var U=0,V=0,Y=null,Z,$;d3.timer=function(a){_(a,0)};var bc=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,17)};d3.scale={},d3.scale.linear=function(){function k(c){var d=Math.min(a,b),e=Math.max(a,b),f=e-d,g=Math.pow(10,Math.floor(Math.log(f/c)/Math.LN10)),h=c/(f/g);h<=.15?g*=10:h<=.35?g*=5:h<=.75&&(g*=2);return{start:Math.ceil(d/g)*g,stop:Math.floor(e/g)*g+g*.5,step:g}}function j(b){b=(b-a)*e;return h(i?Math.max(0,Math.min(1,b)):b)}var a=0,b=1,c=0,d=1,e=1,f=1,g=d3.interpolate,h=g(c,d),i=!1;j.invert=function(b){return(b-c)*f+a},j.domain=function(g){if(!arguments.length)return[a,b];a=+g[0],b=+g[1],e=1/(b-a),f=(b-a)/(d-c);return j},j.range=function(e){if(!arguments.length)return[c,d];c=e[0],d=e[1],f=(b-a)/(d-c),h=g(c,d);return j},j.rangeRound=function(a){return j.range(a).interpolate(d3.interpolateRound)},j.clamp=function(a){if(!arguments.length)return i;i=a;return j},j.interpolate=function(a){if(!arguments.length)return g;h=(g=a)(c,d);return j},j.ticks=function(a){var b=k(a);return d3.range(b.start,b.stop,b.step)},j.tickFormat=function(a){var b=Math.max(0,-Math.floor(Math.log(k(a).step)/Math.LN10+.01));return d3.format(",."+b+"f")};return j},d3.scale.log=function(){function d(c){return a(b(c))}var a=d3.scale.linear(),b=bd,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]||e[1])<0?be:bd,c=b.pow,a.domain(e.map(b));return d},d.range=d3.rebind(d,a.range),d.rangeRound=d3.rebind(d,a.rangeRound),d.interpolate=d3.rebind(d,a.interpolate),d.clamp=d3.rebind(d,a.clamp),d.ticks=function(){var d=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===be){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 function(a){return a.toPrecision(1)}};return d},bd.pow=function(a){return Math.pow(10,a)},be.pow=function(a){return-Math.pow(10,-a)},d3.scale.pow=function(){function f(b){return a(d(b))}var a=d3.scale.linear(),b=d3.scale.linear(),c=1,d=Number,e=d;f.invert=function(b){return e(a.invert(b))},f.domain=function(g){if(!arguments.length)return a.domain().map(e);var h=(g[0]||g[1])<0?bg:bf;d=h(c),e=h(1/c),a.domain(g.map(d)),b.domain(g);return f},f.range=d3.rebind(f,a.range),f.rangeRound=d3.rebind(f,a.rangeRound),f.interpolate=d3.rebind(f,a.interpolate),f.clamp=d3.rebind(f,a.clamp),f.ticks=b.ticks,f.tickFormat=b.tickFormat,f.exponent=function(a){if(!arguments.length)return c;var b=f.domain();c=a;return f.domain(b)};return f},d3.scale.sqrt=function(){return d3.scale.pow().exponent(.5)},d3.scale.ordinal=function(){function e(d){var e=d in b?b[d]:b[d]=a.push(d)-1;return c[e%c.length]}var a=[],b={},c=[],d=0;e.domain=function(c){if(!arguments.length)return a;a=c,b={};var d=-1,f=-1,g=a.length;while(++d<g)c=a[d],c in b||(b[c]=++f);return e},e.range=function(a){if(!arguments.length)return c;c=a;return e},e.rangePoints=function(b,f){arguments.length<2&&(f=0);var g=b[0],h=b[1],i=(h-g)/(a.length-1+f);c=a.length==1?[(g+h)/2]:d3.range(g+i*f/2,h+i/2,i),d=0;return e},e.rangeBands=function(b,f){arguments.length<2&&(f=0);var g=b[0],h=b[1],i=(h-g)/(a.length+f);c=d3.range(g+i*f,h,i),d=i*(1-f);return e},e.rangeRoundBands=function(b,f){arguments.length<2&&(f=0);var g=b[0],h=b[1],i=h-g,j=Math.floor(i/(a.length+f)),k=i-(a.length-f)*j;c=d3.range(g+Math.round(k/2),h,j),d=Math.round(j*(1-f));return e},e.rangeBand=function(){return d};return e},d3.scale.category10=function(){return d3.scale.ordinal().range(bh)},d3.scale.category20=function(){return d3.scale.ordinal().range(bi)},d3.scale.category20b=function(){return d3.scale.ordinal().range(bj)},d3.scale.category20c=function(){return d3.scale.ordinal().range(bk)};var bh=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],bi=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],bj=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],bk=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];d3.scale.quantile=function(){function f(a){return b[e(a)]}function e(a){if(isNaN(a=+a))return NaN;var b=0,d=c.length-1;while(b<=d){var e=b+d>>1,f=c[e];if(f<a)b=e+1;else if(f>a)d=e-1;else return e}return d<0?0:d}function d(){var d=-1,e=c.length=b.length,f=a.length/e;while(++d<e)c[d]=a[~~(d*f)]}var a=[],b=[],c=[];f.domain=function(b){if(!arguments.length)return a;a=b.filter(function(a){return!isNaN(a)}).sort(d3.ascending),d();return f},f.range=function(a){if(!arguments.length)return b;b=a,d();return f},f.quantiles=function(){return c};return f},d3.scale.quantize=function(){function f(b){return e[Math.max(0,Math.min(d,Math.floor(c*(b-a))))]}var a=0,b=1,c=2,d=1,e=[0,1];f.domain=function(d){if(!arguments.length)return[a,b];a=d[0],b=d[1],c=e.length/(b-a);return f},f.range=function(g){if(!arguments.length)return e;e=g,c=e.length/(b-a),d=e.length-1;return f};return f},d3.svg={},d3.svg.arc=function(){function e(){var e=a.apply(this,arguments),f=b.apply(this,arguments),g=c.apply(this,arguments)+bl,h=d.apply(this,arguments)+bl,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>=bm?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=bn,b=bo,c=bp,d=bq;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+bl;return[Math.cos(f)*e,Math.sin(f)*e]};return e};var bl=-Math.PI/2,bm=2*Math.PI-1e-6;d3.svg.line=function(){function f(c){return c.length<1?null:"M"+d(br(this,c,a,b),e)}var a=bs,b=bt,c="linear",d=bu[c],e=.7;f.x=function(b){if(!arguments.length)return a;a=b;return f},f.y=function(a){if(!arguments.length)return b;b=a;return f},f.interpolate=function(a){if(!arguments.length)return c;d=bu[c=a];return f},f.tension=function(a){if(!arguments.length)return e;e=a;return f};return f};var bu={linear:bv,"step-before":bw,"step-after":bx,basis:bC,"basis-closed"
<ide> :bD,cardinal:bz,"cardinal-closed":by},bF=[0,2/3,1/3,0],bG=[0,1/3,2/3,0],bH=[0,1/6,2/3,1/6];d3.svg.area=function(){function g(d){return d.length<1?null:"M"+e(br(this,d,a,c),f)+"L"+e(br(this,d,a,b).reverse(),f)+"Z"}var a=bs,b=bJ,c=bt,d="linear",e=bu[d],f=.7;g.x=function(b){if(!arguments.length)return a;a=b;return g},g.y0=function(a){if(!arguments.length)return b;b=a;return g},g.y1=function(a){if(!arguments.length)return c;c=a;return g},g.interpolate=function(a){if(!arguments.length)return d;e=bu[d=a];return g},g.tension=function(a){if(!arguments.length)return f;f=a;return g};return g},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)+bl,k=e.call(a,h,g)+bl;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=bK,b=bL,c=bM,d=bp,e=bq;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=bK,b=bL,c=bP;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.mouse=function(a){var b=(a.ownerSVGElement||a).createSVGPoint();if(bQ<0&&(window.scrollX||window.scrollY)){var c=d3.select(document.body).append("svg:svg").style("position","absolute").style("top",0).style("left",0),d=c[0][0].getScreenCTM();bQ=!d.f&&!d.e,c.remove()}bQ?(b.x=d3.event.pageX,b.y=d3.event.pageY):(b.x=d3.event.clientX,b.y=d3.event.clientY),b=b.matrixTransform(a.getScreenCTM().inverse());return[b.x,b.y]};var bQ=/WebKit/.test(navigator.userAgent)?-1:0;d3.svg.symbol=function(){function c(c,d){return(bT[a.call(this,c,d)]||bT.circle)(b.call(this,c,d))}var a=bS,b=bR;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},d3.svg.symbolTypes=["circle","cross","diamond","square","triangle-down","triangle-up"];var bT={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*bV)),c=b*bV;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/bU),c=b*bU/2;return"M0,"+c+"L"+b+","+ -c+" "+ -b+","+ -c+"Z"},"triangle-up":function(a){var b=Math.sqrt(a/bU),c=b*bU/2;return"M0,"+ -c+"L"+b+","+c+" "+ -b+","+c+"Z"}},bU=Math.sqrt(3),bV=Math.tan(30*Math.PI/180)})()
<ide>\ No newline at end of file
<ide><path>src/core/core.js
<del>d3 = {version: "1.13.2"}; // semver
<add>d3 = {version: "1.13.3"}; // semver
<ide><path>src/layout/force.js
<ide> d3.layout.force = function() {
<ide> links,
<ide> distances;
<ide>
<del> function accumulate(quad) {
<del> var cx = 0,
<del> cy = 0;
<del> quad.count = 0;
<del> if (!quad.leaf) {
<del> quad.nodes.forEach(function(c) {
<del> accumulate(c);
<del> quad.count += c.count;
<del> cx += c.count * c.cx;
<del> cy += c.count * c.cy;
<del> });
<del> }
<del> if (quad.point) {
<del> quad.count++;
<del> cx += quad.point.x;
<del> cy += quad.point.y;
<del> }
<del> quad.cx = cx / quad.count;
<del> quad.cy = cy / quad.count;
<del> }
<del>
<ide> function repulse(node, kc) {
<ide> return function(quad, x1, y1, x2, y2) {
<ide> if (quad.point != node) {
<ide> d3.layout.force = function() {
<ide> /* Barnes-Hut criterion. */
<ide> if ((x2 - x1) * dn < theta) {
<ide> var k = kc * quad.count * dn * dn;
<del> node.fx += dx * k;
<del> node.fy += dy * k;
<add> node.x += dx * k;
<add> node.y += dy * k;
<ide> return true;
<ide> }
<ide>
<ide> if (quad.point) {
<ide> var k = kc * dn * dn;
<del> node.fx += dx * k;
<del> node.fy += dy * k;
<add> node.x += dx * k;
<add> node.y += dy * k;
<ide> }
<ide> }
<ide> };
<ide> d3.layout.force = function() {
<ide> x, // x-distance
<ide> y; // y-distance
<ide>
<del> // reset forces
<del> i = -1; while (++i < n) {
<del> (o = nodes[i]).fx = o.fy = 0;
<del> }
<del>
<ide> // gauss-seidel relaxation for links
<ide> for (i = 0; i < m; ++i) {
<ide> o = links[i];
<ide> s = o.source;
<ide> t = o.target;
<ide> x = t.x - s.x;
<ide> y = t.y - s.y;
<del> if (l = Math.sqrt(x * x + y * y)) {
<del> l = alpha * (l - distance) / l;
<add> if (l = (x * x + y * y)) {
<add> l = alpha * ((l = Math.sqrt(l)) - distance) / l;
<ide> x *= l;
<ide> y *= l;
<ide> t.x -= x;
<ide> d3.layout.force = function() {
<ide> }
<ide> }
<ide>
<del> // compute quadtree center of mass
<del> accumulate(q);
<del>
<ide> // apply gravity forces
<ide> var kg = alpha * gravity;
<ide> x = size[0] / 2;
<ide> y = size[1] / 2;
<ide> i = -1; while (++i < n) {
<ide> o = nodes[i];
<del> o.fx += (x - o.x) * kg;
<del> o.fy += (y - o.y) * kg;
<add> o.x += (x - o.x) * kg;
<add> o.y += (y - o.y) * kg;
<ide> }
<ide>
<add> // compute quadtree center of mass
<add> d3_layout_forceAccumulate(q);
<add>
<ide> // apply charge forces
<ide> var kc = alpha * charge;
<ide> i = -1; while (++i < n) {
<ide> d3.layout.force = function() {
<ide> o.x = o.px;
<ide> o.y = o.py;
<ide> } else {
<del> x = o.px - (o.px = o.x);
<del> y = o.py - (o.py = o.y);
<del> o.x += o.fx - x * drag;
<del> o.y += o.fy - y * drag;
<add> o.x -= (o.px - (o.px = o.x)) * drag;
<add> o.y -= (o.py - (o.py = o.y)) * drag;
<ide> }
<ide> }
<ide>
<del> event.tick.dispatch({type: "tick"});
<add> event.tick.dispatch({type: "tick", alpha: alpha});
<ide>
<ide> // simulated annealing, basically
<ide> return (alpha *= .99) < .005;
<ide> function d3_layout_forceCancel() {
<ide> d3.event.stopPropagation();
<ide> d3.event.preventDefault();
<ide> }
<add>
<add>function d3_layout_forceAccumulate(quad) {
<add> var cx = 0,
<add> cy = 0;
<add> quad.count = 0;
<add> if (!quad.leaf) {
<add> quad.nodes.forEach(function(c) {
<add> d3_layout_forceAccumulate(c);
<add> quad.count += c.count;
<add> cx += c.count * c.cx;
<add> cy += c.count * c.cy;
<add> });
<add> }
<add> if (quad.point) {
<add> quad.count++;
<add> cx += quad.point.x;
<add> cy += quad.point.y;
<add> }
<add> quad.cx = cx / quad.count;
<add> quad.cy = cy / quad.count;
<add>} | 6 |
Javascript | Javascript | improve euler closure performance | e3eb4e545a009b6900f2392c445c606e420294df | <ide><path>src/math/Euler.js
<ide> Object.assign( Euler.prototype, {
<ide>
<ide> setFromQuaternion: function () {
<ide>
<del> var matrix;
<add> var matrix = new Matrix4();
<ide>
<ide> return function setFromQuaternion( q, order, update ) {
<ide>
<del> if ( matrix === undefined ) matrix = new Matrix4();
<del>
<ide> matrix.makeRotationFromQuaternion( q );
<ide>
<ide> return this.setFromRotationMatrix( matrix, order, update ); | 1 |
PHP | PHP | remove old import | 5db2ae9b7619c5d49955ff1b964678ac29e267f4 | <ide><path>src/Illuminate/Routing/Controllers/Controller.php
<ide> use ReflectionClass;
<ide> use Illuminate\Routing\Router;
<ide> use Illuminate\Container\Container;
<del>use Doctrine\Common\Annotations\SimpleAnnotationReader;
<ide> use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
<ide>
<ide> class Controller { | 1 |
Go | Go | fix inspect when it returns nothing valid | 40ed10cc32fe6dbf18d13a43d42a1a9bed0df902 | <ide><path>commands.go
<ide> func (cli *DockerCli) CmdInspect(args ...string) error {
<ide> }
<ide> indented.WriteString(",")
<ide> }
<del> // Remove trailling ','
<del> indented.Truncate(indented.Len() - 1)
<ide>
<add> if indented.Len() > 0 {
<add> // Remove trailling ','
<add> indented.Truncate(indented.Len() - 1)
<add> }
<ide> fmt.Fprintf(cli.out, "[")
<ide> if _, err := io.Copy(cli.out, indented); err != nil {
<ide> return err | 1 |
PHP | PHP | use asserttag for flash_helper element tests | ef108a76c84186a09db6b818f5702f67b0dc6f40 | <ide><path>tests/TestCase/View/Helper/FlashHelperTest.php
<ide> public function testFlash() {
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $result = $this->Flash->render('notification');
<del> $result = str_replace("\r\n", "\n", $result);
<del> $expected = "<div id=\"notificationLayout\">\n\t<h1>Alert!</h1>\n\t<h3>Notice!</h3>\n\t<p>This is a test of the emergency broadcasting system</p>\n</div>";
<del> $this->assertEquals($expected, $result);
<add>
<add> $children = [
<add> ['tag' => 'h1', 'content' => 'Alert!'],
<add> ['tag' => 'h3', 'content' => 'Notice!'],
<add> ['tag' => 'p', 'content' => 'This is a test of the emergency broadcasting system']
<add> ];
<add>
<add> $expected = [
<add> 'tag' => 'div',
<add> 'id' => 'notificationLayout',
<add> 'child' => []
<add> ];
<add>
<add> $expected['child'] = ['tag' => 'h1', 'content' => 'Alert!'];
<add> $this->assertTag($expected, $result);
<add>
<add> $expected['child'] = ['tag' => 'h3', 'content' => 'Notice!'];
<add> $this->assertTag($expected, $result);
<add>
<add> $expected['child'] = ['tag' => 'p', 'content' => 'This is a test of the emergency broadcasting system'];
<add> $this->assertTag($expected, $result);
<ide> }
<ide>
<ide> /**
<ide> public function testFlashElementInAttrs() {
<ide> 'element' => 'flash_helper',
<ide> 'params' => array('title' => 'Notice!', 'name' => 'Alert!')
<ide> ));
<del> $expected = "<div id=\"notificationLayout\">\n\t<h1>Alert!</h1>\n\t<h3>Notice!</h3>\n\t<p>This is a test of the emergency broadcasting system</p>\n</div>";
<del> $this->assertTextEquals($expected, $result);
<add>
<add> $children = [
<add> ['tag' => 'h1', 'content' => 'Alert!'],
<add> ['tag' => 'h3', 'content' => 'Notice!'],
<add> ['tag' => 'p', 'content' => 'This is a test of the emergency broadcasting system']
<add> ];
<add>
<add> $expected = [
<add> 'tag' => 'div',
<add> 'id' => 'notificationLayout',
<add> 'child' => []
<add> ];
<add>
<add> $expected['child'] = ['tag' => 'h1', 'content' => 'Alert!'];
<add> $this->assertTag($expected, $result);
<add>
<add> $expected['child'] = ['tag' => 'h3', 'content' => 'Notice!'];
<add> $this->assertTag($expected, $result);
<add>
<add> $expected['child'] = ['tag' => 'p', 'content' => 'This is a test of the emergency broadcasting system'];
<add> $this->assertTag($expected, $result);
<ide> }
<ide>
<ide> /** | 1 |
Ruby | Ruby | call super setup in this test | edb69b9be3be8ea8477004625d1ddf3f3de37d77 | <ide><path>activerecord/test/cases/autosave_association_test.rb
<ide> class TestAutosaveAssociationValidationsOnAHasOneAssociation < ActiveRecord::Tes
<ide> def setup
<ide> @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?")
<ide> @pirate.create_ship(:name => 'titanic')
<add> super
<ide> end
<ide>
<ide> test "should automatically validate associations with :validate => true" do
<ide> def setup
<ide> assert [email protected]?
<ide> end
<ide>
<del> test "should not automatically validate associations without :validate => true" do
<add> test "should not automatically asd validate associations without :validate => true" do
<ide> assert @pirate.valid?
<ide> @pirate.non_validated_ship.name = ''
<ide> assert @pirate.valid? | 1 |
Python | Python | fix error handling on azure | 777ed8d4e159299991f88bf2a20cf71c1753f66c | <ide><path>libcloud/common/azure.py
<ide> def parse_error(self, msg=None):
<ide> try:
<ide> # Azure does give some meaningful errors, but is inconsistent
<ide> # Some APIs respond with an XML error. Others just dump HTML
<del> body = self.parse_body()
<del>
<del> # pylint: disable=no-member
<del> if type(body) == ET.Element:
<del> code = body.findtext(fixxpath(xpath='Code'))
<del> message = body.findtext(fixxpath(xpath='Message'))
<del> message = message.split('\n')[0]
<del> error_msg = '%s: %s' % (code, message)
<del>
<del> except MalformedResponseError:
<add> if isinstance(self.body, (str, unicode)):
<add> error_msg = self.body
<add> if 'server failed to authenticate the request' in self.body:
<add> error_msg = 'Please check your credentials are valid'
<add> else:
<add> body = self.parse_body()
<add>
<add> # pylint: disable=no-member
<add> if type(body) == ET.Element:
<add> code = body.findtext(fixxpath(xpath='Code'))
<add> message = body.findtext(fixxpath(xpath='Message'))
<add> message = message.split('\n')[0]
<add> error_msg = '%s: %s' % (code, message)
<add> except:
<ide> pass
<ide>
<ide> if msg:
<ide><path>libcloud/compute/drivers/azure.py
<ide> import os
<ide> import binascii
<ide> import multiprocessing.pool
<add>import requests
<ide>
<ide> from libcloud.utils.py3 import urlquote as url_quote
<ide> from libcloud.utils.py3 import urlunquote as url_unquote
<ide> from xml.sax.saxutils import escape as xml_escape
<ide> from httplib import (HTTPSConnection)
<ide> from libcloud.compute.drivers.azure_arm import locations_mapping
<add>from libcloud.common.types import InvalidCredsError
<ide>
<ide> if sys.version_info < (3,):
<ide> _unicode_type = unicode
<ide> def _perform_request(self, request):
<ide> action=request.path,
<ide> data=request.body, headers=request.headers,
<ide> method=request.method)
<del> if response.status == 307:
<del> #handle 307 responses
<del> response = self.connection.request(
<del> action=response.headers.get('location'),
<del> data=request.body, headers=request.headers,
<del> method=request.method)
<del> except Exception as e:
<del> raise Exception(e)
<add> except requests.exceptions.SSLError:
<add> raise InvalidCredsError('Please provide a valid SSL certificate')
<add> except:
<add> raise
<add> if response.status == 307:
<add> #handle 307 responses
<add> response = self.connection.request(
<add> action=response.headers.get('location'),
<add> data=request.body, headers=request.headers,
<add> method=request.method)
<ide> return response
<ide>
<ide> def _update_request_uri_query(self, request):
<ide> def _parse_response_body_from_xml_text(self, respbody, return_type):
<ide> parse the xml and fill all the data into a class of return_type
<ide> '''
<ide> try:
<del> doc = minidom.parseString(respbody)
<add> doc = minidom.parseString(respbody.encode('utf-8'))
<ide> except:
<ide> return ''
<ide> return_obj = return_type() | 2 |
Python | Python | fix error class instantiation | 485da7222f7f9ca9854db1a6df027b00d348d017 | <ide><path>src/transformers/tokenization_bert_japanese.py
<ide> def __init__(
<ide> try:
<ide> import fugashi
<ide> except ModuleNotFoundError as error:
<del> raise error(
<add> raise error.__class__(
<ide> "You need to install fugashi to use MecabTokenizer."
<ide> "See https://pypi.org/project/fugashi/ for installation."
<ide> )
<ide> def __init__(
<ide> try:
<ide> import ipadic
<ide> except ModuleNotFoundError as error:
<del> raise error(
<add> raise error.__class__(
<ide> "The ipadic dictionary is not installed. "
<ide> "See https://github.com/polm/ipadic-py for installation."
<ide> )
<ide> def __init__(
<ide> try:
<ide> import unidic_lite
<ide> except ModuleNotFoundError as error:
<del> raise error(
<add> raise error.__class__(
<ide> "The unidic_lite dictionary is not installed. "
<ide> "See https://github.com/polm/unidic-lite for installation."
<ide> )
<ide> def __init__(
<ide> try:
<ide> import unidic
<ide> except ModuleNotFoundError as error:
<del> raise error(
<add> raise error.__class__(
<ide> "The unidic dictionary is not installed. "
<ide> "See https://github.com/polm/unidic-py for installation."
<ide> ) | 1 |
Text | Text | update version reference | c9b42514136eb46c7bbbf2d67ae6a9ba196baa2b | <ide><path>CHANGELOG.md
<ide> This release reverts a breaking change that accidentally made it into the 1.5.1
<ide> ## Breaking Changes
<ide>
<ide> ### Upgrade to 1.5.1
<del>This version of AngularJS is problematic due to a issue during its release. Please upgrade to version 1.5.1.
<add>This version of AngularJS is problematic due to a issue during its release. Please upgrade to version [1.5.2](#1.5.2).
<ide>
<ide> - **ngAria:** due to [d06431e5](https://github.com/angular/angular.js/commit/d06431e5309bb0125588877451dc79b935808134),
<ide> Where appropriate, ngAria now applies ARIA to custom controls only, not native inputs. Because of this, support for `aria-multiline` on textareas has been removed. | 1 |
Javascript | Javascript | fix typo in debug statement | 6e56badf18c5af100ef6c4c461e1ed795229bd91 | <ide><path>lib/internal/main/worker_thread.js
<ide> port.on('message', (message) => {
<ide> process.stdin.push(null);
<ide>
<ide> debug(`[${threadId}] starts worker script ${filename} ` +
<del> `(eval = ${eval}) at cwd = ${process.cwd()}`);
<add> `(eval = ${doEval}) at cwd = ${process.cwd()}`);
<ide> port.postMessage({ type: UP_AND_RUNNING });
<ide> if (doEval === 'classic') {
<ide> const { evalScript } = require('internal/process/execution'); | 1 |
Javascript | Javascript | normalize ie xhr bug (status code 1223 to 204) | b2f5299e0e3d6e4892b7fcc37686012147bf0afa | <ide><path>src/Browser.js
<ide> function Browser(window, document, body, XHR, $log) {
<ide> });
<ide> xhr.onreadystatechange = function() {
<ide> if (xhr.readyState == 4) {
<del> completeOutstandingRequest(callback, xhr.status || 200, xhr.responseText);
<add> // normalize IE bug (http://bugs.jquery.com/ticket/1450)
<add> var status = xhr.status == 1223 ? 204 : xhr.status || 200;
<add> completeOutstandingRequest(callback, status, xhr.responseText);
<ide> }
<ide> };
<ide> xhr.send(post || '');
<ide><path>test/BrowserSpecs.js
<ide> describe('browser', function(){
<ide> expect(response).toEqual('RESPONSE');
<ide> });
<ide>
<add> it('should normalize IE\'s 1223 status code into 204', function() {
<add> var callback = jasmine.createSpy('XHR');
<add>
<add> browser.xhr('GET', 'URL', 'POST', callback);
<add>
<add> xhr.status = 1223;
<add> xhr.readyState = 4;
<add> xhr.onreadystatechange();
<add>
<add> expect(callback).toHaveBeenCalled();
<add> expect(callback.argsForCall[0][0]).toEqual(204);
<add> });
<add>
<ide> it('should not set Content-type header for GET requests', function() {
<ide> browser.xhr('GET', 'URL', 'POST-DATA', function(c, r) {});
<ide> | 2 |
Text | Text | fix typo in quick-start.md | ab291aabe04051f272150b72ac42369076858fae | <ide><path>docs/tutorials/quick-start.md
<ide> export function Counter() {
<ide> }
<ide> ```
<ide>
<del>Now, any time you click the "Increment" and "Decrement buttons:
<add>Now, any time you click the "Increment" and "Decrement" buttons:
<ide>
<ide> - The corresponding Redux action will be dispatched to the store
<ide> - The counter slice reducer will see the actions and update its state | 1 |
Java | Java | fix deviceidentity on rn for android | e7765a32f7bf1f7ca17aa285b107358a768cbf4c | <ide><path>ReactAndroid/src/main/java/com/facebook/react/bridge/JSCJavaScriptExecutorFactory.java
<ide> public JavaScriptExecutor create() throws Exception {
<ide> WritableNativeMap jscConfig = new WritableNativeMap();
<ide> jscConfig.putString("OwnerIdentity", "ReactNative");
<ide> jscConfig.putString("AppIdentity", mAppName);
<del> jscConfig.putString("OwnerIdentity", mDeviceName);
<add> jscConfig.putString("DeviceIdentity", mDeviceName);
<ide> return new JSCJavaScriptExecutor(jscConfig);
<ide> }
<ide> } | 1 |
Javascript | Javascript | resolve fonts through options.font | e756fb93a3b8cb5a29de04d9bcf972295e38b21f | <ide><path>src/core/core.scale.js
<ide> function getTickMarkLength(options) {
<ide> /**
<ide> * @param {object} options
<ide> */
<del>function getScaleLabelHeight(options) {
<add>function getScaleLabelHeight(options, fallback) {
<ide> if (!options.display) {
<ide> return 0;
<ide> }
<ide>
<del> const font = toFont(options.font);
<add> const font = toFont(options.font, fallback);
<ide> const padding = toPadding(options.padding);
<ide>
<ide> return font.lineHeight + padding.height;
<ide> export default class Scale extends Element {
<ide> if (maxLabelWidth + 6 > tickWidth) {
<ide> tickWidth = maxWidth / (numTicks - (options.offset ? 0.5 : 1));
<ide> maxHeight = me.maxHeight - getTickMarkLength(options.gridLines)
<del> - tickOpts.padding - getScaleLabelHeight(options.scaleLabel);
<add> - tickOpts.padding - getScaleLabelHeight(options.scaleLabel, me.chart.options.font);
<ide> maxLabelDiagonal = Math.sqrt(maxLabelWidth * maxLabelWidth + maxLabelHeight * maxLabelHeight);
<ide> labelRotation = toDegrees(Math.min(
<ide> Math.asin(Math.min((labelSizes.highest.height + 6) / tickWidth, 1)),
<ide> export default class Scale extends Element {
<ide> const display = me._isVisible();
<ide> const labelsBelowTicks = opts.position !== 'top' && me.axis === 'x';
<ide> const isHorizontal = me.isHorizontal();
<add> const scaleLabelHeight = display && getScaleLabelHeight(scaleLabelOpts, chart.options.font);
<ide>
<ide> // Width
<ide> if (isHorizontal) {
<ide> minSize.width = me.maxWidth;
<ide> } else if (display) {
<del> minSize.width = getTickMarkLength(gridLineOpts) + getScaleLabelHeight(scaleLabelOpts);
<add> minSize.width = getTickMarkLength(gridLineOpts) + scaleLabelHeight;
<ide> }
<ide>
<ide> // height
<ide> if (!isHorizontal) {
<ide> minSize.height = me.maxHeight; // fill all the height
<ide> } else if (display) {
<del> minSize.height = getTickMarkLength(gridLineOpts) + getScaleLabelHeight(scaleLabelOpts);
<add> minSize.height = getTickMarkLength(gridLineOpts) + scaleLabelHeight;
<ide> }
<ide>
<ide> // Don't bother fitting the ticks if we are not showing the labels
<ide> export default class Scale extends Element {
<ide> return;
<ide> }
<ide>
<del> const scaleLabelFont = toFont(scaleLabel.font);
<add> const scaleLabelFont = toFont(scaleLabel.font, me.chart.options.font);
<ide> const scaleLabelPadding = toPadding(scaleLabel.padding);
<ide> const halfLineHeight = scaleLabelFont.lineHeight / 2;
<ide> const scaleLabelAlign = scaleLabel.align;
<ide> export default class Scale extends Element {
<ide> */
<ide> _resolveTickFontOptions(index) {
<ide> const me = this;
<add> const chart = me.chart;
<ide> const options = me.options.ticks;
<ide> const ticks = me.ticks || [];
<ide> const context = {
<del> chart: me.chart,
<add> chart,
<ide> scale: me,
<ide> tick: ticks[index],
<ide> index
<ide> };
<del> return toFont(resolve([options.font], context));
<add> return toFont(resolve([options.font], context), chart.options.font);
<ide> }
<ide> }
<ide>
<ide><path>src/helpers/helpers.options.js
<ide> export function toPadding(value) {
<ide> /**
<ide> * Parses font options and returns the font object.
<ide> * @param {object} options - A object that contains font options to be parsed.
<add> * @param {object} [fallback] - A object that contains fallback font options.
<ide> * @return {object} The font object.
<ide> * @private
<ide> */
<del>export function toFont(options) {
<del> const defaultFont = defaults.font;
<add>export function toFont(options, fallback) {
<ide> options = options || {};
<del> let size = valueOrDefault(options.size, defaultFont.size);
<add> fallback = fallback || defaults.font;
<add>
<add> let size = valueOrDefault(options.size, fallback.size);
<ide>
<ide> if (typeof size === 'string') {
<ide> size = parseInt(size, 10);
<ide> }
<ide>
<ide> const font = {
<del> color: valueOrDefault(options.color, defaultFont.color),
<del> family: valueOrDefault(options.family, defaultFont.family),
<del> lineHeight: toLineHeight(valueOrDefault(options.lineHeight, defaultFont.lineHeight), size),
<del> lineWidth: valueOrDefault(options.lineWidth, defaultFont.lineWidth),
<add> color: valueOrDefault(options.color, fallback.color),
<add> family: valueOrDefault(options.family, fallback.family),
<add> lineHeight: toLineHeight(valueOrDefault(options.lineHeight, fallback.lineHeight), size),
<add> lineWidth: valueOrDefault(options.lineWidth, fallback.lineWidth),
<ide> size,
<del> style: valueOrDefault(options.style, defaultFont.style),
<del> weight: valueOrDefault(options.weight, defaultFont.weight),
<del> strokeStyle: valueOrDefault(options.strokeStyle, defaultFont.strokeStyle),
<add> style: valueOrDefault(options.style, fallback.style),
<add> weight: valueOrDefault(options.weight, fallback.weight),
<add> strokeStyle: valueOrDefault(options.strokeStyle, fallback.strokeStyle),
<ide> string: ''
<ide> };
<ide>
<ide><path>src/plugins/plugin.legend.js
<ide> export class Legend extends Element {
<ide> const display = opts.display;
<ide>
<ide> const ctx = me.ctx;
<del> const labelFont = toFont(labelOpts.font);
<add> const labelFont = toFont(labelOpts.font, me.chart.options.font);
<ide> const fontSize = labelFont.size;
<ide> const boxWidth = getBoxWidth(labelOpts, fontSize);
<ide> const boxHeight = getBoxHeight(labelOpts, fontSize);
<ide> export class Legend extends Element {
<ide> me.drawTitle();
<ide> const rtlHelper = getRtlAdapter(opts.rtl, me.left, me._minSize.width);
<ide> const ctx = me.ctx;
<del> const labelFont = toFont(labelOpts.font);
<add> const labelFont = toFont(labelOpts.font, me.chart.options.font);
<ide> const fontColor = labelFont.color;
<ide> const fontSize = labelFont.size;
<ide> let cursor;
<ide> export class Legend extends Element {
<ide> const me = this;
<ide> const opts = me.options;
<ide> const titleOpts = opts.title;
<del> const titleFont = toFont(titleOpts.font);
<add> const titleFont = toFont(titleOpts.font, me.chart.options.font);
<ide> const titlePadding = toPadding(titleOpts.padding);
<ide>
<ide> if (!titleOpts.display) {
<ide> export class Legend extends Element {
<ide> */
<ide> _computeTitleHeight() {
<ide> const titleOpts = this.options.title;
<del> const titleFont = toFont(titleOpts.font);
<add> const titleFont = toFont(titleOpts.font, this.chart.options.font);
<ide> const titlePadding = toPadding(titleOpts.padding);
<ide> return titleOpts.display ? titleFont.lineHeight + titlePadding.height : 0;
<ide> }
<ide><path>src/plugins/plugin.title.js
<ide> export class Title extends Element {
<ide>
<ide> const lineCount = isArray(opts.text) ? opts.text.length : 1;
<ide> me._padding = toPadding(opts.padding);
<del> const textSize = lineCount * toFont(opts.font).lineHeight + me._padding.height;
<add> const textSize = lineCount * toFont(opts.font, me.chart.options.font).lineHeight + me._padding.height;
<ide> me.width = minSize.width = isHorizontal ? me.maxWidth : textSize;
<ide> me.height = minSize.height = isHorizontal ? textSize : me.maxHeight;
<ide> }
<ide> export class Title extends Element {
<ide> return;
<ide> }
<ide>
<del> const fontOpts = toFont(opts.font);
<add> const fontOpts = toFont(opts.font, me.chart.options.font);
<ide> const lineHeight = fontOpts.lineHeight;
<ide> const offset = lineHeight / 2 + me._padding.top;
<ide> let rotation = 0;
<ide><path>src/plugins/plugin.tooltip.js
<ide> function createTooltipItem(chart, item) {
<ide> /**
<ide> * Helper to get the reset model for the tooltip
<ide> * @param options {object} the tooltip options
<add> * @param fallbackFont {object} the fallback font options
<ide> */
<del>function resolveOptions(options) {
<add>function resolveOptions(options, fallbackFont) {
<ide>
<ide> options = merge({}, [defaults.plugins.tooltip, options]);
<ide>
<del> options.bodyFont = toFont(options.bodyFont);
<del> options.titleFont = toFont(options.titleFont);
<del> options.footerFont = toFont(options.footerFont);
<add> options.bodyFont = toFont(options.bodyFont, fallbackFont);
<add> options.titleFont = toFont(options.titleFont, fallbackFont);
<add> options.footerFont = toFont(options.footerFont, fallbackFont);
<ide>
<ide> options.boxHeight = valueOrDefault(options.boxHeight, options.bodyFont.size);
<ide> options.boxWidth = valueOrDefault(options.boxWidth, options.bodyFont.size);
<ide> export class Tooltip extends Element {
<ide>
<ide> initialize() {
<ide> const me = this;
<del> me.options = resolveOptions(me._chart.options.tooltips);
<add> const chartOpts = me._chart.options;
<add> me.options = resolveOptions(chartOpts.tooltips, chartOpts.font);
<ide> }
<ide>
<ide> /**
<ide> export default {
<ide> footer: noop,
<ide> afterFooter: noop
<ide> }
<del> }
<add> },
<ide> };
<ide><path>src/scales/scale.radialLinear.js
<ide> function fitWithPointLabels(scale) {
<ide> index: i,
<ide> label: scale.pointLabels[i]
<ide> };
<del> const plFont = toFont(resolve([scale.options.pointLabels.font], context, i));
<add> const plFont = toFont(resolve([scale.options.pointLabels.font], context, i), scale.chart.options.font);
<ide> scale.ctx.font = plFont.string;
<ide> textSize = measureLabelSize(scale.ctx, plFont.lineHeight, scale.pointLabels[i]);
<ide> scale._pointLabelSizes[i] = textSize;
<ide> function drawPointLabels(scale) {
<ide> index: i,
<ide> label: scale.pointLabels[i],
<ide> };
<del> const plFont = toFont(resolve([pointLabelOpts.font], context, i));
<add> const plFont = toFont(resolve([pointLabelOpts.font], context, i), scale.chart.options.font);
<ide> ctx.font = plFont.string;
<ide> ctx.fillStyle = plFont.color;
<ide>
<ide><path>test/specs/plugin.title.tests.js
<ide> describe('Title block tests', function() {
<ide> });
<ide>
<ide> it('should update correctly', function() {
<del> var chart = {};
<add> var chart = {
<add> options: Chart.helpers.clone(Chart.defaults)
<add> };
<ide>
<ide> var options = Chart.helpers.clone(Chart.defaults.plugins.title);
<ide> options.text = 'My title';
<ide> describe('Title block tests', function() {
<ide> });
<ide>
<ide> it('should update correctly when vertical', function() {
<del> var chart = {};
<add> var chart = {
<add> options: Chart.helpers.clone(Chart.defaults)
<add> };
<ide>
<ide> var options = Chart.helpers.clone(Chart.defaults.plugins.title);
<ide> options.text = 'My title';
<ide> describe('Title block tests', function() {
<ide> });
<ide>
<ide> it('should have the correct size when there are multiple lines of text', function() {
<del> var chart = {};
<add> var chart = {
<add> options: Chart.helpers.clone(Chart.defaults)
<add> };
<ide>
<ide> var options = Chart.helpers.clone(Chart.defaults.plugins.title);
<ide> options.text = ['line1', 'line2'];
<ide> describe('Title block tests', function() {
<ide> });
<ide>
<ide> it('should draw correctly horizontally', function() {
<del> var chart = {};
<add> var chart = {
<add> options: Chart.helpers.clone(Chart.defaults)
<add> };
<ide> var context = window.createMockContext();
<ide>
<ide> var options = Chart.helpers.clone(Chart.defaults.plugins.title);
<ide> describe('Title block tests', function() {
<ide> });
<ide>
<ide> it ('should draw correctly vertically', function() {
<del> var chart = {};
<add> var chart = {
<add> options: Chart.helpers.clone(Chart.defaults)
<add> };
<ide> var context = window.createMockContext();
<ide>
<ide> var options = Chart.helpers.clone(Chart.defaults.plugins.title); | 7 |
Javascript | Javascript | fix typo and remove unused variables | da51cfdcce465dfd3224ca4c471bb9cb96026664 | <ide><path>packages/ember-application/lib/system/application.js
<ide> var Application = Ember.Application = Ember.Namespace.extend({
<ide> container = this.__container__,
<ide> graph = new Ember.DAG(),
<ide> namespace = this,
<del> properties, i, initializer;
<add> i, initializer;
<ide>
<ide> for (i=0; i<initializers.length; i++) {
<ide> initializer = initializers[i];
<ide><path>packages/ember-routing/lib/helpers/action.js
<ide> Ember.onLoad('Ember.Handlebars', function(Handlebars) {
<ide> event.stopPropagation();
<ide> }
<ide>
<del> var view = options.view,
<del> contexts = options.contexts,
<del> target = options.target;
<add> var target = options.target;
<ide>
<ide> if (target.target) {
<ide> target = handlebarsGet(target.root, target.target, target.options);
<ide> Ember.onLoad('Ember.Handlebars', function(Handlebars) {
<ide>
<ide> var hash = options.hash,
<ide> view = options.data.view,
<del> controller, link;
<add> controller;
<ide>
<ide> // create a hash to pass along to registerAction
<ide> var action = {
<ide><path>packages/ember-runtime/lib/controllers/array_controller.js
<ide> require('ember-runtime/mixins/sortable');
<ide> @submodule ember-runtime
<ide> */
<ide>
<del>var get = Ember.get, set = Ember.set, isGlobalPath = Ember.isGlobalPath,
<del> forEach = Ember.EnumerableUtils.forEach, replace = Ember.EnumerableUtils.replace;
<add>var get = Ember.get, set = Ember.set, forEach = Ember.EnumerableUtils.forEach,
<add> replace = Ember.EnumerableUtils.replace;
<ide>
<ide> /**
<ide> `Ember.ArrayController` provides a way for you to publish a collection of
<ide><path>packages/ember-runtime/lib/mixins/deferred.js
<ide> RSVP.async = function(callback, binding) {
<ide> @submodule ember-runtime
<ide> */
<ide>
<del>var get = Ember.get,
<del> slice = Array.prototype.slice;
<add>var get = Ember.get;
<ide>
<ide> /**
<ide> @class Deferred
<ide><path>packages/ember-runtime/lib/mixins/enumerable.js
<ide> Ember.Enumerable = Ember.Mixin.create({
<ide> @chainable
<ide> */
<ide> enumerableContentDidChange: function(removing, adding) {
<del> var notify = this.propertyDidChange, removeCnt, addCnt, hasDelta;
<add> var removeCnt, addCnt, hasDelta;
<ide>
<ide> if ('number' === typeof removing) removeCnt = removing;
<ide> else if (removing) removeCnt = get(removing, 'length');
<ide><path>packages/ember-runtime/lib/mixins/mutable_array.js
<ide> var EMPTY = [];
<ide> // HELPERS
<ide> //
<ide>
<del>var get = Ember.get, set = Ember.set, forEach = Ember.EnumerableUtils.forEach;
<add>var get = Ember.get, set = Ember.set;
<ide>
<ide> /**
<ide> This mixin defines the API for modifying array-like objects. These methods
<ide><path>packages/ember-runtime/lib/mixins/sortable.js
<ide> Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
<ide>
<ide> if (isSorted) {
<ide> var addedObjects = array.slice(idx, idx+addedCount);
<del> var arrangedContent = get(this, 'arrangedContent');
<ide>
<ide> forEach(addedObjects, function(item) {
<ide> this.insertItemSorted(item);
<ide><path>packages/ember-runtime/lib/system/array_proxy.js
<ide> Ember.ArrayProxy = Ember.Object.extend(Ember.MutableArray,
<ide> },
<ide>
<ide> _insertAt: function(idx, object) {
<del> var content = this.get('content');
<ide> if (idx > get(this, 'content.length')) throw new Error(OUT_OF_RANGE_EXCEPTION);
<ide> this._replace(idx, 0, [object]);
<ide> return this;
<ide><path>packages/ember-runtime/lib/system/core_object.js
<ide> require('ember-runtime/system/namespace');
<ide> var set = Ember.set, get = Ember.get,
<ide> o_create = Ember.create,
<ide> o_defineProperty = Ember.platform.defineProperty,
<del> a_slice = Array.prototype.slice,
<ide> GUID_KEY = Ember.GUID_KEY,
<ide> guidFor = Ember.guidFor,
<ide> generateGuid = Ember.generateGuid,
<ide><path>packages/ember-runtime/lib/system/each_proxy.js
<ide> function addObserverForContentKey(content, keyName, proxy, idx, loc) {
<ide> Ember.addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange');
<ide> Ember.addObserver(item, keyName, proxy, 'contentKeyDidChange');
<ide>
<del> // keep track of the indicies each item was found at so we can map
<add> // keep track of the index each item was found at so we can map
<ide> // it back when the obj changes.
<ide> guid = guidFor(item);
<ide> if (!objects[guid]) objects[guid] = [];
<ide> Ember.EachProxy = Ember.Object.extend({
<ide> // Invokes whenever the content array itself changes.
<ide>
<ide> arrayWillChange: function(content, idx, removedCnt, addedCnt) {
<del> var keys = this._keys, key, array, lim;
<add> var keys = this._keys, key, lim;
<ide>
<ide> lim = removedCnt>0 ? idx+removedCnt : -1;
<ide> Ember.beginPropertyChanges(this);
<ide> Ember.EachProxy = Ember.Object.extend({
<ide> },
<ide>
<ide> arrayDidChange: function(content, idx, removedCnt, addedCnt) {
<del> var keys = this._keys, key, array, lim;
<add> var keys = this._keys, key, lim;
<ide>
<ide> lim = addedCnt>0 ? idx+addedCnt : -1;
<ide> Ember.beginPropertyChanges(this);
<ide><path>packages/ember-states/lib/state.js
<ide> Ember.State = Ember.Object.extend(Ember.Evented,
<ide> },
<ide>
<ide> init: function() {
<del> var states = get(this, 'states'), foundStates;
<add> var states = get(this, 'states');
<ide> set(this, 'childStates', Ember.A());
<ide> set(this, 'eventTransitions', get(this, 'eventTransitions') || {});
<ide>
<ide> Ember.State.reopenClass({
<ide> transitionTo: function(target) {
<ide>
<ide> var transitionFunction = function(stateManager, contextOrEvent) {
<del> var contexts = [], transitionArgs,
<add> var contexts = [],
<ide> Event = Ember.$ && Ember.$.Event;
<ide>
<ide> if (contextOrEvent && (Event && contextOrEvent instanceof Event)) {
<ide><path>packages/ember-views/lib/system/controller.js
<ide> Ember.ControllerMixin.reopen({
<ide> },
<ide>
<ide> _modelDidChange: Ember.observer(function() {
<del> var containers = get(this, '_childContainers'),
<del> container;
<add> var containers = get(this, '_childContainers');
<ide>
<ide> for (var prop in containers) {
<ide> if (!containers.hasOwnProperty(prop)) { continue; }
<ide><path>packages/ember-views/lib/system/render_buffer.js
<ide> Ember._RenderBuffer.prototype =
<ide> */
<ide> addClass: function(className) {
<ide> // lazily create elementClasses
<del> var elementClasses = this.elementClasses = (this.elementClasses || new ClassSet());
<add> this.elementClasses = (this.elementClasses || new ClassSet());
<ide> this.elementClasses.add(className);
<ide> this.classes = this.elementClasses.list;
<ide>
<ide> Ember._RenderBuffer.prototype =
<ide> @chainable
<ide> */
<ide> style: function(name, value) {
<del> var style = this.elementStyle = (this.elementStyle || {});
<add> this.elementStyle = (this.elementStyle || {});
<ide>
<ide> this.elementStyle[name] = value;
<ide> return this;
<ide><path>packages/ember-views/lib/views/collection_view.js
<ide> Ember.CollectionView = Ember.ContainerView.extend(
<ide> */
<ide> arrayDidChange: function(content, start, removed, added) {
<ide> var itemViewClass = get(this, 'itemViewClass'),
<del> addedViews = [], view, item, idx, len, itemTagName;
<add> addedViews = [], view, item, idx, len;
<ide>
<ide> if ('string' === typeof itemViewClass) {
<ide> itemViewClass = get(itemViewClass);
<ide><path>packages/ember-views/lib/views/states.js
<ide> Ember.View.cloneStates = function(from) {
<ide> into.hasElement = Ember.create(into._default);
<ide> into.inDOM = Ember.create(into.hasElement);
<ide>
<del> var viewState;
<del>
<ide> for (var stateName in from) {
<ide> if (!from.hasOwnProperty(stateName)) { continue; }
<ide> Ember.merge(into[stateName], from[stateName]); | 15 |
Go | Go | fix some context sharing/plumbing | 075b75fa14e878afa87ad4fd989f03a8541b13eb | <ide><path>api/client/container/restart.go
<ide> func NewRestartCommand(dockerCli *client.DockerCli) *cobra.Command {
<ide> }
<ide>
<ide> func runRestart(dockerCli *client.DockerCli, opts *restartOptions) error {
<add> ctx := context.Background()
<ide> var errs []string
<ide> for _, name := range opts.containers {
<del> if err := dockerCli.Client().ContainerRestart(context.Background(), name, time.Duration(opts.nSeconds)*time.Second); err != nil {
<add> if err := dockerCli.Client().ContainerRestart(ctx, name, time.Duration(opts.nSeconds)*time.Second); err != nil {
<ide> errs = append(errs, err.Error())
<ide> } else {
<ide> fmt.Fprintf(dockerCli.Out(), "%s\n", name)
<ide><path>api/client/network/inspect.go
<ide> func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command {
<ide> func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error {
<ide> client := dockerCli.Client()
<ide>
<add> ctx := context.Background()
<add>
<ide> getNetFunc := func(name string) (interface{}, []byte, error) {
<del> return client.NetworkInspectWithRaw(context.Background(), name)
<add> return client.NetworkInspectWithRaw(ctx, name)
<ide> }
<ide>
<ide> return inspect.Inspect(dockerCli.Out(), opts.names, opts.format, getNetFunc)
<ide><path>api/client/volume/inspect.go
<ide> func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command {
<ide> func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error {
<ide> client := dockerCli.Client()
<ide>
<add> ctx := context.Background()
<add>
<ide> getVolFunc := func(name string) (interface{}, []byte, error) {
<del> i, err := client.VolumeInspect(context.Background(), name)
<add> i, err := client.VolumeInspect(ctx, name)
<ide> return i, nil, err
<ide> }
<ide> | 3 |
PHP | PHP | add start of decimal type | c3ff21d2d964ea8a7243de20709dd792896e2694 | <ide><path>lib/Cake/Model/Datasource/Database/Type.php
<ide> class Type {
<ide> */
<ide> protected static $_basicTypes = [
<ide> 'float' => ['callback' => 'floatval'],
<add> 'decimal' => ['callback' => 'floatval'],
<ide> 'integer' => ['callback' => 'intval', 'pdo' => PDO::PARAM_INT],
<ide> 'biginteger' => ['callback' => 'intval', 'pdo' => PDO::PARAM_INT],
<ide> 'string' => ['callback' => 'strval'],
<ide><path>lib/Cake/Test/TestCase/Model/Datasource/Database/TypeTest.php
<ide> public function testUuidToStatement() {
<ide> $this->assertEquals(PDO::PARAM_STR, $type->toStatement($string, $driver));
<ide> }
<ide>
<add>/**
<add> * Tests decimal from database are converted correctly to PHP
<add> *
<add> * @return void
<add> */
<add> public function testDecimalToPHP() {
<add> $type = Type::build('decimal');
<add> $driver = $this->getMock('\Cake\Model\Datasource\Database\Driver');
<add>
<add> $this->assertSame(3.14159, $type->toPHP('3.14159', $driver));
<add> $this->assertSame(3.14159, $type->toPHP(3.14159, $driver));
<add> $this->assertSame(3.0, $type->toPHP(3, $driver));
<add> }
<add>
<add>/**
<add> * Tests integers from PHP are converted correctly to statement value
<add> *
<add> * @return void
<add> */
<add> public function testDecimalToStatement() {
<add> $type = Type::build('decimal');
<add> $string = '12.55';
<add> $driver = $this->getMock('\Cake\Model\Datasource\Database\Driver');
<add> $this->assertEquals(PDO::PARAM_STR, $type->toStatement($string, $driver));
<add> }
<add>
<ide> } | 2 |
Javascript | Javascript | remove map/set from rn open source | 93b9ac74e59bbe84ea388d7c1879857b4acab114 | <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 |
Ruby | Ruby | add audit for incorrect signing | e90371f8abd188c046692ed4998737cba656e697 | <ide><path>Library/Homebrew/cask/audit.rb
<ide> class Audit
<ide>
<ide> attr_reader :cask, :download
<ide>
<del> attr_predicate :appcast?, :new_cask?, :strict?, :online?, :token_conflicts?
<add> attr_predicate :appcast?, :new_cask?, :strict?, :signing?, :online?, :token_conflicts?
<ide>
<ide> def initialize(cask, appcast: nil, download: nil, quarantine: nil,
<del> token_conflicts: nil, online: nil, strict: nil,
<add> token_conflicts: nil, online: nil, strict: nil, signing: nil,
<ide> new_cask: nil)
<ide>
<del> # `new_cask` implies `online` and `strict`
<add> # `new_cask` implies `online`, `token_conflicts`, `strict` and signing
<ide> online = new_cask if online.nil?
<ide> strict = new_cask if strict.nil?
<add> signing = new_cask if signing.nil?
<add> token_conflicts = new_cask if token_conflicts.nil?
<ide>
<ide> # `online` implies `appcast` and `download`
<ide> appcast = online if appcast.nil?
<ide> download = online if download.nil?
<ide>
<del> # `new_cask` implies `token_conflicts`
<del> token_conflicts = new_cask if token_conflicts.nil?
<add> # `signing` implies `download`
<add> download = signing if download.nil?
<ide>
<ide> @cask = cask
<ide> @appcast = appcast
<ide> @download = Download.new(cask, quarantine: quarantine) if download
<ide> @online = online
<ide> @strict = strict
<add> @signing = signing
<ide> @new_cask = new_cask
<ide> @token_conflicts = token_conflicts
<ide> end
<ide> def run!
<ide> check_github_repository_archived
<ide> check_github_prerelease_version
<ide> check_bitbucket_repository
<add> check_signing
<ide> self
<ide> rescue => e
<ide> odebug e, e.backtrace
<ide> def check_download
<ide> add_error "download not possible: #{e}"
<ide> end
<ide>
<add> def check_signing
<add> return if !signing? || download.blank? || cask.url.blank?
<add>
<add> odebug "Auditing signing"
<add> odebug cask.artifacts
<add> artifacts = cask.artifacts.select { |k| k.is_a?(Artifact::Pkg) || k.is_a?(Artifact::App) }
<add>
<add> return if artifacts.empty?
<add>
<add> downloaded_path = download.fetch
<add> primary_container = UnpackStrategy.detect(downloaded_path, type: @cask.container&.type, merge_xattrs: true)
<add>
<add> return if primary_container.nil?
<add>
<add> Dir.mktmpdir do |tmpdir|
<add> tmpdir = Pathname(tmpdir)
<add> primary_container.extract_nestedly(to: tmpdir, basename: downloaded_path.basename, verbose: false)
<add> cask.artifacts.each do |artifact|
<add> result = system_command("codesign", args: [
<add> "--verify",
<add> tmpdir/artifact.source.basename,
<add> ], print_stderr: false)
<add> add_warning result.merged_output unless result.success?
<add> end
<add> end
<add> end
<add>
<ide> def check_livecheck_version
<ide> return unless appcast?
<ide>
<ide><path>Library/Homebrew/cask/auditor.rb
<ide> def self.audit(
<ide> audit_online: nil,
<ide> audit_new_cask: nil,
<ide> audit_strict: nil,
<add> audit_signing: nil,
<ide> audit_token_conflicts: nil,
<ide> quarantine: nil,
<ide> any_named_args: nil,
<ide> def self.audit(
<ide> audit_online: audit_online,
<ide> audit_new_cask: audit_new_cask,
<ide> audit_strict: audit_strict,
<add> audit_signing: audit_signing,
<ide> audit_token_conflicts: audit_token_conflicts,
<ide> quarantine: quarantine,
<ide> any_named_args: any_named_args,
<ide> def initialize(
<ide> audit_appcast: nil,
<ide> audit_online: nil,
<ide> audit_strict: nil,
<add> audit_signing: nil,
<ide> audit_token_conflicts: nil,
<ide> audit_new_cask: nil,
<ide> quarantine: nil,
<ide> def initialize(
<ide> @audit_online = audit_online
<ide> @audit_new_cask = audit_new_cask
<ide> @audit_strict = audit_strict
<add> @audit_signing = audit_signing
<ide> @quarantine = quarantine
<ide> @audit_token_conflicts = audit_token_conflicts
<ide> @any_named_args = any_named_args
<ide> def audit_cask_instance(cask)
<ide> appcast: @audit_appcast,
<ide> online: @audit_online,
<ide> strict: @audit_strict,
<add> signing: @audit_signing,
<ide> new_cask: @audit_new_cask,
<ide> token_conflicts: @audit_token_conflicts,
<ide> download: @audit_download,
<ide><path>Library/Homebrew/cask/cmd/audit.rb
<ide> def self.parser
<ide> description: "Audit the appcast"
<ide> switch "--[no-]token-conflicts",
<ide> description: "Audit for token conflicts"
<add> switch "--[no-]signing",
<add> description: "Audit for signed apps, which is required on ARM"
<ide> switch "--[no-]strict",
<ide> description: "Run additional, stricter style checks"
<ide> switch "--[no-]online",
<ide> def run
<ide> appcast: args.appcast?,
<ide> online: args.online?,
<ide> strict: args.strict?,
<add> signing: args.signing?,
<ide> new_cask: args.new_cask?,
<ide> token_conflicts: args.token_conflicts?,
<ide> quarantine: args.quarantine?,
<ide> def self.audit_casks(
<ide> appcast: nil,
<ide> online: nil,
<ide> strict: nil,
<add> signing: nil,
<ide> new_cask: nil,
<ide> token_conflicts: nil,
<ide> quarantine: nil,
<ide> def self.audit_casks(
<ide> audit_appcast: appcast,
<ide> audit_online: online,
<ide> audit_strict: strict,
<add> audit_signing: signing,
<ide> audit_new_cask: new_cask,
<ide> audit_token_conflicts: token_conflicts,
<ide> quarantine: quarantine,
<ide><path>Library/Homebrew/test/cask/audit_spec.rb
<ide> def tmp_cask(name, text)
<ide> end
<ide> end
<ide>
<add> describe "signing checks" do
<add> let(:download_double) { instance_double(Cask::Download) }
<add> let(:unpack_double) { instance_double(UnpackStrategy::Zip) }
<add>
<add> before do
<add> allow(audit).to receive(:download).and_return(download_double)
<add> allow(audit).to receive(:signing?).and_return(true)
<add> allow(audit).to receive(:check_https_availability)
<add> end
<add>
<add> context "when cask is not using a signed artifact" do
<add> let(:cask) do
<add> tmp_cask "signing-cask-test", <<~RUBY
<add> cask 'signing-cask-test' do
<add> version '1.0'
<add> url "https://brew.sh/index.html"
<add> binary 'Audit.app'
<add> end
<add> RUBY
<add> end
<add>
<add> it "does not fail" do
<add> expect(download_double).not_to receive(:fetch)
<add> expect(UnpackStrategy).not_to receive(:detect)
<add> expect(run).not_to warn_with(/Audit\.app/)
<add> end
<add> end
<add>
<add> context "when cask is using a signed artifact" do
<add> let(:cask) do
<add> tmp_cask "signing-cask-test", <<~RUBY
<add> cask 'signing-cask-test' do
<add> version '1.0'
<add> url "https://brew.sh/"
<add> pkg 'Audit.app'
<add> end
<add> RUBY
<add> end
<add>
<add> it "does not fail since no extract" do
<add> allow(download_double).to receive(:fetch).and_return(Pathname.new("/tmp/test.zip"))
<add> allow(UnpackStrategy).to receive(:detect).and_return(nil)
<add> expect(run).not_to warn_with(/Audit\.app/)
<add> end
<add> end
<add> end
<add>
<ide> describe "livecheck should be skipped" do
<ide> let(:online) { true }
<ide> let(:message) { /Version '[^']*' differs from '[^']*' retrieved by livecheck\./ }
<ide> def tmp_cask(name, text)
<ide> end
<ide>
<ide> describe "audit of downloads" do
<del> let(:cask_token) { "with-binary" }
<add> let(:cask_token) { "basic-cask" }
<ide> let(:cask) { Cask::CaskLoader.load(cask_token) }
<ide> let(:download_double) { instance_double(Cask::Download) }
<ide> let(:message) { "Download Failed" }
<ide>
<ide> before do
<ide> allow(audit).to receive(:download).and_return(download_double)
<ide> allow(audit).to receive(:check_https_availability)
<add> allow(UnpackStrategy).to receive(:detect).and_return(nil)
<ide> end
<ide>
<ide> it "when download and verification succeed it does not fail" do
<del> expect(download_double).to receive(:fetch)
<add> expect(download_double).to receive(:fetch).and_return(Pathname.new("/tmp/test.zip"))
<ide> expect(run).to pass
<ide> end
<ide> | 4 |
Text | Text | suggest worker threads in cluster docs | 312b0fc7530f9543b0d3c448b56639115f61adf7 | <ide><path>doc/api/cluster.md
<ide>
<ide> <!-- source_link=lib/cluster.js -->
<ide>
<del>A single instance of Node.js runs in a single thread. To take advantage of
<del>multi-core systems, the user will sometimes want to launch a cluster of Node.js
<del>processes to handle the load.
<add>Clusters of Node.js processes can be used to run multiple instances of Node.js
<add>that can distribute workloads among their application threads. When process
<add>isolation is not needed, use the [`worker_threads`][] module instead, which
<add>allows running multiple application threads within a single Node.js instance.
<ide>
<ide> The cluster module allows easy creation of child processes that all share
<ide> server ports.
<ide> socket.on('data', (id) => {
<ide> [`process` event: `'message'`]: process.md#event-message
<ide> [`server.close()`]: net.md#event-close
<ide> [`worker.exitedAfterDisconnect`]: #workerexitedafterdisconnect
<add>[`worker_threads`]: worker_threads.md | 1 |
Python | Python | remove h5py requirement and made it optional | a582b184c9918cdf556c9892b70481deccded61d | <ide><path>setup.py
<ide> url='https://github.com/fchollet/keras',
<ide> download_url='https://github.com/fchollet/keras/tarball/0.1.2',
<ide> license='MIT',
<del> install_requires=['theano', 'pyyaml', 'h5py'],
<add> install_requires=['theano', 'pyyaml'],
<add> extras_require = {
<add> 'h5py': ['h5py'],
<add> },
<ide> packages=find_packages()) | 1 |
Ruby | Ruby | remove outdated comment | e73f869d8427e093a536cf10c38ec714264245d3 | <ide><path>Library/Homebrew/extend/ENV.rb
<ide> def set_cpu_cflags default=DEFAULT_FLAGS, map=Hardware::CPU.optimization_flags
<ide>
<ide> # actually c-compiler, so cc would be a better name
<ide> def compiler
<del> # TODO seems that ENV.clang in a Formula.install should warn when called
<del> # if the user has set something that is tested here
<del>
<ide> # test for --flags first so that installs can be overridden on a per
<ide> # install basis. Then test for ENVs in inverse order to flags, this is
<ide> # sensible, trust me | 1 |
PHP | PHP | fix optional parameters with default values | 85dc6feca45006ff2bd6f81867a343b646e89b29 | <ide><path>src/Controller/ControllerFactory.php
<ide> public function invoke($controller): ResponseInterface
<ide> // Primitive types are passed args as they can't be looked up in the container.
<ide> // We only handle strings currently.
<ide> if ($typeName === 'string') {
<del> if (count($passed) || !$type->allowsNull()) {
<add> $defaultValue = $parameter->getDefaultValue();
<add> if (count($passed)) {
<ide> $args[$position] = array_shift($passed);
<add> } elseif ($defaultValue) {
<add> $args[$position] = $defaultValue;
<ide> } else {
<ide> $args[$position] = null;
<ide> }
<ide><path>tests/TestCase/Controller/ControllerFactoryTest.php
<ide> public function testInvokeInjectPassedParametersSpread()
<ide> $this->assertNotNull($data);
<ide> $this->assertSame(['one', 'two'], $data->args);
<ide> }
<add>
<add> /**
<add> * Test that default parameters work for controller methods
<add> *
<add> * @return void
<add> */
<add> public function testInvokeOptionalStringParam()
<add> {
<add> $request = new ServerRequest([
<add> 'url' => 'test_plugin_three/dependencies/optionalString',
<add> 'params' => [
<add> 'plugin' => null,
<add> 'controller' => 'Dependencies',
<add> 'action' => 'optionalString',
<add> ],
<add> ]);
<add> $controller = $this->factory->create($request);
<add>
<add> $result = $this->factory->invoke($controller);
<add> $data = json_decode((string)$result->getBody());
<add>
<add> $this->assertNotNull($data);
<add> $this->assertSame('default val', $data->str);
<add> }
<ide> }
<ide><path>tests/test_app/TestApp/Controller/DependenciesController.php
<ide> public function __construct(
<ide> $this->inject = $inject;
<ide> }
<ide>
<add> public function optionalString(string $str = 'default val')
<add> {
<add> return $this->response->withStringBody(json_encode(compact('str')));
<add> }
<add>
<ide> public function optionalDep($any = null, ?string $str = null, ?stdClass $dep = null)
<ide> {
<ide> return $this->response->withStringBody(json_encode(compact('dep', 'any', 'str'))); | 3 |
PHP | PHP | apply suggestions from code review | 9c5c640d0871924a77a4f7db2b82884fb4227d89 | <ide><path>src/Illuminate/Foundation/Testing/TestResponse.php
<ide> public function assertJsonValidationErrors($errors)
<ide>
<ide> if (! is_int($key)) {
<ide> $hasError = false;
<add>
<ide> foreach (Arr::wrap($jsonErrors[$key]) as $jsonErrorMessage) {
<ide> if (Str::contains($jsonErrorMessage, $value)) {
<ide> $hasError = true;
<add>
<ide> break;
<ide> }
<ide> } | 1 |
Text | Text | correct the css example for 'appear' transition | 208f20b787e2d50eb4283cf6593b7a5353787c3d | <ide><path>docs/docs/10.1-animation.md
<ide> During the initial mount `ReactCSSTransitionGroup` will get the `example-appear`
<ide> ```css
<ide> .example-appear {
<ide> opacity: 0.01;
<del> transition: opacity .5s ease-in;
<ide> }
<ide>
<ide> .example-appear.example-appear-active {
<ide> opacity: 1;
<add> transition: opacity .5s ease-in;
<ide> }
<ide> ```
<ide> | 1 |
PHP | PHP | fix typo in foreign key sql | c29bed81d476725a83cdb777bffa650598c32df8 | <ide><path>src/Database/Schema/PostgresSchema.php
<ide> protected function _keySql($prefix, $data) {
<ide> );
<ide> if ($data['type'] === Table::CONSTRAINT_FOREIGN) {
<ide> return $prefix . sprintf(
<del> ' FOREIGN KEY (%s) REFERENCES %s (%s) ON UPDATE %s ON DELETE %s DEFERABLE INITIALLY IMMEDIATE',
<add> ' FOREIGN KEY (%s) REFERENCES %s (%s) ON UPDATE %s ON DELETE %s DEFERRABLE INITIALLY IMMEDIATE',
<ide> implode(', ', $columns),
<ide> $this->_driver->quoteIdentifier($data['references'][0]),
<ide> $this->_driver->quoteIdentifier($data['references'][1]),
<ide> public function createTableSql(Table $table, $columns, $constraints, $indexes) {
<ide> public function truncateTableSql(Table $table) {
<ide> $name = $this->_driver->quoteIdentifier($table->name());
<ide> return [
<del> sprintf('TRUNCATE %s RESTART IDENTITY', $name)
<add> sprintf('TRUNCATE %s RESTART IDENTITY CASCADE', $name)
<ide> ];
<ide> }
<ide>
<ide><path>tests/TestCase/Database/Schema/PostgresSchemaTest.php
<ide> public static function constraintSqlProvider() {
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id']],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT DEFERABLE INITIALLY IMMEDIATE'
<add> 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE'
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'cascade'],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE CASCADE ON DELETE RESTRICT DEFERABLE INITIALLY IMMEDIATE'
<add> 'REFERENCES "authors" ("id") ON UPDATE CASCADE ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE'
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'restrict'],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT DEFERABLE INITIALLY IMMEDIATE'
<add> 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE'
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'setNull'],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE SET NULL ON DELETE RESTRICT DEFERABLE INITIALLY IMMEDIATE'
<add> 'REFERENCES "authors" ("id") ON UPDATE SET NULL ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE'
<ide> ],
<ide> [
<ide> 'author_id_idx',
<ide> ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'noAction'],
<ide> 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' .
<del> 'REFERENCES "authors" ("id") ON UPDATE NO ACTION ON DELETE RESTRICT DEFERABLE INITIALLY IMMEDIATE'
<add> 'REFERENCES "authors" ("id") ON UPDATE NO ACTION ON DELETE RESTRICT DEFERRABLE INITIALLY IMMEDIATE'
<ide> ],
<ide> ];
<ide> } | 2 |
Text | Text | add configurestore recipe | d4355ab0612089d4a728bf0207b3285d310114ca | <ide><path>docs/README.md
<ide> * [Example: Reddit API](advanced/ExampleRedditAPI.md)
<ide> * [Next Steps](advanced/NextSteps.md)
<ide> * [Recipes](recipes/README.md)
<add> * [Configuring Your Store](recipes/ConfiguringYourStore.md)
<ide> * [Migrating to Redux](recipes/MigratingToRedux.md)
<ide> * [Using Object Spread Operator](recipes/UsingObjectSpreadOperator.md)
<ide> * [Reducing Boilerplate](recipes/ReducingBoilerplate.md)
<ide><path>docs/recipes/ConfiguringYourStore.md
<add># Configuring Your Store
<add>
<add>In the [basics section](../basics/README.md), we introduced the fundamental Redux concepts by building an example Todo list app.
<add>
<add>We will now explore how to customise the store to add extra functionality. We'll start with the source code from the basics section, which you can view in [the documentation](../basics/ExampleTodoList.md), in [our repository of examples](https://github.com/reduxjs/redux/tree/master/examples/todos/src), or [in your browser via CodeSandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/todos).
<add>
<add>## Creating the store
<add>
<add>First, let's look at the original `index.js` file in which we created our store:
<add>
<add>```js
<add>import React from 'react'
<add>import { render } from 'react-dom'
<add>import { Provider } from 'react-redux'
<add>import { createStore } from 'redux'
<add>import rootReducer from './reducers'
<add>import App from './components/App'
<add>
<add>const store = createStore(rootReducer)
<add>
<add>render(
<add> <Provider store={store}>
<add> <App />
<add> </Provider>,
<add> document.getElementById('root')
<add>)
<add>```
<add>
<add>In this code, we pass our reducers to the Redux `createStore` function, which returns a `store` object. We then pass this object to the `react-redux` `Provider` component, which is rendered at the top of our component tree.
<add>
<add>This ensures that any time we connect to Redux in our app via `react-redux` `connect`, the store is available to our components.
<add>
<add>## Extending Redux functionality
<add>
<add>Most apps extend the functionality of their Redux store by adding middleware or store enhancers _(note: middleware is common, enhancers are less common)_. Middleware adds extra functionality to the Redux `dispatch` function; enhancers add extra functionality to the Redux store.
<add>
<add>We will add two middlewares and one enhancer:
<add>
<add>- The [`redux-thunk` middleware](https://github.com/reduxjs/redux-thunk), which allows simple asynchronous use of dispatch.
<add>- A middleware which logs dispatched actions and the resulting new state.
<add>- An enhancer which logs the time taken for the reducers to process each action.
<add>
<add>#### Install `redux-thunk`
<add>
<add>```
<add>npm install --save redux-thunk
<add>```
<add>
<add>#### middleware/logger.js
<add>```js
<add>const logger = store => next => action => {
<add> console.group(action.type)
<add> console.info('dispatching', action)
<add> let result = next(action)
<add> console.log('next state', store.getState())
<add> console.groupEnd()
<add> return result
<add>}
<add>
<add>export default logger
<add>```
<add>
<add>#### enhancers/monitorReducer.js
<add>```js
<add>const round = number => Math.round(number * 100) / 100
<add>
<add>const monitorReducerEnhancer = createStore => (
<add> reducer,
<add> initialState,
<add> enhancer
<add>) => {
<add> const monitoredReducer = (state, action) => {
<add> const start = performance.now()
<add> const newState = reducer(state, action)
<add> const end = performance.now()
<add> const diff = round(end - start)
<add>
<add> console.log('reducer process time:', diff)
<add>
<add> return newState
<add> }
<add>
<add> return createStore(monitoredReducer, initialState, enhancer)
<add>}
<add>
<add>export default monitorReducerEnhancer
<add>```
<add>
<add>Let's add these to our existing `index.js`.
<add>
<add>- First, we need to import `redux-thunk` plus our `loggerMiddleware` and `monitorReducerEnhancer`, plus two extra functions provided by Redux: `applyMiddleware` and `compose`.
<add>- We then use `applyMiddleware` to create a store enhancer which will apply our `loggerMiddleware` and the `thunkMiddleware` to the store's dispatch function.
<add>- Next, we use `compose` to compose our new `middlewareEnhancer` and our `monitorReducerEnhancer` into one function.
<add>
<add> This is needed because you can only pass one enhancer into `createStore`. To use multiple enhancers, you must first compose them into a single larger enhancer, as shown in this example.
<add>- Finally, we pass this new `composedEnhancers` function into `createStore` as its third argument. _Note: the second argument, which we will ignore, lets you preloaded state into the store._
<add>
<add>```js
<add>import React from 'react'
<add>import { render } from 'react-dom'
<add>import { Provider } from 'react-redux'
<add>import { createStore } from 'redux'
<add>import thunkMiddleware from 'redux-thunk'
<add>import rootReducer from './reducers'
<add>import loggerMiddleware from './middleware/logger'
<add>import monitorReducerEnhancer from './enhancers/monitorReducer'
<add>import App from './components/App'
<add>
<add>const middlewareEnhancer = applyMiddleware(loggerMiddleware, thunkMiddleware)
<add>const composedEnhancers = compose(middlewareEnhancer, monitorReducerEnhancer)
<add>
<add>const store = createStore(rootReducer, undefined, composedEnhancers)
<add>
<add>render(
<add> <Provider store={store}>
<add> <App />
<add> </Provider>,
<add> document.getElementById('root')
<add>)
<add>```
<add>
<add>## Problems with this approach
<add>
<add>While this code works, for a typical app it is not ideal.
<add>
<add>Most apps use more than one middleware, and each middleware often requires some initial setup. The extra noise added to the `index.js` can quickly make it hard to maintain, because the logic is not cleanly organised.
<add>
<add>## The solution: `configureStore`
<add>
<add>The solution to this problem is to create a new `configureStore` function which encapsulates our store creation logic, which can then be located in its own file to ease extensibility.
<add>
<add>The end goal is for our `index.js` to look like this:
<add>
<add>```js
<add>import React from 'react'
<add>import { render } from 'react-dom'
<add>import { Provider } from 'react-redux'
<add>import App from './components/App'
<add>import configureStore from './configureStore'
<add>
<add>const store = configureStore()
<add>
<add>render(
<add> <Provider store={store}>
<add> <App />
<add> </Provider>,
<add> document.getElementById('root')
<add>)
<add>```
<add>
<add>All the logic related to configuring the store - including importing reducers, middleware, and enhancers - is handled in a dedicated file.
<add>
<add>To achieve this, `configureStore` function looks like this:
<add>
<add>```js
<add>import { applyMiddleware, compose, createStore } from 'redux'
<add>import thunkMiddleware from 'redux-thunk'
<add>
<add>import monitorReducersEnhancer from './enhancers/monitorReducers'
<add>import loggerMiddleware from './middleware/logger'
<add>import rootReducer from './reducers'
<add>
<add>export default function configureStore(preloadedState) {
<add> const middlewares = [loggerMiddleware, thunkMiddleware]
<add> const middlewareEnhancer = applyMiddleware(...middlewares)
<add>
<add> const enhancers = [middlewareEnhancer, monitorReducersEnhancer]
<add> const composedEnhancers = compose(...enhancers)
<add>
<add> const store = createStore(rootReducer, preloadedState, composedEnhancers)
<add>
<add> return store
<add>}
<add>```
<add>
<add>This function follows the same steps outlined above, with some of the logic split out to prepare for extension, which will make it easier to add more in future:
<add>
<add>- Both `middlewares` and `enhancers` are defined as arrays, separate from the functions which consume them.
<add>
<add> This allows us to easily add more middleware or enhancers based on different conditions.
<add>
<add> For example, it is common to add some middleware only when in development mode, which is easily achieved by pushing to the middlewares array inside an if statement:
<add>
<add> ```js
<add> if (process.env === 'development') {
<add> middlewares.push(secretMiddleware)
<add> }
<add> ```
<add>- A `preloadedState` variable is passed through to `createStore` in case we want to add this later.
<add>
<add>This also makes our `createStore` function easier to reason about - each step is clearly separated, which makes it more obvious what exactly is happening.
<add>
<add>## Integrating the devtools extension
<add>
<add>Another common feature which you may wish to add to your app is the `redux-devtools-extension` integration.
<add>
<add>The extension is a suite of tools which give you absolute control over your Redux store - it allows you to inspect and replay actions, explore your state at different times, dispatch actions directly to the store, and much more. [Click here to read more about the available features.](https://github.com/zalmoxisus/redux-devtools-extension)
<add>
<add>There are several ways to integrate the extension, but we will use the most convenient option.
<add>
<add>First, we install the package via npm:
<add>
<add>```
<add>npm install --save-dev redux-devtools-extension
<add>```
<add>
<add>Next, we remove the `compose` function which we imported from `redux`, and replace it with a new `composeWithDevtools` function imported from `redux-devtools-extension`.
<add>
<add>The final code looks like this:
<add>
<add>```js
<add>import { applyMiddleware, createStore } from 'redux'
<add>import thunkMiddleware from 'redux-thunk'
<add>import { composeWithDevtools } from 'redux-devtools-extension'
<add>
<add>import monitorReducersEnhancer from './enhancers/monitorReducers'
<add>import loggerMiddleware from './middleware/logger'
<add>import rootReducer from './reducers'
<add>
<add>export default function configureStore(preloadedState) {
<add> const middlewares = [loggerMiddleware, thunkMiddleware]
<add> const middlewareEnhancer = applyMiddleware(...middlewares)
<add>
<add> const enhancers = [middlewareEnhancer, monitorReducersEnhancer]
<add> const composedEnhancers = composeWithDevtools(...enhancers)
<add>
<add> const store = createStore(rootReducer, preloadedState, composedEnhancers)
<add>
<add> return store
<add>}
<add>```
<add>
<add>And that's it!
<add>
<add>If we now visit our app via a browser with the devtools extension installed, we can explore and debug using a powerful new tool.
<add>
<add>## Hot reloading
<add>
<add>Another powerful tool which can make the development process a lot more intuitive is hot reloading, which means replacing pieces of code without restarting your whole app.
<add>
<add>For example, consider what happens when you run your app, interact with it for a while, and then decide to make changes to one of your reducers. Normally, when you make those changes your app will restart, reverting your Redux state to its initial value.
<add>
<add>With hot module reloading enabled, only the reducer you changed would be reloaded, allowing you to change your code _without_ resetting the state every time. This makes for a much faster development process.
<add>
<add>We'll add hot reloading both to our Redux reducers and to our React components.
<add>
<add>First, let's add it to our `configureStore` function:
<add>
<add>```js
<add>import { applyMiddleware, compose, createStore } from 'redux'
<add>import thunkMiddleware from 'redux-thunk'
<add>
<add>import monitorReducersEnhancer from './enhancers/monitorReducers'
<add>import loggerMiddleware from './middleware/logger'
<add>import rootReducer from './reducers'
<add>
<add>export default function configureStore(preloadedState) {
<add> const middlewares = [loggerMiddleware, thunkMiddleware]
<add> const middlewareEnhancer = applyMiddleware(...middlewares)
<add>
<add> const enhancers = [middlewareEnhancer, monitorReducersEnhancer]
<add> const composedEnhancers = compose(...enhancers)
<add>
<add> const store = createStore(rootReducer, preloadedState, composedEnhancers)
<add>
<add> if (process.env.NODE_ENV !== 'production' && module.hot) {
<add> module.hot.accept('./reducers', () =>
<add> store.replaceReducer(rootReducer)
<add> )
<add> }
<add>
<add> return store
<add>}
<add>```
<add>
<add>The new code is wrapped in an `if` statement, so it only runs when our app is not in production mode, and only if the `module.hot` feature is available.
<add>
<add>We use Webpack's `module.hot.accept` method to specify which module should be hot reloaded, and what should happen when the module changes. In this case, we're watching the `./reducers` module, and passing the updated `rootReducer` to the `store.replaceReducer` method when it changes.
<add>
<add>We'll also use the same pattern in our `index.js` to hot reload any changes to our React components:
<add>
<add>```js
<add>import React from 'react'
<add>import { render } from 'react-dom'
<add>import { Provider } from 'react-redux'
<add>import App from './components/App'
<add>import configureStore from './configureStore'
<add>
<add>const store = configureStore()
<add>
<add>const renderApp = () => render(
<add> <Provider store={store}>
<add> <App />
<add> </Provider>,
<add> document.getElementById('root')
<add>)
<add>
<add>if (process.env.NODE_ENV !== 'production' && module.hot) {
<add> module.hot.accept('./components/App', () => {
<add> renderApp()
<add> })
<add>}
<add>
<add>renderApp()
<add>```
<add>
<add>The only extra change here is that we have encapsulated our app's rendering into a new `renderApp` function, which we now call to re-render the app.
<add>
<add>## Next Steps
<add>
<add>Now that you know how to encapsulate your store configuration to make it easier to maintain, you can [learn more about the advanced features Redux provides](../basics/README.md), or take a closer look at some of the [extensions available in the Redux ecosystem](../introduction/ecosystem).
<ide><path>docs/recipes/README.md
<ide>
<ide> These are some use cases and code snippets to get you started with Redux in a real app. They assume you understand the topics in [basic](../basics/README.md) and [advanced](../advanced/README.md) tutorials.
<ide>
<add>* [Configuring Your Store](ConfiguringYourStore.md)
<ide> * [Migrating to Redux](MigratingToRedux.md)
<ide> * [Using Object Spread Operator](UsingObjectSpreadOperator.md)
<ide> * [Reducing Boilerplate](ReducingBoilerplate.md) | 3 |
Python | Python | move error to errors | ba22111ff407c3e6ea462626323c9048a3d9a4e4 | <ide><path>spacy/errors.py
<ide> class Errors:
<ide> E199 = ("Unable to merge 0-length span at doc[{start}:{end}].")
<ide>
<ide> # TODO: fix numbering after merging develop into master
<add> E952 = ("The section '{name}' is not a valid section in the provided config.")
<ide> E953 = ("Mismatched IDs received by the Tok2Vec listener: {id1} vs. {id2}")
<ide> E954 = ("The Tok2Vec listener did not receive a valid input.")
<ide> E955 = ("Can't find table '{table}' for language '{lang}' in spacy-lookups-data.")
<ide><path>spacy/util.py
<ide> def dot_to_object(config: Config, section: str):
<ide> for item in parts:
<ide> try:
<ide> component = component[item]
<del> except (KeyError, TypeError) as e:
<del> msg = f"The section '{section}' is not a valid section in the provided config."
<del> raise KeyError(msg)
<add> except (KeyError, TypeError):
<add> raise KeyError(Errors.E952.format(name=section))
<ide> return component
<ide>
<ide> | 2 |
Ruby | Ruby | run `git am --abort` on failure | ed7693cecf677a5e55a450be2065168e4ebefdb7 | <ide><path>Library/Contributions/cmd/brew-pull.rb
<ide> def tap arg
<ide> revision = `git rev-parse --short HEAD`.strip
<ide>
<ide> ohai 'Applying patch'
<del> patch_args = ['am']
<add> patch_args = []
<ide> patch_args << '--signoff' unless ARGV.include? '--clean'
<ide> # Normally we don't want whitespace errors, but squashing them can break
<ide> # patches so an option is provided to skip this step.
<ide> def tap arg
<ide> end
<ide> patch_args << patchpath
<ide>
<del> safe_system 'git', *patch_args
<add> begin
<add> safe_system 'git', 'am', *patch_args
<add> rescue => e
<add> system 'git', 'am', '--abort'
<add> odie 'Patch failed to apply: aborted.'
<add> end
<ide>
<ide> issue = arg.to_i > 0 ? arg.to_i : url_match[4]
<ide> if issue and not ARGV.include? '--clean' | 1 |
Ruby | Ruby | add tests to validate library versions | 86eca5ab4487f79b2f1c60645cca440d4bd068aa | <ide><path>Library/Homebrew/test/os/mac/pkgconfig_spec.rb
<add># frozen_string_literal: true
<add>
<add># These tests assume the needed SDKs are correctly installed, i.e. `brew doctor` passes.
<add># The CLT version installed should be the latest available for the running OS.
<add># The tests do not check other OS versions beyond than the one the tests are being run on.
<add>#
<add># It is not possible to automatically check the following libraries for version updates:
<add>#
<add># - libedit (incorrect LIBEDIT_MAJOR/MINOR in histedit.h)
<add># - uuid (not a standalone library)
<add>#
<add># Additionally, libffi version detection cannot be performed on systems running Mojave or earlier.
<add>#
<add># For indeterminable cases, consult https://opensource.apple.com for the version used.
<add>describe "pkg-config" do
<add> def pc_version(library)
<add> path = HOMEBREW_LIBRARY_PATH/"os/mac/pkgconfig/#{MacOS.version}/#{library}.pc"
<add> version = File.foreach(path)
<add> .lazy
<add> .grep(/^Version:\s*?(.+)$/) { Regexp.last_match(1) }
<add> .first
<add> .strip
<add> if (match = version.match(/^\${(.+?)}$/))
<add> version = File.foreach(path)
<add> .lazy
<add> .grep(/^#{match.captures.first}\s*?=\s*?(.+)$/) { Regexp.last_match(1) }
<add> .first
<add> .strip
<add> end
<add> version
<add> end
<add>
<add> let(:sdk) { MacOS.sdk_path_if_needed }
<add>
<add> it "returns the correct version for expat" do
<add> version = File.foreach("#{sdk}/usr/include/expat.h")
<add> .lazy
<add> .grep(/^#define XML_(MAJOR|MINOR|MICRO)_VERSION (\d+)$/) do
<add> { Regexp.last_match(1).downcase => Regexp.last_match(2) }
<add> end
<add> .inject(:merge!)
<add> version = "#{version["major"]}.#{version["minor"]}.#{version["micro"]}"
<add>
<add> expect(pc_version("expat")).to eq(version)
<add> end
<add>
<add> it "returns the correct version for libcurl" do
<add> version = File.foreach("#{sdk}/usr/include/curl/curlver.h")
<add> .lazy
<add> .grep(/^#define LIBCURL_VERSION "(.*?)"$/) { Regexp.last_match(1) }
<add> .first
<add>
<add> expect(pc_version("libcurl")).to eq(version)
<add> end
<add>
<add> it "returns the correct version for libexslt" do
<add> version = File.foreach("#{sdk}/usr/include/libexslt/exsltconfig.h")
<add> .lazy
<add> .grep(/^#define LIBEXSLT_VERSION (\d+)$/) { Regexp.last_match(1) }
<add> .first
<add> .rjust(6, "0")
<add> version = "#{version[-6..-5].to_i}.#{version[-4..-3].to_i}.#{version[-2..].to_i}"
<add>
<add> expect(pc_version("libexslt")).to eq(version)
<add> end
<add>
<add> it "returns the correct version for libffi" do
<add> version = File.foreach("#{sdk}/usr/include/ffi/ffi.h")
<add> .lazy
<add> .grep(/^\s*libffi (\S+) - Copyright /) { Regexp.last_match(1) }
<add> .first
<add>
<add> skip "Cannot detect system libffi version." if version == "PyOBJC"
<add>
<add> expect(pc_version("libffi")).to eq(version)
<add> end
<add>
<add> it "returns the correct version for libxml-2.0" do
<add> version = File.foreach("#{sdk}/usr/include/libxml2/libxml/xmlversion.h")
<add> .lazy
<add> .grep(/^#define LIBXML_DOTTED_VERSION "(.*?)"$/) { Regexp.last_match(1) }
<add> .first
<add>
<add> expect(pc_version("libxml-2.0")).to eq(version)
<add> end
<add>
<add> it "returns the correct version for libxslt" do
<add> version = File.foreach("#{sdk}/usr/include/libxslt/xsltconfig.h")
<add> .lazy
<add> .grep(/^#define LIBXSLT_DOTTED_VERSION "(.*?)"$/) { Regexp.last_match(1) }
<add> .first
<add>
<add> expect(pc_version("libxslt")).to eq(version)
<add> end
<add>
<add> it "returns the correct version for ncurses" do
<add> version = File.foreach("#{sdk}/usr/include/ncurses.h")
<add> .lazy
<add> .grep(/^#define NCURSES_VERSION_(MAJOR|MINOR|PATCH) (\d+)$/) do
<add> { Regexp.last_match(1).downcase => Regexp.last_match(2) }
<add> end
<add> .inject(:merge!)
<add> version = "#{version["major"]}.#{version["minor"]}.#{version["patch"]}"
<add>
<add> expect(pc_version("ncurses")).to eq(version)
<add> expect(pc_version("ncursesw")).to eq(version)
<add> end
<add>
<add> it "returns the correct version for sqlite3" do
<add> version = File.foreach("#{sdk}/usr/include/sqlite3.h")
<add> .lazy
<add> .grep(/^#define SQLITE_VERSION\s+?"(.*?)"$/) { Regexp.last_match(1) }
<add> .first
<add>
<add> expect(pc_version("sqlite3")).to eq(version)
<add> end
<add>
<add> it "returns the correct version for zlib" do
<add> version = File.foreach("#{sdk}/usr/include/zlib.h")
<add> .lazy
<add> .grep(/^#define ZLIB_VERSION "(.*?)"$/) { Regexp.last_match(1) }
<add> .first
<add>
<add> expect(pc_version("zlib")).to eq(version)
<add> end
<add>end | 1 |
Javascript | Javascript | fix bug where spinner wasn't called | 7301ba396915a54e1db9a2673a467639ff6cd0b1 | <ide><path>src/node.js
<ide>
<ide> nextTickQueue.push(obj);
<ide> infoBox[length]++;
<add>
<add> if (needSpinner) {
<add> _needTickCallback();
<add> needSpinner = false;
<add> }
<ide> }
<ide> };
<ide> | 1 |
Javascript | Javascript | increase fs promise coverage | 211cd0441a575222e9f0d3ce1f19091f8a5566cd | <ide><path>test/parallel/test-fs-promises-file-handle-readFile.js
<ide> const common = require('../common');
<ide> // FileHandle.readFile method.
<ide>
<ide> const fs = require('fs');
<del>const { open } = fs.promises;
<add>const {
<add> open,
<add> readFile,
<add> writeFile,
<add> truncate
<add>} = fs.promises;
<ide> const path = require('path');
<ide> const tmpdir = require('../common/tmpdir');
<add>const tick = require('../common/tick');
<ide> const assert = require('assert');
<ide> const tmpDir = tmpdir.path;
<ide>
<ide> async function validateReadFileProc() {
<ide> assert.ok(hostname.length > 0);
<ide> }
<ide>
<add>async function doReadAndCancel() {
<add> // Signal aborted from the start
<add> {
<add> const filePathForHandle = path.resolve(tmpDir, 'dogs-running.txt');
<add> const fileHandle = await open(filePathForHandle, 'w+');
<add> const buffer = Buffer.from('Dogs running'.repeat(10000), 'utf8');
<add> fs.writeFileSync(filePathForHandle, buffer);
<add> const controller = new AbortController();
<add> const { signal } = controller;
<add> controller.abort();
<add> await assert.rejects(readFile(fileHandle, { signal }), {
<add> name: 'AbortError'
<add> });
<add> }
<add>
<add> // Signal aborted on first tick
<add> {
<add> const filePathForHandle = path.resolve(tmpDir, 'dogs-running1.txt');
<add> const fileHandle = await open(filePathForHandle, 'w+');
<add> const buffer = Buffer.from('Dogs running'.repeat(10000), 'utf8');
<add> fs.writeFileSync(filePathForHandle, buffer);
<add> const controller = new AbortController();
<add> const { signal } = controller;
<add> tick(1, () => controller.abort());
<add> await assert.rejects(readFile(fileHandle, { signal }), {
<add> name: 'AbortError'
<add> });
<add> }
<add>
<add> // Signal aborted right before buffer read
<add> {
<add> const newFile = path.resolve(tmpDir, 'dogs-running2.txt');
<add> const buffer = Buffer.from('Dogs running'.repeat(1000), 'utf8');
<add> fs.writeFileSync(newFile, buffer);
<add>
<add> const fileHandle = await open(newFile, 'r');
<add>
<add> const controller = new AbortController();
<add> const { signal } = controller;
<add> tick(2, () => controller.abort());
<add> await assert.rejects(fileHandle.readFile({ signal, encoding: 'utf8' }), {
<add> name: 'AbortError'
<add> });
<add> }
<add>
<add> // Validate file size is within range for reading
<add> {
<add> // Variable taken from https://github.com/nodejs/node/blob/master/lib/internal/fs/promises.js#L5
<add> const kIoMaxLength = 2 ** 31 - 1;
<add>
<add> const newFile = path.resolve(tmpDir, 'dogs-running3.txt');
<add> await writeFile(newFile, Buffer.from('0'));
<add> await truncate(newFile, kIoMaxLength + 1);
<add>
<add> const fileHandle = await open(newFile, 'r');
<add>
<add> await assert.rejects(fileHandle.readFile(), {
<add> name: 'RangeError',
<add> code: 'ERR_FS_FILE_TOO_LARGE'
<add> });
<add> }
<add>}
<add>
<ide> validateReadFile()
<del> .then(() => validateReadFileProc())
<add> .then(validateReadFileProc)
<add> .then(doReadAndCancel)
<ide> .then(common.mustCall());
<ide><path>test/parallel/test-fs-promises-file-handle-writeFile.js
<ide> const common = require('../common');
<ide>
<ide> // The following tests validate base functionality for the fs.promises
<del>// FileHandle.readFile method.
<add>// FileHandle.writeFile method.
<ide>
<ide> const fs = require('fs');
<del>const { open } = fs.promises;
<add>const { open, writeFile } = fs.promises;
<ide> const path = require('path');
<ide> const tmpdir = require('../common/tmpdir');
<ide> const assert = require('assert');
<ide> async function validateWriteFile() {
<ide> await fileHandle.close();
<ide> }
<ide>
<add>// Signal aborted while writing file
<add>async function doWriteAndCancel() {
<add> const filePathForHandle = path.resolve(tmpDir, 'dogs-running.txt');
<add> const fileHandle = await open(filePathForHandle, 'w+');
<add> const buffer = Buffer.from('dogs running'.repeat(10000), 'utf8');
<add> const controller = new AbortController();
<add> const { signal } = controller;
<add> process.nextTick(() => controller.abort());
<add> await assert.rejects(writeFile(fileHandle, buffer, { signal }), {
<add> name: 'AbortError'
<add> });
<add>}
<add>
<ide> validateWriteFile()
<add> .then(doWriteAndCancel)
<ide> .then(common.mustCall());
<ide><path>test/parallel/test-fs-promises-writefile.js
<ide> async function doWriteWithCancel() {
<ide> }
<ide>
<ide> async function doAppend() {
<del> await fsPromises.appendFile(dest, buffer2);
<add> await fsPromises.appendFile(dest, buffer2, { flag: null });
<ide> const data = fs.readFileSync(dest);
<ide> const buf = Buffer.concat([buffer, buffer2]);
<ide> assert.deepStrictEqual(buf, data);
<ide><path>test/parallel/test-fs-promises.js
<ide> const {
<ide> link,
<ide> lchmod,
<ide> lstat,
<add> lutimes,
<ide> mkdir,
<ide> mkdtemp,
<ide> open,
<ide> async function getHandle(dest) {
<ide> await handle.close();
<ide> }
<ide>
<add> // Use fallback buffer allocation when input not buffer
<add> {
<add> const handle = await getHandle(dest);
<add> const ret = await handle.read(0, 0, 0, 0);
<add> assert.strictEqual(ret.buffer.length, 16384);
<add> }
<add>
<ide> // Bytes written to file match buffer
<ide> {
<ide> const handle = await getHandle(dest);
<ide> async function getHandle(dest) {
<ide> await handle.close();
<ide> }
<ide>
<add> // Set modification times with lutimes
<add> {
<add> const a_time = new Date();
<add> a_time.setMinutes(a_time.getMinutes() - 1);
<add> const m_time = new Date();
<add> m_time.setHours(m_time.getHours() - 1);
<add> await lutimes(dest, a_time, m_time);
<add> const stats = await stat(dest);
<add>
<add> assert.strictEqual(a_time.toString(), stats.atime.toString());
<add> assert.strictEqual(m_time.toString(), stats.mtime.toString());
<add> }
<add>
<ide> // create symlink
<ide> {
<ide> const newPath = path.resolve(tmpDir, 'baz2.js');
<ide> async function getHandle(dest) {
<ide> }
<ide> }
<ide>
<add> // specify symlink type
<add> {
<add> const dir = path.join(tmpDir, nextdir());
<add> await symlink(tmpDir, dir, 'dir');
<add> const stats = await lstat(dir);
<add> assert.strictEqual(stats.isSymbolicLink(), true);
<add> await unlink(dir);
<add> }
<add>
<ide> // create hard link
<ide> {
<ide> const newPath = path.resolve(tmpDir, 'baz2.js');
<ide> async function getHandle(dest) {
<ide> await unlink(newFile);
<ide> }
<ide>
<add> // Use fallback encoding when input is null
<add> {
<add> const newFile = path.resolve(tmpDir, 'dogs_running.js');
<add> await writeFile(newFile, 'dogs running', { encoding: null });
<add> const fileExists = fs.existsSync(newFile);
<add> assert.strictEqual(fileExists, true);
<add> }
<add>
<ide> // `mkdir` when options is number.
<ide> {
<ide> const dir = path.join(tmpDir, nextdir()); | 4 |
Javascript | Javascript | reduce bytes and minor adjustments | cec4018d0e5249203aaba203cd67147a1162b435 | <ide><path>src/support.js
<ide> jQuery.support = (function() {
<ide> // Run fixed position tests at doc ready to avoid a crash
<ide> // related to the invisible body in IE8
<ide> jQuery(function() {
<del> var outer, inner, table, td, offsetSupport,
<add> var container, outer, inner, table, td, offsetSupport,
<ide> conMarginTop = 1,
<ide> ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",
<add> vb = "visibility:hidden;border:0;",
<ide> style = "style='" + ptlm + "border:5px solid #000;padding:0;'",
<ide> html = "<div " + style + "><div></div></div>" +
<ide> "<table " + style + " cellpadding='0' cellspacing='0'>" +
<del> "<tbody><tr><td></td></tr></tbody></table>";
<add> "<tr><td></td></tr></table>";
<ide>
<ide> // Reconstruct a container
<ide> body = document.getElementsByTagName("body")[0];
<ide> container = document.createElement("div");
<del> container.style.cssText = "width:0;height:0;border:0;visibility:hidden;position:static;top:0;marginTop:" + conMarginTop + "px";
<add> container.style.cssText = vb + "width:0;height:0;position:static;top:0;marginTop:" + conMarginTop + "px";
<ide> body.insertBefore( container, body.firstChild );
<ide>
<ide> // Construct a test element
<ide> testElement = document.createElement("div");
<del> testElement.style.cssText = ptlm + "border:0;visibility:hidden";
<add> testElement.style.cssText = ptlm + vb;
<ide>
<ide> testElement.innerHTML = html;
<ide> container.appendChild( testElement );
<ide> outer = testElement.firstChild;
<ide> inner = outer.firstChild;
<del> td = outer.nextSibling.firstChild.firstChild.firstChild;
<add> td = outer.nextSibling.firstChild.firstChild;
<ide>
<ide> offsetSupport = {
<ide> doesNotAddBorder: ( inner.offsetTop !== 5 ),
<ide> jQuery.support = (function() {
<ide> testElementParent.removeChild( testElement );
<ide>
<ide> // Null connected elements to avoid leaks in IE
<del> fragment = select = opt = body = marginDiv = div = input = null;
<add> testElement = fragment = select = opt = body = marginDiv = div = input = null;
<ide>
<ide> return support;
<ide> })(); | 1 |
Ruby | Ruby | check formula options properly to rule out bottle | 82d1310800dc225e8c561fb07c76a1e85434fdd4 | <ide><path>Library/Homebrew/bottles.rb
<ide> def install_bottle? f
<ide> return true if ARGV.include? '--install-bottle'
<ide> not ARGV.build_from_source? \
<ide> and ARGV.bottles_supported? \
<del> and ARGV.options_only.empty? \
<add> and ARGV.used_options(f).empty? \
<ide> and bottle_current?(f)
<ide> end
<ide> | 1 |
Text | Text | update first package documentation | 5be6cfa67884b43ea7cefff3acbc4f2d0f1f1f1b | <ide><path>docs/your-first-package.md
<del># Creating Your First Package
<add># Create Your First Package
<ide>
<del>Let's take a look at creating your first package.
<add>We are going to create a simple package that replaces selected text with ascii
<add>art. So if "cool" was selected the output would be:
<ide>
<del>To get started, hit `cmd-shift-P`, and start typing "Generate Package" to generate
<del>a package. Once you select the "Generate Package" command, it'll ask you for a
<del>name for your new package. Let's call ours _changer_.
<del>
<del>Atom will pop open a new window, showing the _changer_ package with a default set of
<del>folders and files created for us. Hit `cmd-shift-P` and start typing "Changer." You'll
<del>see a new `Changer:Toggle` command which, if selected, pops up a greeting. So far,
<del>so good!
<del>
<del>In order to demonstrate the capabilities of Atom and its API, our Changer plugin
<del>is going to do two things:
<del>
<del>1. It'll show only modified files in the file tree
<del>2. It'll append a new pane to the editor with some information about the modified
<del>files
<del>
<del>Let's get started!
<del>
<del>## Changing Keybindings and Commands
<del>
<del>Since Changer is primarily concerned with the file tree, let's write a
<del>key binding that works only when the tree is focused. Instead of using the
<del>default `toggle`, our keybinding executes a new command called `magic`.
<del>
<del>_keymaps/changer.cson_ should change to look like this:
<del>
<del>```coffeescript
<del>'.tree-view':
<del> 'ctrl-V': 'changer:magic'
<ide> ```
<del>
<del>Notice that the keybinding is called `ctrl-V` — that's actually `ctrl-shift-v`.
<del>You can use capital letters to denote using `shift` for your binding.
<del>
<del>`.tree-view` represents the parent container for the tree view.
<del>Keybindings only work within the context of where they're entered. In this case,
<del>hitting `ctrl-V` anywhere other than tree won't do anything. Obviously, you can
<del>bind to any part of the editor using element, id, or class names. For example,
<del>you can map to `body` if you want to scope to anywhere in Atom, or just `.editor`
<del>for the editor portion.
<del>
<del>To bind keybindings to a command, we'll need to do a bit of association in our
<del>CoffeeScript code using the `atom.workspaceView.command` method. This method takes a command
<del>name and executes a callback function. Open up _lib/changer-view.coffee_, and
<del>change `atom.workspaceView.command "changer:toggle"` to look like this:
<del>
<del>```coffeescript
<del>atom.workspaceView.command "changer:magic", => @magic()
<add> /\_ \
<add> ___ ___ ___\//\ \
<add> /'___\ / __`\ / __`\\ \ \
<add>/\ \__//\ \L\ \/\ \L\ \\_\ \_
<add>\ \____\ \____/\ \____//\____\
<add> \/____/\/___/ \/___/ \/____/
<ide> ```
<ide>
<del>It's common practice to namespace your commands with your package name, separated
<del>with a colon (`:`). Make sure to rename your `toggle` method to `magic` as well.
<add>The final package can be viewed at
<add>[https://github.com/atom/ascii-art]([https://github.com/atom/ascii-art]).
<ide>
<del>Every time you reload the Atom editor, changes to your package code will be reevaluated,
<del>just as if you were writing a script for the browser. Reload the editor, click on
<del>the tree, hit your keybinding, and...nothing happens! What the heck?!
<add>To begin, press `cmd-shift-P` to bring up the Command Palette. Type "generate
<add>package" and select the "Package Generator: Generate Package" command. You will
<add>be prompt for package name, let's call ours _ascii-art_.
<ide>
<del>Open up the _package.json_ file, and find the property called `activationEvents`.
<del>Basically, this key tells Atom to not load a package until it hears a certain event.
<del>Change the event to `changer:magic` and reload the editor:
<add>Atom will open a new window with the _ascii-art_ package contents displayed in
<add>the Tree View. This window will already has the Ascii Art package installed. If
<add>you toggle the Command Palette `cmd-shift-P` and type "Ascii Art" you'll see a
<add>new `Ascii Art: Toggle` command. If triggered, this command displays a message
<add>created by the package generator.
<ide>
<del>```json
<del>"activationEvents": ["changer:magic"]
<del>```
<del>
<del>Hitting the key binding on the tree now works!
<del>
<del>## Working with Styles
<del>
<del>The next step is to hide elements in the tree that aren't modified. To do that,
<del>we'll first try and get a list of files that have not changed.
<del>
<del>All packages are able to use jQuery in their code. In fact, there's [a list of
<del>the bundled libraries Atom provides by default][bundled-libs].
<del>
<del>We bring in jQuery by requiring the `atom` package and binding it to the `$` variable:
<add>Now let's edit the package files to make our ascii art package work! Since this
<add>package doesn't need any UI we can remove all view related code. Start by
<add>opening up _lib/ascii-art.coffee_. Remove all view code until the file looks
<add>like this:
<ide>
<ide> ```coffeescript
<del>{$, View} = require 'atom'
<add> module.exports =
<add> activate: ->
<ide> ```
<ide>
<del>Now, we can define the `magic` method to query the tree to get us a list of every
<del>file that _wasn't_ modified:
<del>
<del>```coffeescript
<del>magic: ->
<del> $('ol.entries li').each (i, el) ->
<del> if !$(el).hasClass("status-modified")
<del> console.log el
<del>```
<add>## Create Command
<ide>
<del>You can access the dev console by hitting `alt-cmd-i`. Here, you'll see all the
<del>statements from `console` calls. When we execute the `changer:magic` command, the
<del>browser console lists items that are not being modified (_i.e._, those without the
<del>`status-modified` class). Let's add a class to each of these elements called `hide-me`:
<add>Now let's add a command. It's recommended to namespace your commands with your
<add>package name, separated with a colon (`:`). So we'll call this command
<add>`ascii-art:convert`. Register the command in _lib/ascii-art.coffee_:
<ide>
<ide> ```coffeescript
<del>magic: ->
<del> $('ol.entries li').each (i, el) ->
<del> if !$(el).hasClass("status-modified")
<del> $(el).addClass("hide-me")
<del>```
<add>module.exports =
<add> activate: ->
<add> atom.workspaceView.command "ascii-art:convert", => @convert()
<ide>
<del>With our newly added class, we can manipulate the visibility of the elements
<del>with a simple stylesheet. Open up _changer.css_ in the _stylesheets_ directory,
<del>and add a single entry:
<del>
<del>```css
<del>ol.entries .hide-me {
<del> display: none;
<del>}
<add> convert: ->
<add> # This assumes the active pane item is an editor
<add> editor = atom.workspace.activePaneItem.
<add> selection = editor.getSelection()
<add> upperCaseSelectedText = selection.getText().toUpperCase()
<add> selection.insertText(upperCaseSelectedText)
<ide> ```
<ide>
<del>Refresh Atom, and run the `changer` command. You'll see all the non-changed
<del>files disappear from the tree. Success!
<del>
<del>![Changer_File_View]
<add>`atom.workspaceView.command` method takes a command name and a callback. The
<add>callback executes when the command is triggered. In this case, when the command
<add>is triggered the callback will uppercase the selected text.
<ide>
<del>There are a number of ways you can get the list back; let's just naively iterate
<del>over the same elements and remove the class:
<del>
<del>```coffeescript
<del>magic: ->
<del> $('ol.entries li').each (i, el) ->
<del> if !$(el).hasClass("status-modified")
<del> if !$(el).hasClass("hide-me")
<del> $(el).addClass("hide-me")
<del> else
<del> $(el).removeClass("hide-me")
<del>```
<add>## Reload The Package
<ide>
<del>## Creating a New Panel
<add>Before we trigger the `ascii-art:convert` we'll need to reload the window. This
<add>will reevaluate our package code, just as if we were writing a script for the
<add>browser. Trigger `window:reload` command using the command palette or press
<add>`ctrl-alt-cmd-l`.
<ide>
<del>The next goal of this package is to append a panel to the Atom editor that lists
<del>some information about the modified files.
<add>## Trigger the command
<ide>
<del>To do that, we're going to first open up [the style guide][styleguide]. The Style
<del>Guide lists every type of UI element that can be created by an Atom package. Aside
<del>from helping you avoid writing fresh code from scratch, it ensures that packages
<del>have the same look and feel no matter how they're built.
<del>
<del>Every package that extends from the `View` class can provide an optional class
<del>method called `content`. The `content` method constructs the DOM that your
<del>package uses as its UI. The principals of `content` are built entirely on
<del>[SpacePen][space-pen], which we'll touch upon only briefly here.
<del>
<del>Our display will simply be an unordered list of the file names, and their
<del>modified times. We'll append this list to a panel on the bottom of the editor. A
<del>basic `panel` element inside a `tool-panel` will work well for us. Let's start by carving out a
<del>`div` to hold the filenames:
<del>
<del>```coffeescript
<del>@content: ->
<del> @div class: "changer tool-panel panel-bottom", =>
<del> @div class: "panel", =>
<del> @div class: "panel-heading", "Modified Files"
<del> @div class: "panel-body padded", outlet: 'modifiedFilesContainer', =>
<del> @ul class: 'modified-files-list', outlet: 'modifiedFilesList', =>
<del> @li 'Modified File Test'
<del> @li 'Modified File Test'
<del>```
<del>
<del>You can add any HTML attribute you like. `outlet` names the variable your
<del>package can use to manipulate the element directly. The fat arrow (`=>`)
<del>indicates that the next DOM set are nested children.
<del>
<del>Once again, you can style `li` elements using your stylesheets. Let's test that
<del>out by adding these lines to the _changer.css_ file:
<del>
<del>```css
<del>ul.modified-files-list {
<del> color: white;
<del>}
<del>```
<del>
<del>We'll add one more line to the end of the `magic` method to make this pane
<del>appear:
<del>
<del>```coffeescript
<del>atom.workspaceView.prependToBottom(this)
<del>```
<del>
<del>If you refresh Atom and hit the key command, you'll see a box appear right
<del>underneath the editor:
<del>
<del>![Changer_Panel_Append]
<del>
<del>As you might have guessed, `atom.workspaceView.prependToBottom` tells Atom to
<del>prepend `this` item (_i.e._, whatever is defined by`@content`). If we had called
<del>`atom.workspaceView.appendToBottom`, the pane would be attached below the status
<del>bar.
<del>
<del>Before we populate this panel for real, let's apply some logic to toggle the
<del>pane off and on, just like we did with the tree view. Replace the
<del>`atom.workspaceView.prependToBottom` call with this code:
<add>Open the command panel and search for the `ascii-art:convert` command. Its not
<add>there, what the heck?! To fix this open _package.json_ and find the property
<add>called `activationEvents`. Activation Events speed up load time by allowing an
<add>Atom to delay it's activation until needed. So add the `ascii-art:convert` to
<add>the activationEvents array:
<ide>
<ide> ```coffeescript
<del># toggles the pane
<del>if @hasParent()
<del> @remove()
<del>else
<del> atom.workspaceView.prependToBottom(this)
<add>"activationEvents": ["ascii-art:convert"],
<ide> ```
<ide>
<del>There are about a hundred different ways to toggle a pane on and off, and this
<del>might not be the most efficient one. If you know your package needs to be
<del>toggled on and off more freely, it might be better to draw the interface during the
<del>initialization, then immediately call `hide()` on the element to remove it from
<del>the view. You can then swap between `show()` and `hide()`, and instead of
<del>forcing Atom to add and remove the element as we're doing here, it'll just set a
<del>CSS property to control your package's visibility.
<del>
<del>Refresh Atom, hit the key combo, and watch your test list appear and disappear.
<add>Now reload window `ctrl-alt-cmd-l` and use the command panel to trigger the
<add>`ascii-art:convert` command. It will uppercase any text you have selected.
<ide>
<del>## Calling Node.js Code
<add>## Add Key Binding
<ide>
<del>Since Atom is built on top of [Node.js][node], you can call any of its libraries,
<del>including other modules that your package requires.
<add>Now let's add a key binding to trigger the `ascii-art:convert` command. Open
<add>_keymaps/ascii-art.cson_ and add a key binding linking `ctrl-alt-a` to the
<add>`ascii-art:convert` command.
<ide>
<del>We'll iterate through our resulting tree, and construct the path to our modified
<del>file based on its depth in the tree. We'll use Node to handle path joining for
<del>directories.
<del>
<del>Add the following Node module to the top of your file:
<add>When finished, the file will look like this:
<ide>
<ide> ```coffeescript
<del>path = require 'path'
<add>'.editor':
<add> 'cmd-alt-a': 'ascii-art:convert'
<ide> ```
<ide>
<del>Then, add these lines to your `magic` method, _before_ your pane drawing code:
<add>Notice the `.editor` line. This limits the key binding to only work when the
<add>focused element matches the selector `.editor`, much like CSS. For example, if
<add>the Tree View has focus, pressing `cmd-alt-a` won't trigger the
<add>`ascii-art:convert` command. But if the editor has focus, the
<add>`ascii-art:convert` method will be triggered. More information on key bindings
<add>can be found in the [keymaps][keymaps] documentation.
<ide>
<del>```coffeescript
<del>modifiedFiles = []
<del># for each single entry...
<del>$('ol.entries li.file.status-modified span.name').each (i, el) ->
<del> filePath = []
<del> # ...grab its name...
<del> filePath.unshift($(el).text())
<del>
<del> # ... then find its parent directories, and grab their names
<del> parents = $(el).parents('.directory.status-modified')
<del> parents.each (i, el) ->
<del> filePath.unshift($(el).find('div.header span.name').eq(0).text())
<del>
<del> modifiedFilePath = path.join(atom.project.rootDirectory.path, filePath.join(path.sep))
<del> modifiedFiles.push modifiedFilePath
<del>```
<add>Now reload the window and verify that pressing the key binding works! You can
<add>also verify that it **doesn't** work when the Tree View is focused.
<ide>
<del>`modifiedFiles` is an array containing a list of our modified files. We're also
<del>using the node.js [`path` library][path] to get the proper directory separator
<del>for our system.
<add>## Add The Ascii Art
<ide>
<del>Remove the two `@li` elements we added in `@content`, so that we can
<del>populate our `modifiedFilesList` with real information. We'll do that by
<del>iterating over `modifiedFiles`, accessing a file's last modified time, and
<del>appending it to `modifiedFilesList`:
<add>Now the fun part, we need to convert the selected text to ascii art. To do this
<add>we will use the [figlet node module](https://npmjs.org/package/figlet). Open
<add>_package.json_ add the latest version of figlet to the dependencies:
<ide>
<ide> ```coffeescript
<del># toggles the pane
<del>if @hasParent()
<del> @remove()
<del>else
<del> for file in modifiedFiles
<del> stat = fs.lstatSync(file)
<del> mtime = stat.mtime
<del> @modifiedFilesList.append("<li>#{file} - Modified at #{mtime}")
<del> atom.workspaceView.prependToBottom(this)
<add> "dependencies": {
<add> "figlet": "1.0.8"
<add> }
<ide> ```
<ide>
<del>When you toggle the modified files list, your pane is now populated with the
<del>filenames and modified times of files in your project:
<add>NOW GO TO THE COMMAND LINE AND RUN APM UPDATE BUT REALLY THIS STEP SEEMS LIKE
<add>IT COULD BE AN ATOM COMMAND.
<ide>
<del>![Changer_Panel_Timestamps]
<del>
<del>You might notice that subsequent calls to this command reduplicate information.
<del>We could provide an elegant way of rechecking files already in the list, but for
<del>this demonstration, we'll just clear the `modifiedFilesList` each time it's closed:
<add>Now you can require the figlet node module in _lib/ascii-art.coffee_ and
<add>instead of uppercasing the text, you can convert it to ascii art!
<ide>
<ide> ```coffeescript
<del># toggles the pane
<del>if @hasParent()
<del> @modifiedFilesList.empty() # added this to clear the list on close
<del> @remove()
<del>else
<del> for file in modifiedFiles
<del> stat = fs.lstatSync(file)
<del> mtime = stat.mtime
<del> @modifiedFilesList.append("<li>#{file} - Modified at #{mtime}")
<del> atom.workspaceView.prependToBottom(this)
<del>```
<del>
<del>## Coloring UI Elements
<del>
<del>For packages that create new UI elements, adhering to the style guide is just one
<del>part to keeping visual consistency. Packages dealing with color, fonts, padding,
<del>margins, and other visual cues should rely on [Theme Variables][theme-vars], instead
<del>of developing individual styles. Theme variables are variables defined by Atom
<del>for use in packages and themes. They're only available in [`LESS`](http://lesscss.org/)
<del>stylesheets.
<add>convert: ->
<add> # This assumes the active pane item is an editor
<add> selection = atom.workspace.activePaneItem.getSelection()
<ide>
<del>For our package, let's remove the style defined by `ul.modified-files-list` in
<del>_changer.css_. Create a new file under the _stylesheets_ directory called _text-colors.less_.
<del>Here, we'll import the _ui-variables.less_ file, and define some Atom-specific
<del>styles:
<del>
<del>```less
<del>@import "ui-variables";
<del>
<del>ul.modified-files-list {
<del> color: @text-color;
<del> background-color: @background-color-info;
<del>}
<add> figlet = require 'figlet'
<add> figlet selection.getText(), {font: "Larry 3D 2"}, (error, asciiArt) ->
<add> if error
<add> console.error(error)
<add> else
<add> selection.insertText("\n" + asciiArt + "\n")
<ide> ```
<ide>
<del>Using theme variables ensures that packages look great alongside any theme.
<del>
<ide> ## Further reading
<ide>
<ide> For more information on the mechanics of packages, check out
<ide> [Creating a Package][creating-a-package].
<ide>
<add>[keymaps]: advanced/keymaps.html
<ide> [bundled-libs]: creating-a-package.html#included-libraries
<ide> [styleguide]: https://github.com/atom/styleguide
<ide> [space-pen]: https://github.com/atom/space-pen | 1 |
Text | Text | update stale event docs in tutorial | ea82dba555b3380bb7d3bd53c82276388657f102 | <ide><path>docs/docs/tutorial.md
<ide> var CommentForm = React.createClass({
<ide>
<ide> #### Events
<ide>
<del>React attaches event handlers to components using a camelCase naming convention. We attach an onKeyUp handler to the text field, check if the user has entered text and pressed the enter key and then clear the form fields.
<add>React attaches event handlers to components using a camelCase naming convention. We attach an onSubmit handler to the form that clear the form fields if the user has entered text in both.
<ide>
<ide> `React.autoBind()` is a simple way to ensure that a method is always bound to its component. Inside the method, `this` will be bound to the component instance.
<ide> | 1 |
Javascript | Javascript | avoid an allocation in readcharcode() | 61e6b576d40134c2921a9c738e362fd507df32a3 | <ide><path>src/core/cmap.js
<ide> var CMap = (function CMapClosure() {
<ide> return this._map;
<ide> },
<ide>
<del> readCharCode: function(str, offset) {
<add> readCharCode: function(str, offset, out) {
<ide> var c = 0;
<ide> var codespaceRanges = this.codespaceRanges;
<ide> var codespaceRangesLen = this.codespaceRanges.length;
<ide> var CMap = (function CMapClosure() {
<ide> var low = codespaceRange[k++];
<ide> var high = codespaceRange[k++];
<ide> if (c >= low && c <= high) {
<del> return [c, n + 1];
<add> out.charcode = c;
<add> out.length = n + 1;
<add> return;
<ide> }
<ide> }
<ide> }
<del>
<del> return [0, 1];
<add> out.charcode = 0;
<add> out.length = 1;
<ide> }
<ide> };
<ide> return CMap;
<ide><path>src/core/fonts.js
<ide> var Font = (function FontClosure() {
<ide> if (this.cMap) {
<ide> // composite fonts have multi-byte strings convert the string from
<ide> // single-byte to multi-byte
<add> var c = {};
<ide> while (i < chars.length) {
<del> var c = this.cMap.readCharCode(chars, i);
<del> charcode = c[0];
<del> var length = c[1];
<add> this.cMap.readCharCode(chars, i, c);
<add> charcode = c.charcode;
<add> var length = c.length;
<ide> i += length;
<ide> glyph = this.charToGlyph(charcode);
<ide> glyphs.push(glyph);
<ide><path>test/unit/cmap_spec.js
<ide> describe('cmap', function() {
<ide> 'endcodespacerange\n';
<ide> var stream = new StringStream(str);
<ide> var cmap = CMapFactory.create(stream);
<del> var c = cmap.readCharCode(String.fromCharCode(1), 0);
<del> expect(c[0]).toEqual(1);
<del> expect(c[1]).toEqual(1);
<del> c = cmap.readCharCode(String.fromCharCode(0, 0, 0, 3), 0);
<del> expect(c[0]).toEqual(3);
<del> expect(c[1]).toEqual(4);
<add> var c = {};
<add> cmap.readCharCode(String.fromCharCode(1), 0, c);
<add> expect(c.charcode).toEqual(1);
<add> expect(c.length).toEqual(1);
<add> cmap.readCharCode(String.fromCharCode(0, 0, 0, 3), 0, c);
<add> expect(c.charcode).toEqual(3);
<add> expect(c.length).toEqual(4);
<ide> });
<ide> it('decodes 4 byte codespace ranges', function() {
<ide> var str = '1 begincodespacerange\n' +
<ide> '<8EA1A1A1> <8EA1FEFE>\n' +
<ide> 'endcodespacerange\n';
<ide> var stream = new StringStream(str);
<ide> var cmap = CMapFactory.create(stream);
<del> var c = cmap.readCharCode(String.fromCharCode(0x8E, 0xA1, 0xA1, 0xA1), 0);
<del> expect(c[0]).toEqual(0x8EA1A1A1);
<del> expect(c[1]).toEqual(4);
<add> var c = {};
<add> cmap.readCharCode(String.fromCharCode(0x8E, 0xA1, 0xA1, 0xA1), 0, c);
<add> expect(c.charcode).toEqual(0x8EA1A1A1);
<add> expect(c.length).toEqual(4);
<ide> });
<ide> it('read usecmap', function() {
<ide> var str = '/Adobe-Japan1-1 usecmap\n'; | 3 |
Javascript | Javascript | add tests for application#injecttesthelpers | f61439fb16d852e46916715ec75b535b92af2cd3 | <ide><path>packages/ember-testing/tests/helpers_test.js
<ide> var App;
<ide>
<del>module("ember-testing Helpers", {
<del> teardown: function() {
<add>function cleanup(){
<add> if (App) {
<ide> Ember.run(App, App.destroy);
<ide> App.removeTestHelpers();
<ide> App = null;
<del> Ember.TEMPLATES = {};
<ide> }
<add>
<add> Ember.run(function(){
<add> Ember.$(document).off('ajaxStart');
<add> Ember.$(document).off('ajaxStop');
<add> });
<add>
<add> Ember.TEMPLATES = {};
<add>}
<add>
<add>module("ember-testing Helpers", {
<add> setup: function(){ cleanup(); },
<add> teardown: function() { cleanup(); }
<ide> });
<ide>
<ide> test("Ember.Application#injectTestHelpers/#removeTestHelpers", function() {
<ide> test("`click` triggers appropriate events in order", function() {
<ide> });
<ide> });
<ide>
<add>test("Ember.Application#injectTestHelpers", function() {
<add> var documentEvents;
<add>
<add> Ember.run(function() {
<add> App = Ember.Application.create();
<add> App.setupForTesting();
<add> });
<add>
<add> documentEvents = Ember.$._data(document, 'events');
<add>
<add> if (!documentEvents) {
<add> documentEvents = {};
<add> }
<add>
<add> ok(documentEvents['ajaxStart'] === undefined, 'there are no ajaxStart listers setup prior to calling injectTestHelpers');
<add> ok(documentEvents['ajaxStop'] === undefined, 'there are no ajaxStop listers setup prior to calling injectTestHelpers');
<add>
<add> App.injectTestHelpers();
<add> documentEvents = Ember.$._data(document, 'events');
<add>
<add> equal(documentEvents['ajaxStart'].length, 1, 'calling injectTestHelpers registers an ajaxStart handler');
<add> equal(documentEvents['ajaxStop'].length, 1, 'calling injectTestHelpers registers an ajaxStop handler');
<add>});
<add>
<add>test("Ember.Application#injectTestHelpers calls callbacks registered with onInjectHelpers", function(){
<add> var injected = 0;
<add>
<add> Ember.Test.onInjectHelpers(function(){
<add> injected++;
<add> });
<add>
<add> Ember.run(function() {
<add> App = Ember.Application.create();
<add> App.setupForTesting();
<add> });
<add>
<add> equal(injected, 0, 'onInjectHelpers are not called before injectTestHelpers');
<add>
<add> App.injectTestHelpers();
<add>
<add> equal(injected, 1, 'onInjectHelpers are called after injectTestHelpers');
<add>});
<add>
<ide> if (Ember.FEATURES.isEnabled("ember-testing-wait-hooks")) {
<ide> test("`wait` respects registerWaiters", function() {
<ide> expect(2);
<ide> if (Ember.FEATURES.isEnabled("ember-testing-wait-hooks")) {
<ide>
<ide> module("ember-testing pendingAjaxRequests", {
<ide> setup: function(){
<del> Ember.run(function(){
<del> Ember.$(document).off('ajaxStart');
<del> Ember.$(document).off('ajaxStop');
<del> });
<add> cleanup();
<ide>
<ide> Ember.run(function() {
<ide> App = Ember.Application.create();
<ide> module("ember-testing pendingAjaxRequests", {
<ide> App.injectTestHelpers();
<ide> },
<ide>
<del> teardown: function() {
<del> Ember.run(App, App.destroy);
<del> App.removeTestHelpers();
<del> App = null;
<del> Ember.TEMPLATES = {};
<del> }
<add> teardown: function() { cleanup(); }
<ide> });
<ide>
<ide> test("pendingAjaxRequests is incremented on each document ajaxStart event", function() { | 1 |
PHP | PHP | add test case cakephp | 725ca399d77b19e515075625c3f695c0f05bc5f9 | <ide><path>tests/TestCase/Validation/ValidationTest.php
<ide> public function testLocalizedTime()
<ide>
<ide> $this->assertFalse(Validation::localizedTime('', 'date'));
<ide> $this->assertFalse(Validation::localizedTime('invalid', 'date'));
<add> $this->assertFalse(Validation::localizedTime(1, 'date'));
<add> $this->assertFalse(Validation::localizedTime(['an array'], 'date'));
<ide>
<ide> // English (US)
<ide> I18n::setLocale('en_US'); | 1 |
Javascript | Javascript | delay closing stream | 87cd389bbfe69004c4792d4982908a350238a6da | <ide><path>lib/internal/http2/core.js
<ide> class Http2Stream extends Duplex {
<ide> !(state.flags & STREAM_FLAGS_HAS_TRAILERS) &&
<ide> !state.didRead &&
<ide> this.readableFlowing === null) {
<del> this.close();
<add> // By using setImmediate we allow pushStreams to make it through
<add> // before the stream is officially closed. This prevents a bug
<add> // in most browsers where those pushStreams would be rejected.
<add> setImmediate(this.close.bind(this));
<ide> }
<ide> }
<ide> }
<ide> class ServerHttp2Stream extends Http2Stream {
<ide> let headRequest = false;
<ide> if (headers[HTTP2_HEADER_METHOD] === HTTP2_METHOD_HEAD)
<ide> headRequest = options.endStream = true;
<del> options.readable = !options.endStream;
<add> options.readable = false;
<ide>
<ide> const headersList = mapToHeaders(headers);
<ide> if (!Array.isArray(headersList)) | 1 |
Javascript | Javascript | add fast toarray and toobject to raw sequences | 1eed7e134280d96b7b73c5fbb895cfa52e00cc32 | <ide><path>dist/Sequence.js
<ide> for(IndexedSequence____Key in IndexedSequence){if(IndexedSequence.hasOwnProperty
<ide> this.$ArraySequence_array = array;
<ide> }
<ide>
<add> ArraySequence.prototype.toArray=function() {"use strict";
<add> return this.$ArraySequence_array;
<add> };
<add>
<ide> ArraySequence.prototype.cacheResult=function() {"use strict";
<ide> return this;
<ide> };
<ide> for(Sequence____Key in Sequence){if(Sequence.hasOwnProperty(Sequence____Key)){Ob
<ide> this.$ObjectSequence_object = object;
<ide> }
<ide>
<add> ObjectSequence.prototype.toObject=function() {"use strict";
<add> return this.$ObjectSequence_object;
<add> };
<add>
<ide> ObjectSequence.prototype.cacheResult=function() {"use strict";
<ide> this.length = Object.keys(this.$ObjectSequence_object).length;
<ide> return this;
<ide><path>src/Sequence.js
<ide> class ArraySequence extends IndexedSequence {
<ide> this._array = array;
<ide> }
<ide>
<add> toArray() {
<add> return this._array;
<add> }
<add>
<ide> cacheResult() {
<ide> return this;
<ide> }
<ide> class ObjectSequence extends Sequence {
<ide> this._object = object;
<ide> }
<ide>
<add> toObject() {
<add> return this._object;
<add> }
<add>
<ide> cacheResult() {
<ide> this.length = Object.keys(this._object).length;
<ide> return this; | 2 |
Java | Java | remove deprecated usage in contrib modules | 22048a3b89112a924ece815eb9531fd8b1bea1c1 | <ide><path>rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/AsyncTest.java
<ide> public String call() {
<ide> return "one";
<ide> }
<ide> };
<del> assertEquals("one", Async.start(func).toBlockingObservable().single());
<add> assertEquals("one", Async.start(func).toBlocking().single());
<ide> }
<ide>
<ide> @Test(expected = RuntimeException.class)
<ide> public String call() {
<ide> throw new RuntimeException("Some error");
<ide> }
<ide> };
<del> Async.start(func).toBlockingObservable().single();
<add> Async.start(func).toBlocking().single();
<ide> }
<ide>
<ide> @Test
<ide><path>rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorDeferFutureTest.java
<ide> public Observable<Integer> call() throws Exception {
<ide> if (!ready.await(1000, TimeUnit.MILLISECONDS)) {
<ide> throw new IllegalStateException("Not started in time");
<ide> }
<del> return Observable.from(1);
<add> return Observable.just(1);
<ide> }
<ide> });
<ide> }
<ide><path>rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorForEachFutureTest.java
<ide> public void testSimple() {
<ide> final ExecutorService exec = Executors.newCachedThreadPool();
<ide>
<ide> try {
<del> Observable<Integer> source = Observable.from(1, 2, 3)
<add> Observable<Integer> source = Observable.just(1, 2, 3)
<ide> .subscribeOn(Schedulers.computation());
<ide>
<ide> final AtomicInteger sum = new AtomicInteger();
<ide> public void call(Integer t1) {
<ide>
<ide> @Test
<ide> public void testSimpleScheduled() {
<del> Observable<Integer> source = Observable.from(1, 2, 3)
<add> Observable<Integer> source = Observable.just(1, 2, 3)
<ide> .subscribeOn(Schedulers.computation());
<ide>
<ide> final AtomicInteger sum = new AtomicInteger();
<ide><path>rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/Statement.java
<ide> public static <K, R> Observable<R> switchCase(Func0<? extends K> caseSelector,
<ide> */
<ide> public static <K, R> Observable<R> switchCase(Func0<? extends K> caseSelector,
<ide> Map<? super K, ? extends Observable<? extends R>> mapOfCases, Scheduler scheduler) {
<del> return switchCase(caseSelector, mapOfCases, Observable.<R> empty(scheduler));
<add> return switchCase(caseSelector, mapOfCases, Observable.<R> empty().subscribeOn(scheduler));
<ide> }
<ide>
<ide> /**
<ide> public static <R> Observable<R> ifThen(Func0<Boolean> condition, Observable<? ex
<ide> * Observable running on the specified Scheduler otherwise
<ide> */
<ide> public static <R> Observable<R> ifThen(Func0<Boolean> condition, Observable<? extends R> then, Scheduler scheduler) {
<del> return ifThen(condition, then, Observable.<R> empty(scheduler));
<add> return ifThen(condition, then, Observable.<R> empty().subscribeOn(scheduler));
<ide> }
<ide>
<ide> /**
<ide><path>rxjava-contrib/rxjava-computation-expressions/src/test/java/rx/operators/OperatorConditionalsTest.java
<ide> <T> void observeSequenceError(Observable<? extends T> source, Class<? extends Th
<ide>
<ide> @Test
<ide> public void testSimple() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<del> Observable<Integer> source2 = Observable.from(4, 5, 6);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<add> Observable<Integer> source2 = Observable.just(4, 5, 6);
<ide>
<ide> Map<Integer, Observable<Integer>> map = new HashMap<Integer, Observable<Integer>>();
<ide> map.put(1, source1);
<ide> public void testSimple() {
<ide>
<ide> @Test
<ide> public void testDefaultCase() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<del> Observable<Integer> source2 = Observable.from(4, 5, 6);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<add> Observable<Integer> source2 = Observable.just(4, 5, 6);
<ide>
<ide> Map<Integer, Observable<Integer>> map = new HashMap<Integer, Observable<Integer>>();
<ide> map.put(1, source1);
<ide> public void testDefaultCase() {
<ide>
<ide> @Test
<ide> public void testCaseSelectorThrows() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide>
<ide> Map<Integer, Observable<Integer>> map = new HashMap<Integer, Observable<Integer>>();
<ide> map.put(1, source1);
<ide> public void testCaseSelectorThrows() {
<ide>
<ide> @Test
<ide> public void testMapGetThrows() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<del> Observable<Integer> source2 = Observable.from(4, 5, 6);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<add> Observable<Integer> source2 = Observable.just(4, 5, 6);
<ide>
<ide> Map<Integer, Observable<Integer>> map = new HashMap<Integer, Observable<Integer>>() {
<ide> private static final long serialVersionUID = -4342868139960216388L;
<ide> public Observable<Integer> get(Object key) {
<ide>
<ide> @Test
<ide> public void testMapContainsKeyThrows() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide>
<ide> Map<Integer, Observable<Integer>> map = new HashMap<Integer, Observable<Integer>>() {
<ide> private static final long serialVersionUID = 1975411728567003983L;
<ide> public boolean containsKey(Object key) {
<ide>
<ide> @Test
<ide> public void testChosenObservableThrows() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide> Observable<Integer> source2 = Observable.error(new RuntimeException("Forced failure"));
<ide>
<ide> Map<Integer, Observable<Integer>> map = new HashMap<Integer, Observable<Integer>>();
<ide> public void testChosenObservableThrows() {
<ide>
<ide> @Test
<ide> public void testIfThen() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide>
<ide> Observable<Integer> result = Statement.ifThen(condition, source1);
<ide>
<ide> public void testIfThen() {
<ide>
<ide> @Test
<ide> public void testIfThenElse() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<del> Observable<Integer> source2 = Observable.from(4, 5, 6);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<add> Observable<Integer> source2 = Observable.just(4, 5, 6);
<ide>
<ide> Observable<Integer> result = Statement.ifThen(condition, source1, source2);
<ide>
<ide> public void testIfThenElse() {
<ide>
<ide> @Test
<ide> public void testIfThenConditonThrows() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide>
<ide> Observable<Integer> result = Statement.ifThen(conditionError, source1);
<ide>
<ide> public void testIfThenObservableThrows() {
<ide>
<ide> @Test
<ide> public void testIfThenElseObservableThrows() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide> Observable<Integer> source2 = Observable.error(new RuntimeException("Forced failure!"));
<ide>
<ide> Observable<Integer> result = Statement.ifThen(condition, source1, source2);
<ide> public void testIfThenElseObservableThrows() {
<ide>
<ide> @Test
<ide> public void testDoWhile() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide>
<ide> Observable<Integer> result = Statement.doWhile(source1, condition);
<ide>
<ide> public void testDoWhile() {
<ide>
<ide> @Test
<ide> public void testDoWhileOnce() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide>
<ide> condition.call(); // toggle to false
<ide> Observable<Integer> result = Statement.doWhile(source1, condition);
<ide> public void testDoWhileOnce() {
<ide>
<ide> @Test
<ide> public void testDoWhileConditionThrows() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide> Observable<Integer> result = Statement.doWhile(source1, conditionError);
<ide>
<ide> observeError(result, RuntimeException.class, 1, 2, 3);
<ide> }
<ide>
<ide> @Test
<ide> public void testDoWhileSourceThrows() {
<del> Observable<Integer> source1 = Observable.concat(Observable.from(1, 2, 3),
<add> Observable<Integer> source1 = Observable.concat(Observable.just(1, 2, 3),
<ide> Observable.<Integer> error(new RuntimeException("Forced failure!")));
<ide>
<ide> Observable<Integer> result = Statement.doWhile(source1, condition);
<ide> public Boolean call() {
<ide>
<ide> @Test
<ide> public void testDoWhileManyTimes() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3).subscribeOn(Schedulers.trampoline());
<add> Observable<Integer> source1 = Observable.just(1, 2, 3).subscribeOn(Schedulers.trampoline());
<ide>
<ide> List<Integer> expected = new ArrayList<Integer>(numRecursion * 3);
<ide> for (int i = 0; i < numRecursion; i++) {
<ide> public void testDoWhileManyTimes() {
<ide>
<ide> @Test
<ide> public void testWhileDo() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide> Observable<Integer> result = Statement.whileDo(source1, countdown(2));
<ide>
<ide> observe(result, 1, 2, 3, 1, 2, 3);
<ide> }
<ide>
<ide> @Test
<ide> public void testWhileDoOnce() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide> Observable<Integer> result = Statement.whileDo(source1, countdown(1));
<ide>
<ide> observe(result, 1, 2, 3);
<ide> }
<ide>
<ide> @Test
<ide> public void testWhileDoZeroTimes() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide> Observable<Integer> result = Statement.whileDo(source1, countdown(0));
<ide>
<ide> observe(result);
<ide> }
<ide>
<ide> @Test
<ide> public void testWhileDoManyTimes() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3).subscribeOn(Schedulers.trampoline());
<add> Observable<Integer> source1 = Observable.just(1, 2, 3).subscribeOn(Schedulers.trampoline());
<ide>
<ide> List<Integer> expected = new ArrayList<Integer>(numRecursion * 3);
<ide> for (int i = 0; i < numRecursion; i++) {
<ide> public void testWhileDoManyTimes() {
<ide>
<ide> @Test
<ide> public void testWhileDoConditionThrows() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide> Observable<Integer> result = Statement.whileDo(source1, conditionError);
<ide>
<ide> observeError(result, RuntimeException.class, 1, 2, 3);
<ide> }
<ide>
<ide> @Test
<ide> public void testWhileDoConditionThrowsImmediately() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<ide> conditionError.call();
<ide> Observable<Integer> result = Statement.whileDo(source1, conditionError);
<ide>
<ide> public void testWhileDoConditionThrowsImmediately() {
<ide>
<ide> @Test
<ide> public void testWhileDoSourceThrows() {
<del> Observable<Integer> source1 = Observable.concat(Observable.from(1, 2, 3),
<add> Observable<Integer> source1 = Observable.concat(Observable.just(1, 2, 3),
<ide> Observable.<Integer> error(new RuntimeException("Forced failure!")));
<ide>
<ide> Observable<Integer> result = Statement.whileDo(source1, condition);
<ide><path>rxjava-contrib/rxjava-debug/src/test/java/rx/debug/DebugHookTest.java
<ide> public void testSimple() {
<ide> final DebugHook hook = new DebugHook(listener);
<ide> RxJavaPlugins.getInstance().registerObservableExecutionHook(hook);
<ide>
<del> Observable.from(1).subscribe(Subscribers.empty());
<add> Observable.just(1).subscribe(Subscribers.empty());
<ide>
<ide> final InOrder inOrder = inOrder(listener);
<ide> inOrder.verify(listener).start(subscribe());
<ide><path>rxjava-contrib/rxjava-joins/src/test/java/rx/joins/operators/OperatorJoinsTest.java
<ide> public void whenArgumentNull2() {
<ide>
<ide> @Test
<ide> public void whenMultipleSymmetric() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<del> Observable<Integer> source2 = Observable.from(4, 5, 6);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<add> Observable<Integer> source2 = Observable.just(4, 5, 6);
<ide>
<ide> Observable<Integer> m = JoinObservable.when(JoinObservable.from(source1).and(source2).then(add)).toObservable();
<ide> m.subscribe(observer);
<ide> public void whenMultipleSymmetric() {
<ide>
<ide> @Test
<ide> public void whenMultipleAsymSymmetric() {
<del> Observable<Integer> source1 = Observable.from(1, 2, 3);
<del> Observable<Integer> source2 = Observable.from(4, 5);
<add> Observable<Integer> source1 = Observable.just(1, 2, 3);
<add> Observable<Integer> source2 = Observable.just(4, 5);
<ide>
<ide> Observable<Integer> m = JoinObservable.when(JoinObservable.from(source1).and(source2).then(add)).toObservable();
<ide> m.subscribe(observer);
<ide><path>rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorAverageTest.java
<ide> public class OperatorAverageTest {
<ide>
<ide> @Test
<ide> public void testAverageOfAFewInts() throws Throwable {
<del> Observable<Integer> src = Observable.from(1, 2, 3, 4, 6);
<add> Observable<Integer> src = Observable.just(1, 2, 3, 4, 6);
<ide> averageInteger(src).subscribe(w);
<ide>
<ide> verify(w, times(1)).onNext(anyInt());
<ide> public void testEmptyAverage() throws Throwable {
<ide>
<ide> @Test
<ide> public void testAverageOfAFewLongs() throws Throwable {
<del> Observable<Long> src = Observable.from(1L, 2L, 3L, 4L, 6L);
<add> Observable<Long> src = Observable.just(1L, 2L, 3L, 4L, 6L);
<ide> averageLong(src).subscribe(wl);
<ide>
<ide> verify(wl, times(1)).onNext(anyLong());
<ide> public void testEmptyAverageLongs() throws Throwable {
<ide>
<ide> @Test
<ide> public void testAverageOfAFewFloats() throws Throwable {
<del> Observable<Float> src = Observable.from(1.0f, 2.0f);
<add> Observable<Float> src = Observable.just(1.0f, 2.0f);
<ide> averageFloat(src).subscribe(wf);
<ide>
<ide> verify(wf, times(1)).onNext(anyFloat());
<ide> public void testEmptyAverageFloats() throws Throwable {
<ide>
<ide> @Test
<ide> public void testAverageOfAFewDoubles() throws Throwable {
<del> Observable<Double> src = Observable.from(1.0d, 2.0d);
<add> Observable<Double> src = Observable.just(1.0d, 2.0d);
<ide> averageDouble(src).subscribe(wd);
<ide>
<ide> verify(wd, times(1)).onNext(anyDouble());
<ide> <N extends Number> void testValue(Observer<Object> o, N value) {
<ide>
<ide> @Test
<ide> public void testIntegerAverageSelector() {
<del> Observable<String> source = Observable.from("a", "bb", "ccc", "dddd");
<add> Observable<String> source = Observable.just("a", "bb", "ccc", "dddd");
<ide> Func1<String, Integer> length = new Func1<String, Integer>() {
<ide> @Override
<ide> public Integer call(String t1) {
<ide> public Integer call(String t1) {
<ide>
<ide> @Test
<ide> public void testLongAverageSelector() {
<del> Observable<String> source = Observable.from("a", "bb", "ccc", "dddd");
<add> Observable<String> source = Observable.just("a", "bb", "ccc", "dddd");
<ide> Func1<String, Long> length = new Func1<String, Long>() {
<ide> @Override
<ide> public Long call(String t1) {
<ide> public Long call(String t1) {
<ide>
<ide> @Test
<ide> public void testFloatAverageSelector() {
<del> Observable<String> source = Observable.from("a", "bb", "ccc", "dddd");
<add> Observable<String> source = Observable.just("a", "bb", "ccc", "dddd");
<ide> Func1<String, Float> length = new Func1<String, Float>() {
<ide> @Override
<ide> public Float call(String t1) {
<ide> public Float call(String t1) {
<ide>
<ide> @Test
<ide> public void testDoubleAverageSelector() {
<del> Observable<String> source = Observable.from("a", "bb", "ccc", "dddd");
<add> Observable<String> source = Observable.just("a", "bb", "ccc", "dddd");
<ide> Func1<String, Double> length = new Func1<String, Double>() {
<ide> @Override
<ide> public Double call(String t1) {
<ide> public Double call(String t1) {
<ide>
<ide> @Test
<ide> public void testIntegerAverageSelectorThrows() {
<del> Observable<String> source = Observable.from("a");
<add> Observable<String> source = Observable.just("a");
<ide> Func1<String, Integer> length = new Func1<String, Integer>() {
<ide> @Override
<ide> public Integer call(String t1) {
<ide> public Integer call(String t1) {
<ide>
<ide> @Test
<ide> public void testLongAverageSelectorThrows() {
<del> Observable<String> source = Observable.from("a");
<add> Observable<String> source = Observable.just("a");
<ide> Func1<String, Long> length = new Func1<String, Long>() {
<ide> @Override
<ide> public Long call(String t1) {
<ide> public Long call(String t1) {
<ide>
<ide> @Test
<ide> public void testFloatAverageSelectorThrows() {
<del> Observable<String> source = Observable.from("a");
<add> Observable<String> source = Observable.just("a");
<ide> Func1<String, Float> length = new Func1<String, Float>() {
<ide> @Override
<ide> public Float call(String t1) {
<ide> public Float call(String t1) {
<ide>
<ide> @Test
<ide> public void testDoubleAverageSelectorThrows() {
<del> Observable<String> source = Observable.from("a");
<add> Observable<String> source = Observable.just("a");
<ide> Func1<String, Double> length = new Func1<String, Double>() {
<ide> @Override
<ide> public Double call(String t1) {
<ide><path>rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorMinMaxTest.java
<ide> public class OperatorMinMaxTest {
<ide> @Test
<ide> public void testMin() {
<del> Observable<Integer> observable = min(Observable.from(2, 3, 1, 4));
<add> Observable<Integer> observable = min(Observable.just(2, 3, 1, 4));
<ide>
<ide> @SuppressWarnings("unchecked")
<ide> Observer<Integer> observer = (Observer<Integer>) mock(Observer.class);
<ide> public void testMinWithEmpty() {
<ide>
<ide> @Test
<ide> public void testMinWithComparator() {
<del> Observable<Integer> observable = min(Observable.from(2, 3, 1, 4),
<add> Observable<Integer> observable = min(Observable.just(2, 3, 1, 4),
<ide> new Comparator<Integer>() {
<ide> @Override
<ide> public int compare(Integer o1, Integer o2) {
<ide> public int compare(Integer o1, Integer o2) {
<ide> @Test
<ide> public void testMinBy() {
<ide> Observable<List<String>> observable = minBy(
<del> Observable.from("1", "2", "3", "4", "5", "6"),
<add> Observable.just("1", "2", "3", "4", "5", "6"),
<ide> new Func1<String, Integer>() {
<ide> @Override
<ide> public Integer call(String t1) {
<ide> public Integer call(String t1) {
<ide> @Test
<ide> public void testMinByWithComparator() {
<ide> Observable<List<String>> observable = minBy(
<del> Observable.from("1", "2", "3", "4", "5", "6"),
<add> Observable.just("1", "2", "3", "4", "5", "6"),
<ide> new Func1<String, Integer>() {
<ide> @Override
<ide> public Integer call(String t1) {
<ide> public int compare(Integer o1, Integer o2) {
<ide>
<ide> @Test
<ide> public void testMax() {
<del> Observable<Integer> observable = max(Observable.from(2, 3, 1, 4));
<add> Observable<Integer> observable = max(Observable.just(2, 3, 1, 4));
<ide>
<ide> @SuppressWarnings("unchecked")
<ide> Observer<Integer> observer = (Observer<Integer>) mock(Observer.class);
<ide> public void testMaxWithEmpty() {
<ide>
<ide> @Test
<ide> public void testMaxWithComparator() {
<del> Observable<Integer> observable = max(Observable.from(2, 3, 1, 4),
<add> Observable<Integer> observable = max(Observable.just(2, 3, 1, 4),
<ide> new Comparator<Integer>() {
<ide> @Override
<ide> public int compare(Integer o1, Integer o2) {
<ide> public int compare(Integer o1, Integer o2) {
<ide> @Test
<ide> public void testMaxBy() {
<ide> Observable<List<String>> observable = maxBy(
<del> Observable.from("1", "2", "3", "4", "5", "6"),
<add> Observable.just("1", "2", "3", "4", "5", "6"),
<ide> new Func1<String, Integer>() {
<ide> @Override
<ide> public Integer call(String t1) {
<ide> public Integer call(String t1) {
<ide> @Test
<ide> public void testMaxByWithComparator() {
<ide> Observable<List<String>> observable = maxBy(
<del> Observable.from("1", "2", "3", "4", "5", "6"),
<add> Observable.just("1", "2", "3", "4", "5", "6"),
<ide> new Func1<String, Integer>() {
<ide> @Override
<ide> public Integer call(String t1) {
<ide><path>rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorSumTest.java
<ide> public class OperatorSumTest {
<ide>
<ide> @Test
<ide> public void testSumOfAFewInts() throws Throwable {
<del> Observable<Integer> src = Observable.from(1, 2, 3, 4, 5);
<add> Observable<Integer> src = Observable.just(1, 2, 3, 4, 5);
<ide> sumIntegers(src).subscribe(w);
<ide>
<ide> verify(w, times(1)).onNext(anyInt());
<ide> public void testEmptySum() throws Throwable {
<ide>
<ide> @Test
<ide> public void testSumOfAFewLongs() throws Throwable {
<del> Observable<Long> src = Observable.from(1L, 2L, 3L, 4L, 5L);
<add> Observable<Long> src = Observable.just(1L, 2L, 3L, 4L, 5L);
<ide> sumLongs(src).subscribe(wl);
<ide>
<ide> verify(wl, times(1)).onNext(anyLong());
<ide> public void testEmptySumLongs() throws Throwable {
<ide>
<ide> @Test
<ide> public void testSumOfAFewFloats() throws Throwable {
<del> Observable<Float> src = Observable.from(1.0f);
<add> Observable<Float> src = Observable.just(1.0f);
<ide> sumFloats(src).subscribe(wf);
<ide>
<ide> verify(wf, times(1)).onNext(anyFloat());
<ide> public void testEmptySumFloats() throws Throwable {
<ide>
<ide> @Test
<ide> public void testSumOfAFewDoubles() throws Throwable {
<del> Observable<Double> src = Observable.from(0.0d, 1.0d, 0.5d);
<add> Observable<Double> src = Observable.just(0.0d, 1.0d, 0.5d);
<ide> sumDoubles(src).subscribe(wd);
<ide>
<ide> verify(wd, times(1)).onNext(anyDouble());
<ide> <N extends Number> void testValue(Observer<Object> o, N value) {
<ide>
<ide> @Test
<ide> public void testIntegerSumSelector() {
<del> Observable<String> source = Observable.from("a", "bb", "ccc", "dddd");
<add> Observable<String> source = Observable.just("a", "bb", "ccc", "dddd");
<ide> Func1<String, Integer> length = new Func1<String, Integer>() {
<ide> @Override
<ide> public Integer call(String t1) {
<ide> public Integer call(String t1) {
<ide>
<ide> @Test
<ide> public void testLongSumSelector() {
<del> Observable<String> source = Observable.from("a", "bb", "ccc", "dddd");
<add> Observable<String> source = Observable.just("a", "bb", "ccc", "dddd");
<ide> Func1<String, Long> length = new Func1<String, Long>() {
<ide> @Override
<ide> public Long call(String t1) {
<ide> public Long call(String t1) {
<ide>
<ide> @Test
<ide> public void testFloatSumSelector() {
<del> Observable<String> source = Observable.from("a", "bb", "ccc", "dddd");
<add> Observable<String> source = Observable.just("a", "bb", "ccc", "dddd");
<ide> Func1<String, Float> length = new Func1<String, Float>() {
<ide> @Override
<ide> public Float call(String t1) {
<ide> public Float call(String t1) {
<ide>
<ide> @Test
<ide> public void testDoubleSumSelector() {
<del> Observable<String> source = Observable.from("a", "bb", "ccc", "dddd");
<add> Observable<String> source = Observable.just("a", "bb", "ccc", "dddd");
<ide> Func1<String, Double> length = new Func1<String, Double>() {
<ide> @Override
<ide> public Double call(String t1) {
<ide> public Double call(String t1) {
<ide>
<ide> @Test
<ide> public void testIntegerSumSelectorThrows() {
<del> Observable<String> source = Observable.from("a");
<add> Observable<String> source = Observable.just("a");
<ide> Func1<String, Integer> length = new Func1<String, Integer>() {
<ide> @Override
<ide> public Integer call(String t1) {
<ide> public Integer call(String t1) {
<ide>
<ide> @Test
<ide> public void testLongSumSelectorThrows() {
<del> Observable<String> source = Observable.from("a");
<add> Observable<String> source = Observable.just("a");
<ide> Func1<String, Long> length = new Func1<String, Long>() {
<ide> @Override
<ide> public Long call(String t1) {
<ide> public Long call(String t1) {
<ide>
<ide> @Test
<ide> public void testFloatSumSelectorThrows() {
<del> Observable<String> source = Observable.from("a");
<add> Observable<String> source = Observable.just("a");
<ide> Func1<String, Float> length = new Func1<String, Float>() {
<ide> @Override
<ide> public Float call(String t1) {
<ide> public Float call(String t1) {
<ide>
<ide> @Test
<ide> public void testDoubleSumSelectorThrows() {
<del> Observable<String> source = Observable.from("a");
<add> Observable<String> source = Observable.just("a");
<ide> Func1<String, Double> length = new Func1<String, Double>() {
<ide> @Override
<ide> public Double call(String t1) { | 10 |
Javascript | Javascript | cover error case in os getcheckedfunction() | 8d05a1590aaeab07050e019ac892e1ebacac456d | <ide><path>test/parallel/test-os-checked-function.js
<add>'use strict';
<add>// Monkey patch the os binding before requiring any other modules, including
<add>// common, which requires the os module.
<add>process.binding('os').getHomeDirectory = function(ctx) {
<add> ctx.syscall = 'foo';
<add> ctx.code = 'bar';
<add> ctx.message = 'baz';
<add>};
<add>
<add>const common = require('../common');
<add>const os = require('os');
<add>
<add>common.expectsError(os.homedir, {
<add> message: /^A system error occurred: foo returned bar \(baz\)$/
<add>}); | 1 |
Javascript | Javascript | remove debugger statement from http_simple.js | 08bec7ab0a9be15373d89492123b210fd0a05763 | <ide><path>benchmark/http_simple.js
<ide> var server = http.createServer(function (req, res) {
<ide>
<ide> if (command == "bytes") {
<ide> var n = parseInt(arg, 10)
<del> debugger;
<ide> if (n <= 0)
<ide> throw "bytes called with n <= 0"
<ide> if (stored[n] === undefined) { | 1 |
Python | Python | add simple script to add pytest marks | 199943deb4da7c68f08f578b404dbc6208cc41ac | <ide><path>spacy/tests/regression/util_add_marker.py
<add>import re
<add>from pathlib import Path
<add>from typing import Optional
<add>
<add>import typer
<add>
<add>
<add>def main(
<add> filename: Path, out_file: Optional[Path] = typer.Option(None), dry_run: bool = False
<add>):
<add> """Add pytest issue markers on regression tests
<add>
<add> If --out-file is not used, it will overwrite the original file. You can set
<add> the --dry-run flag to just see the changeset and not write to disk.
<add> """
<add> lines = []
<add> with filename.open() as f:
<add> lines = f.readlines()
<add>
<add> # Regex pattern for matching common regression formats (e.g. test_issue1234)
<add> pattern = r"def test_issue\d{1,4}"
<add> regex = re.compile(pattern)
<add>
<add> new_lines = []
<add> for line_text in lines:
<add> if regex.search(line_text): # if match, append marker first
<add> issue_num = int(re.findall(r"\d+", line_text)[0]) # Simple heuristic
<add> typer.echo(f"Found: {line_text} with issue number: {issue_num}")
<add> new_lines.append(f"@pytest.mark.issue({issue_num})\n")
<add> new_lines.append(line_text)
<add>
<add> # Save to file
<add> if not dry_run:
<add> out = out_file or filename
<add> with out.open("w") as f:
<add> for new_line in new_lines:
<add> f.write(new_line)
<add>
<add>
<add>if __name__ == "__main__":
<add> typer.run(main) | 1 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.