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 | add readline support for meta-f and meta-b | 748469c71c9a0860aada8b0d130aa181df13e370 | <ide><path>lib/readline.js
<ide> var EventEmitter = require('events').EventEmitter;
<ide> var stdio = process.binding('stdio');
<ide>
<ide>
<del>
<ide> exports.createInterface = function (output, completer) {
<ide> return new Interface(output, completer);
<ide> };
<ide> Interface.prototype._ttyWrite = function (b) {
<ide> return;
<ide>
<ide> case 27: /* escape sequence */
<add> var next_word, next_non_word, previous_word, previous_non_word;
<ide> if (b[1] === 98 && this.cursor > 0) { // meta-b - backward word
<del>
<add> previous_word = this.line.slice(0, this.cursor)
<add> .split('').reverse().join('')
<add> .search(/\w/);
<add> if (previous_word !== -1) {
<add> previous_non_word = this.line.slice(0, this.cursor - previous_word)
<add> .split('').reverse().join('')
<add> .search(/\W/);
<add> if (previous_non_word !== -1) {
<add> this.cursor -= previous_word + previous_non_word;
<add> this._refreshLine();
<add> break;
<add> }
<add> }
<add> this.cursor = 0;
<add> this._refreshLine();
<ide> } else if (b[1] === 102 && this.cursor < this.line.length) { // meta-f - forward word
<del>
<add> next_word = this.line.slice(this.cursor, this.line.length)
<add> .search(/\w/);
<add> if (next_word !== -1) {
<add> next_non_word = this.line.slice(this.cursor + next_word, this.line.length)
<add> .search(/\W/);
<add> if (next_non_word !== -1) {
<add> this.cursor += next_word + next_non_word;
<add> this._refreshLine();
<add> break;
<add> }
<add> }
<add> this.cursor = this.line.length;
<add> this._refreshLine();
<ide> } else if (b[1] === 91 && b[2] === 68) { // left arrow
<ide> if (this.cursor > 0) {
<ide> this.cursor--;
<ide><path>test/simple/test-readline.js
<ide> var readline = require("readline");
<ide> var key = {
<ide> xterm: {
<ide> home: [27, 91, 72],
<del> end: [27, 91, 70]
<add> end: [27, 91, 70],
<add> metab: [27, 98],
<add> metaf: [27, 102]
<ide> },
<ide> gnome: {
<ide> home: [27, 79, 72],
<ide> var key = {
<ide> }
<ide> };
<ide>
<del>var fakestream = {
<del> fd: 1,
<del> write: function(bytes) {
<del> }
<add>var readlineFakeStream = function() {
<add> var written_bytes = [];
<add> var rl = readline.createInterface({
<add> fd: 1,
<add> write: function(b) {
<add> written_bytes.push(b);
<add> }}, function (text) {
<add> return [[], ""];
<add> });
<add> rl.written_bytes = written_bytes;
<add> return rl;
<ide> };
<ide>
<del>var rl = readline.createInterface(fakestream, function (text) {
<del> return [[], ""];
<del>});
<add>var rl = readlineFakeStream();
<add>var written_bytes_length, refreshed;
<ide>
<ide> rl.write('foo');
<ide> assert.equal(3, rl.cursor);
<ide> rl.write(key.gnome.home);
<ide> assert.equal(0, rl.cursor);
<ide> rl.write(key.gnome.end);
<ide> assert.equal(3, rl.cursor);
<add>
<add>rl = readlineFakeStream();
<add>rl.write('foo bar.hop/zoo');
<add>rl.write(key.xterm.home);
<add>written_bytes_length = rl.written_bytes.length;
<add>rl.write(key.xterm.metaf);
<add>assert.equal(3, rl.cursor);
<add>refreshed = written_bytes_length !== rl.written_bytes.length;
<add>assert.equal(true, refreshed);
<add>rl.write(key.xterm.metaf);
<add>assert.equal(7, rl.cursor);
<add>rl.write(key.xterm.metaf);
<add>assert.equal(11, rl.cursor);
<add>written_bytes_length = rl.written_bytes.length;
<add>rl.write(key.xterm.metaf);
<add>assert.equal(15, rl.cursor);
<add>refreshed = written_bytes_length !== rl.written_bytes.length;
<add>assert.equal(true, refreshed);
<add>written_bytes_length = rl.written_bytes.length;
<add>rl.write(key.xterm.metab);
<add>assert.equal(12, rl.cursor);
<add>refreshed = written_bytes_length !== rl.written_bytes.length;
<add>assert.equal(true, refreshed);
<add>rl.write(key.xterm.metab);
<add>assert.equal(8, rl.cursor);
<add>rl.write(key.xterm.metab);
<add>assert.equal(4, rl.cursor);
<add>written_bytes_length = rl.written_bytes.length;
<add>rl.write(key.xterm.metab);
<add>assert.equal(0, rl.cursor);
<add>refreshed = written_bytes_length !== rl.written_bytes.length;
<add>assert.equal(true, refreshed);
<ide>\ No newline at end of file | 2 |
Javascript | Javascript | add tests and docs for addinjectionpoint | 4d3916f74e350691ab85e63ac8b1ad5bb851339b | <ide><path>spec/grammar-registry-spec.js
<ide> describe('GrammarRegistry', () => {
<ide> })
<ide> })
<ide>
<add> describe('.addInjectionPoint(languageId, {type, language, content})', () => {
<add> const injectionPoint = {
<add> type: 'some_node_type',
<add> language() { return 'some_language_name' },
<add> content(node) { return node }
<add> }
<add>
<add> beforeEach(() => {
<add> atom.config.set('core.useTreeSitterParsers', true)
<add> })
<add>
<add> it('adds an injection point to the grammar with the given id', async () => {
<add> await atom.packages.activatePackage('language-javascript')
<add> atom.grammars.addInjectionPoint('javascript', injectionPoint)
<add> const grammar = atom.grammars.grammarForId('javascript')
<add> expect(grammar.injectionPoints).toContain(injectionPoint)
<add> })
<add>
<add> describe('when called before a grammar with the given id is loaded', () => {
<add> it('adds the injection point once the grammar is loaded', async () => {
<add> atom.grammars.addInjectionPoint('javascript', injectionPoint)
<add> await atom.packages.activatePackage('language-javascript')
<add> const grammar = atom.grammars.grammarForId('javascript')
<add> expect(grammar.injectionPoints).toContain(injectionPoint)
<add> })
<add> })
<add> })
<add>
<ide> describe('serialization', () => {
<ide> it('persists editors\' grammar overrides', async () => {
<ide> const buffer1 = new TextBuffer()
<ide><path>spec/tree-sitter-language-mode-spec.js
<ide> describe('TreeSitterLanguageMode', () => {
<ide> tag_name: 'tag',
<ide> attribute_name: 'attr'
<ide> },
<del> injections: [
<del> name => name.toLowerCase().includes('html')
<del> ]
<add> injectionRegExp: 'html'
<ide> })
<ide>
<ide> atom.grammars.addGrammar(jsGrammar)
<ide><path>src/grammar-registry.js
<ide> class GrammarRegistry {
<ide> return this.textmateRegistry.onDidUpdateGrammar(callback)
<ide> }
<ide>
<add> // Experimental: Specify a type of syntax node that may embed other languages.
<add> //
<add> // * `grammarId` The {String} id of the parent language
<add> // * `injectionPoint` An {Object} with the following keys:
<add> // * `type` The {String} type of syntax node that may embed other languages
<add> // * `language` A {Function} that is called with syntax nodes of the specified `type` and
<add> // returns a {String} that will be tested against other grammars' `injectionRegExp` in
<add> // order to determine what language should be embedded.
<add> // * `content` A {Function} that is called with syntax nodes of the specified `type` and
<add> // returns another syntax node that contains the embedded source code.
<add> addInjectionPoint (grammarId, injectionPoint) {
<add> const grammar = this.treeSitterGrammarsById[grammarId]
<add> if (grammar) {
<add> grammar.injectionPoints.push(injectionPoint)
<add> } else {
<add> this.treeSitterGrammarsById[grammarId] = {
<add> injectionPoints: [injectionPoint]
<add> }
<add> }
<add> return new Disposable(() => {
<add> const grammar = this.treeSitterGrammarsById[grammarId]
<add> const index = grammar.injectionPoints.indexOf(injectionPoint)
<add> if (index !== -1) grammar.injectionPoints.splice(index, 1)
<add> })
<add> }
<add>
<ide> get nullGrammar () {
<ide> return this.textmateRegistry.nullGrammar
<ide> }
<ide> class GrammarRegistry {
<ide>
<ide> addGrammar (grammar) {
<ide> if (grammar instanceof TreeSitterGrammar) {
<add> const existingParams = this.treeSitterGrammarsById[grammar.id] || {}
<ide> this.treeSitterGrammarsById[grammar.id] = grammar
<ide> if (grammar.legacyScopeName) {
<ide> this.config.setLegacyScopeAliasForNewScope(grammar.id, grammar.legacyScopeName)
<ide> this.textMateScopeNamesByTreeSitterLanguageId.set(grammar.id, grammar.legacyScopeName)
<ide> this.treeSitterLanguageIdsByTextMateScopeName.set(grammar.legacyScopeName, grammar.id)
<ide> }
<add> if (existingParams.injectionPoints) grammar.injectionPoints.push(...existingParams.injectionPoints)
<ide> this.grammarAddedOrUpdated(grammar)
<ide> return new Disposable(() => this.removeGrammar(grammar))
<ide> } else {
<ide> class GrammarRegistry {
<ide>
<ide> treeSitterGrammarForLanguageString (languageString) {
<ide> for (const id in this.treeSitterGrammarsById) {
<del> const grammar = this.treeSitterGrammarsById[id];
<del> if (grammar.injections) {
<del> for (const injection of grammar.injections) {
<del> if (injection(languageString)) {
<del> return grammar
<del> }
<del> }
<add> const grammar = this.treeSitterGrammarsById[id]
<add> if (grammar.injectionRegExp && grammar.injectionRegExp.test(languageString)) {
<add> return grammar
<ide> }
<ide> }
<ide> }
<ide><path>src/tree-sitter-grammar.js
<ide> class TreeSitterGrammar {
<ide> this.name = params.name
<ide> this.legacyScopeName = params.legacyScopeName
<ide> if (params.contentRegExp) this.contentRegExp = new RegExp(params.contentRegExp)
<add> if (params.injectionRegExp) this.injectionRegExp = new RegExp(params.injectionRegExp)
<ide>
<ide> this.folds = params.folds || []
<ide>
<ide> class TreeSitterGrammar {
<ide> this.scopeMap = new SyntaxScopeMap(scopeSelectors)
<ide> this.fileTypes = params.fileTypes
<ide> this.injectionPoints = params.injectionPoints || []
<del> this.injections = params.injections || []
<ide>
<ide> // TODO - When we upgrade to a new enough version of node, use `require.resolve`
<ide> // with the new `paths` option instead of this private API.
<ide><path>src/tree-sitter-language-mode.js
<ide> class TreeSitterLanguageMode {
<ide> this.emitRangeUpdate = this.emitRangeUpdate.bind(this)
<ide>
<ide> this.subscription = this.buffer.onDidChangeText(({changes}) => {
<del> for (let i = changes.length; i --> 0;) {
<add> for (let i = changes.length - 1; i >= 0; i--) {
<ide> const {oldRange, newRange} = changes[i]
<ide> const startRow = oldRange.start.row
<ide> const oldEndRow = oldRange.end.row
<ide> class LanguageLayer {
<ide> }
<ide> }
<ide>
<del> destroy() {
<add> destroy () {
<ide> for (const marker of this.languageMode.injectionsMarkerLayer.getMarkers()) {
<ide> if (marker.parentLanguageLayer === this) {
<ide> marker.languageLayer.destroy()
<ide> class LanguageLayer {
<ide>
<ide> if (this.patchSinceCurrentParseStarted) {
<ide> const changes = this.patchSinceCurrentParseStarted.getChanges()
<del> for (let i = changes.length; i --> 0;) {
<add> for (let i = changes.length - 1; i >= 0; i--) {
<ide> const {oldStart, oldEnd, newEnd, oldText, newText} = changes[i]
<ide> this.tree.edit(this._treeEditForBufferChange(
<ide> oldStart, oldEnd, newEnd, oldText, newText
<ide> class LanguageLayer {
<ide> let affectedRange
<ide> let existingInjectionMarkers
<ide> if (this.tree) {
<del> const changedTokenRange = this.tree.getEditedRange()
<del> affectedRange = new Range(changedTokenRange.startPosition, changedTokenRange.endPosition)
<add> const editedRange = this.tree.getEditedRange()
<add> affectedRange = new Range(editedRange.startPosition, editedRange.endPosition)
<ide>
<ide> const rangesWithSyntaxChanges = this.tree.getChangedRanges(tree)
<ide> for (const range of rangesWithSyntaxChanges) {
<ide> class LanguageLayer {
<ide> injectionPoint.type,
<ide> affectedRange.start,
<ide> affectedRange.end
<del> );
<add> )
<ide>
<ide> for (const node of nodes) {
<ide> const languageName = injectionPoint.language(node, getNodeText) | 5 |
Text | Text | fix casing of javascript in readme | 282185535b7bde56437d6d3a78d89a201dac0e53 | <ide><path>README.md
<ide> <a href="https://saucelabs.com/u/ember-ci"><img src="https://saucelabs.com/browser-matrix/ember-ci.svg" alt="Sauce Test Status"></a>
<ide> </p>
<ide>
<del>Ember.js is a Javascript framework that greatly reduces the time, effort and resources needed
<add>Ember.js is a JavaScript framework that greatly reduces the time, effort and resources needed
<ide> to build any web application. It is focused on making you, the developer, as productive as possible by doing all the common, repetitive, yet essential, tasks involved in most web development projects.
<ide>
<del>Ember.js also provides access to the most advanced features of Javascript, HTML and the Browser giving you everything you need to create your next killer web app.
<add>Ember.js also provides access to the most advanced features of JavaScript, HTML and the Browser giving you everything you need to create your next killer web app.
<ide>
<ide> - [Website](https://emberjs.com)
<ide> - [Guides](https://guides.emberjs.com) | 1 |
Python | Python | update commands for pypi test | 8036ceb7c57e72428f61e685523e17243a6c49e3 | <ide><path>setup.py
<ide>
<ide> twine upload dist/* -r pypitest
<ide> (pypi suggest using twine as other methods upload files via plaintext.)
<add> You may have to specify the repository url, use the following command then:
<add> twine upload dist/* -r pypitest --repository-url=https://test.pypi.org/legacy/
<ide>
<ide> Check that you can install it in a virtualenv by running:
<ide> pip install -i https://testpypi.python.org/pypi transformers | 1 |
Mixed | Javascript | add support for import.meta to module | 07ba9141e475ec63f6ef56b67ec5f98077cd3446 | <ide><path>doc/api/vm.md
<ide> const contextifiedSandbox = vm.createContext({ secret: 42 });
<ide> in stack traces produced by this Module.
<ide> * `columnOffset` {integer} Spcifies the column number offset that is displayed
<ide> in stack traces produced by this Module.
<add> * `initalizeImportMeta` {Function} Called during evaluation of this Module to
<add> initialize the `import.meta`. This function has the signature `(meta,
<add> module)`, where `meta` is the `import.meta` object in the Module, and
<add> `module` is this `vm.Module` object.
<ide>
<ide> Creates a new ES `Module` object.
<ide>
<add>*Note*: Properties assigned to the `import.meta` object that are objects may
<add>allow the Module to access information outside the specified `context`, if the
<add>object is created in the top level context. Use `vm.runInContext()` to create
<add>objects in a specific context.
<add>
<add>```js
<add>const vm = require('vm');
<add>
<add>const contextifiedSandbox = vm.createContext({ secret: 42 });
<add>
<add>(async () => {
<add> const module = new vm.Module(
<add> 'Object.getPrototypeOf(import.meta.prop).secret = secret;',
<add> {
<add> initializeImportMeta(meta) {
<add> // Note: this object is created in the top context. As such,
<add> // Object.getPrototypeOf(import.meta.prop) points to the
<add> // Object.prototype in the top context rather than that in
<add> // the sandbox.
<add> meta.prop = {};
<add> }
<add> });
<add> // Since module has no dependencies, the linker function will never be called.
<add> await module.link(() => {});
<add> module.initialize();
<add> await module.evaluate();
<add>
<add> // Now, Object.prototype.secret will be equal to 42.
<add> //
<add> // To fix this problem, replace
<add> // meta.prop = {};
<add> // above with
<add> // meta.prop = vm.runInContext('{}', contextifiedSandbox);
<add>})();
<add>```
<add>
<ide> ### module.dependencySpecifiers
<ide>
<ide> * {string[]}
<ide><path>lib/internal/bootstrap/node.js
<ide> 'DeprecationWarning', 'DEP0062', startup, true);
<ide> }
<ide>
<del> if (process.binding('config').experimentalModules) {
<del> process.emitWarning(
<del> 'The ESM module loader is experimental.',
<del> 'ExperimentalWarning', undefined);
<add> if (process.binding('config').experimentalModules ||
<add> process.binding('config').experimentalVMModules) {
<add> if (process.binding('config').experimentalModules) {
<add> process.emitWarning(
<add> 'The ESM module loader is experimental.',
<add> 'ExperimentalWarning', undefined);
<add> }
<ide> NativeModule.require('internal/process/esm_loader').setup();
<ide> }
<ide>
<ide><path>lib/internal/process/esm_loader.js
<ide> const { getURLFromFilePath } = require('internal/url');
<ide> const Loader = require('internal/modules/esm/loader');
<ide> const path = require('path');
<ide> const { URL } = require('url');
<add>const {
<add> initImportMetaMap,
<add> wrapToModuleMap
<add>} = require('internal/vm/module');
<ide>
<ide> function normalizeReferrerURL(referrer) {
<ide> if (typeof referrer === 'string' && path.isAbsolute(referrer)) {
<ide> function normalizeReferrerURL(referrer) {
<ide> }
<ide>
<ide> function initializeImportMetaObject(wrap, meta) {
<del> meta.url = wrap.url;
<add> const vmModule = wrapToModuleMap.get(wrap);
<add> if (vmModule === undefined) {
<add> // This ModuleWrap belongs to the Loader.
<add> meta.url = wrap.url;
<add> } else {
<add> const initializeImportMeta = initImportMetaMap.get(vmModule);
<add> if (initializeImportMeta !== undefined) {
<add> // This ModuleWrap belongs to vm.Module, initializer callback was
<add> // provided.
<add> initializeImportMeta(meta, vmModule);
<add> }
<add> }
<ide> }
<ide>
<ide> let loaderResolve;
<ide><path>lib/internal/vm/module.js
<ide> const perContextModuleId = new WeakMap();
<ide> const wrapMap = new WeakMap();
<ide> const dependencyCacheMap = new WeakMap();
<ide> const linkingStatusMap = new WeakMap();
<add>// vm.Module -> function
<add>const initImportMetaMap = new WeakMap();
<add>// ModuleWrap -> vm.Module
<add>const wrapToModuleMap = new WeakMap();
<ide>
<ide> class Module {
<ide> constructor(src, options = {}) {
<ide> class Module {
<ide> perContextModuleId.set(context, 1);
<ide> }
<ide>
<add> if (options.initializeImportMeta !== undefined) {
<add> if (typeof options.initializeImportMeta === 'function') {
<add> initImportMetaMap.set(this, options.initializeImportMeta);
<add> } else {
<add> throw new ERR_INVALID_ARG_TYPE(
<add> 'options.initializeImportMeta', 'function',
<add> options.initializeImportMeta);
<add> }
<add> }
<add>
<ide> const wrap = new ModuleWrap(src, url, {
<ide> [kParsingContext]: context,
<ide> lineOffset: options.lineOffset,
<ide> class Module {
<ide>
<ide> wrapMap.set(this, wrap);
<ide> linkingStatusMap.set(this, 'unlinked');
<add> wrapToModuleMap.set(wrap, this);
<ide>
<ide> Object.defineProperties(this, {
<ide> url: { value: url, enumerable: true },
<ide> class Module {
<ide> }
<ide>
<ide> module.exports = {
<del> Module
<add> Module,
<add> initImportMetaMap,
<add> wrapToModuleMap
<ide> };
<ide><path>test/parallel/test-vm-module-import-meta.js
<add>'use strict';
<add>
<add>// Flags: --experimental-vm-modules --harmony-import-meta
<add>
<add>const common = require('../common');
<add>const assert = require('assert');
<add>const { Module } = require('vm');
<add>
<add>common.crashOnUnhandledRejection();
<add>
<add>async function testBasic() {
<add> const m = new Module('import.meta;', {
<add> initializeImportMeta: common.mustCall((meta, module) => {
<add> assert.strictEqual(module, m);
<add> meta.prop = 42;
<add> })
<add> });
<add> await m.link(common.mustNotCall());
<add> m.instantiate();
<add> const { result } = await m.evaluate();
<add> assert.strictEqual(typeof result, 'object');
<add> assert.strictEqual(Object.getPrototypeOf(result), null);
<add> assert.strictEqual(result.prop, 42);
<add> assert.deepStrictEqual(Reflect.ownKeys(result), ['prop']);
<add>}
<add>
<add>async function testInvalid() {
<add> for (const invalidValue of [
<add> null, {}, 0, Symbol.iterator, [], 'string', false
<add> ]) {
<add> common.expectsError(() => {
<add> new Module('', {
<add> initializeImportMeta: invalidValue
<add> });
<add> }, {
<add> code: 'ERR_INVALID_ARG_TYPE',
<add> type: TypeError
<add> });
<add> }
<add>}
<add>
<add>(async () => {
<add> await testBasic();
<add> await testInvalid();
<add>})(); | 5 |
Text | Text | remove superfluous adverb from style guide | 23432d3306c98e39fd94ea6eee2fd05dc66723dc | <ide><path>doc/STYLE_GUIDE.md
<ide> * American English spelling is preferred. "Capitalize" vs. "Capitalise",
<ide> "color" vs. "colour", etc.
<ide> * Use [serial commas][].
<del>* Generally avoid personal pronouns in reference documentation ("I", "you",
<del> "we").
<add>* Avoid personal pronouns in reference documentation ("I", "you", "we").
<ide> * Pronouns are acceptable in more colloquial documentation, like guides.
<ide> * Use gender-neutral pronouns and mass nouns. Non-comprehensive
<ide> examples: | 1 |
Python | Python | add files via upload | d4fc55c5fc4859490584c5f023a18e1c514226c8 | <ide><path>sorts/recursive_bubble_sort.py
<add>def bubble_sort(list1):
<add> """
<add> It is similar is bubble sort but recursive.
<add> :param list1: mutable ordered sequence of elements
<add> :return: the same list in ascending order
<add>
<add> >>> bubble_sort([0, 5, 2, 3, 2])
<add> [0, 2, 2, 3, 5]
<add>
<add> >>> bubble_sort([])
<add> []
<add>
<add> >>> bubble_sort([-2, -45, -5])
<add> [-45, -5, -2]
<add>
<add> >>> bubble_sort([-23, 0, 6, -4, 34])
<add> [-23, -4, 0, 6, 34]
<add>
<add> >>> bubble_sort([-23, 0, 6, -4, 34]) == sorted([-23, 0, 6, -4, 34])
<add> True
<add>
<add> >>> bubble_sort(['z','a','y','b','x','c'])
<add> ['a', 'b', 'c', 'x', 'y', 'z']
<add>
<add> """
<add>
<add> for i, num in enumerate(list1):
<add> try:
<add> if list1[i+1] < num:
<add> list1[i] = list1[i+1]
<add> list1[i+1] = num
<add> bubble_sort(list1)
<add> except IndexError:
<add> pass
<add> return list1
<add>
<add>if __name__ == "__main__":
<add> list1 = [33,99,22,11,66]
<add> bubble_sort(list1)
<add> print(list1) | 1 |
PHP | PHP | accept field for route binding | e1f8eef2a413642aeab6df1a08602a58da58739f | <ide><path>src/Illuminate/Contracts/Routing/UrlRoutable.php
<ide> public function getRouteKeyName();
<ide> /**
<ide> * Retrieve the model for a bound value.
<ide> *
<del> * @param mixed $value
<add> * @param mixed $value
<add> * @param string $field
<ide> * @return \Illuminate\Database\Eloquent\Model|null
<ide> */
<del> public function resolveRouteBinding($value);
<add> public function resolveRouteBinding($value, $field = null);
<ide> }
<ide><path>src/Illuminate/Database/Eloquent/Model.php
<ide> public function getRouteKeyName()
<ide> /**
<ide> * Retrieve the model for a bound value.
<ide> *
<del> * @param mixed $value
<add> * @param mixed $value
<add> * @param string $field
<ide> * @return \Illuminate\Database\Eloquent\Model|null
<ide> */
<del> public function resolveRouteBinding($value)
<add> public function resolveRouteBinding($value, $field = null)
<ide> {
<del> return $this->where($this->getRouteKeyName(), $value)->first();
<add> return $this->where($field ?? $this->getRouteKeyName(), $value)->first();
<ide> }
<ide>
<ide> /**
<ide><path>src/Illuminate/Http/Resources/DelegatesToResource.php
<ide> public function getRouteKeyName()
<ide> /**
<ide> * Retrieve the model for a bound value.
<ide> *
<del> * @param mixed $value
<add> * @param mixed $value
<add> * @param string $field
<ide> * @return void
<ide> *
<ide> * @throws \Exception
<ide> */
<del> public function resolveRouteBinding($value)
<add> public function resolveRouteBinding($value, $field = null)
<ide> {
<ide> throw new Exception('Resources may not be implicitly resolved from route bindings.');
<ide> }
<ide><path>tests/Integration/Routing/UrlSigningTest.php
<ide> public function getRouteKeyName()
<ide> return 'routable';
<ide> }
<ide>
<del> public function resolveRouteBinding($routeKey)
<add> public function resolveRouteBinding($routeKey, $field = null)
<ide> {
<ide> //
<ide> }
<ide><path>tests/Routing/RoutingUrlGeneratorTest.php
<ide> public function getRouteKeyName()
<ide> return 'key';
<ide> }
<ide>
<del> public function resolveRouteBinding($routeKey)
<add> public function resolveRouteBinding($routeKey, $field = null)
<ide> {
<ide> //
<ide> } | 5 |
Python | Python | change batchnorm trainable to true | 3e73c76c7a5373dafd71ef9231896dabcb696cc5 | <ide><path>research/object_detection/models/faster_rcnn_resnet_v1_fpn_keras_feature_extractor.py
<ide> def __init__(self,
<ide> resnet_v1_base_model_name,
<ide> first_stage_features_stride,
<ide> conv_hyperparams,
<del> batch_norm_trainable=False,
<add> batch_norm_trainable=True,
<ide> pad_to_multiple=32,
<ide> weight_decay=0.0,
<ide> fpn_min_level=2,
<ide> class FasterRCNNResnet50FpnKerasFeatureExtractor(
<ide> def __init__(self,
<ide> is_training,
<ide> first_stage_features_stride=16,
<del> batch_norm_trainable=False,
<add> batch_norm_trainable=True,
<ide> conv_hyperparams=None,
<ide> weight_decay=0.0,
<ide> fpn_min_level=2,
<ide> class FasterRCNNResnet101FpnKerasFeatureExtractor(
<ide> def __init__(self,
<ide> is_training,
<ide> first_stage_features_stride=16,
<del> batch_norm_trainable=False,
<add> batch_norm_trainable=True,
<ide> conv_hyperparams=None,
<ide> weight_decay=0.0,
<ide> fpn_min_level=2,
<ide> class FasterRCNNResnet152FpnKerasFeatureExtractor(
<ide> def __init__(self,
<ide> is_training,
<ide> first_stage_features_stride=16,
<del> batch_norm_trainable=False,
<add> batch_norm_trainable=True,
<ide> conv_hyperparams=None,
<ide> weight_decay=0.0,
<ide> fpn_min_level=2, | 1 |
Javascript | Javascript | increase coverage for path.parse | f7f590c9a9fe7bb31719f7fb7427e4de1a0d9edc | <ide><path>test/parallel/test-path-parse-format.js
<ide> const winPaths = [
<ide> 'file',
<ide> '.\\file',
<ide> 'C:\\',
<add> 'C:',
<add> '\\',
<ide> '',
<ide>
<ide> // unc
<ide> const winPaths = [
<ide> ];
<ide>
<ide> const winSpecialCaseParseTests = [
<del> ['/foo/bar', { root: '/' }]
<add> ['/foo/bar', { root: '/' }],
<add> ['C:', { root: 'C:', dir: 'C:', base: '' }],
<add> ['C:\\', { root: 'C:\\', dir: 'C:\\', base: '' }]
<ide> ];
<ide>
<ide> const winSpecialCaseFormatTests = [ | 1 |
Go | Go | remove unnecessary getlayerinit | c502bcff33e10be55f15366e123b25574016a9af | <ide><path>daemon/create.go
<ide> func (daemon *Daemon) setRWLayer(container *container.Container) error {
<ide>
<ide> rwLayerOpts := &layer.CreateRWLayerOpts{
<ide> MountLabel: container.MountLabel,
<del> InitFunc: daemon.getLayerInit(),
<add> InitFunc: setupInitLayer(daemon.idMappings),
<ide> StorageOpt: container.HostConfig.StorageOpt,
<ide> }
<ide>
<ide><path>daemon/daemon.go
<ide> import (
<ide> "github.com/sirupsen/logrus"
<ide> // register graph drivers
<ide> _ "github.com/docker/docker/daemon/graphdriver/register"
<del> "github.com/docker/docker/daemon/initlayer"
<ide> "github.com/docker/docker/daemon/stats"
<ide> dmetadata "github.com/docker/docker/distribution/metadata"
<ide> "github.com/docker/docker/distribution/xfer"
<ide> import (
<ide> "github.com/docker/docker/layer"
<ide> "github.com/docker/docker/libcontainerd"
<ide> "github.com/docker/docker/migrate/v1"
<del> "github.com/docker/docker/pkg/containerfs"
<ide> "github.com/docker/docker/pkg/idtools"
<ide> "github.com/docker/docker/pkg/locker"
<ide> "github.com/docker/docker/pkg/plugingetter"
<ide> func prepareTempDir(rootDir string, rootIDs idtools.IDPair) (string, error) {
<ide> return tmpDir, idtools.MkdirAllAndChown(tmpDir, 0700, rootIDs)
<ide> }
<ide>
<del>func (daemon *Daemon) setupInitLayer(initPath containerfs.ContainerFS) error {
<del> rootIDs := daemon.idMappings.RootPair()
<del> return initlayer.Setup(initPath, rootIDs)
<del>}
<del>
<ide> func (daemon *Daemon) setGenericResources(conf *config.Config) error {
<ide> genericResources, err := config.ParseGenericResources(conf.NodeGenericResources)
<ide> if err != nil {
<ide><path>daemon/daemon_unix.go
<ide> import (
<ide> containertypes "github.com/docker/docker/api/types/container"
<ide> "github.com/docker/docker/container"
<ide> "github.com/docker/docker/daemon/config"
<add> "github.com/docker/docker/daemon/initlayer"
<ide> "github.com/docker/docker/image"
<ide> "github.com/docker/docker/opts"
<ide> "github.com/docker/docker/pkg/containerfs"
<ide> func removeDefaultBridgeInterface() {
<ide> }
<ide> }
<ide>
<del>func (daemon *Daemon) getLayerInit() func(containerfs.ContainerFS) error {
<del> return daemon.setupInitLayer
<add>func setupInitLayer(idMappings *idtools.IDMappings) func(containerfs.ContainerFS) error {
<add> return func(initPath containerfs.ContainerFS) error {
<add> return initlayer.Setup(initPath, idMappings.RootPair())
<add> }
<ide> }
<ide>
<ide> // Parse the remapped root (user namespace) option, which can be one of:
<ide><path>daemon/daemon_windows.go
<ide> func parseSecurityOpt(container *container.Container, config *containertypes.Hos
<ide> return nil
<ide> }
<ide>
<del>func (daemon *Daemon) getLayerInit() func(containerfs.ContainerFS) error {
<add>func setupInitLayer(idMappings *idtools.IDMappings) func(containerfs.ContainerFS) error {
<ide> return nil
<ide> }
<ide> | 4 |
PHP | PHP | add table to the debug info, and remove toarray() | 307b91cbece6bebddce2f8d3e1ee144e6d9fc60e | <ide><path>src/Database/Schema/TableSchema.php
<ide> public function dropConstraintSql(Connection $connection)
<ide> *
<ide> * @return array
<ide> */
<del> public function toArray()
<add> public function __debugInfo()
<ide> {
<ide> return [
<add> 'table' => $this->_table,
<ide> 'columns' => $this->_columns,
<ide> 'indexes' => $this->_indexes,
<ide> 'constraints' => $this->_constraints,
<ide> public function toArray()
<ide> 'temporary' => $this->_temporary,
<ide> ];
<ide> }
<del>
<del> /**
<del> * Returns an array of the table schema.
<del> *
<del> * @return array
<del> */
<del> public function __debugInfo()
<del> {
<del> return $this->toArray();
<del> }
<ide> }
<ide>
<ide> // @deprecated Add backwards compat alias.
<ide><path>tests/TestCase/Database/Schema/TableTest.php
<ide> public function testTemporary()
<ide> $this->assertFalse($table->temporary());
<ide> }
<ide>
<del> /**
<del> * Tests the toArray() method.
<del> *
<del> * @return void
<del> */
<del> public function testToArray()
<del> {
<del> $table = new Table('articles');
<del> $result = $table->toArray();
<del> $expected = [
<del> 'columns' => [],
<del> 'indexes' => [],
<del> 'constraints' => [],
<del> 'options' => [],
<del> 'typeMap' => [],
<del> 'temporary' => false,
<del> ];
<del> $this->assertSame($expected, $result);
<del> }
<del>
<del> /**
<del> * Tests the __debugInfo() method.
<del> *
<del> * @return void
<del> */
<del> public function testDebugInfo()
<del> {
<del> $table = new Table('articles');
<del> $table->setTemporary(true);
<del>
<del> $result = $table->__debugInfo();
<del> $expected = [
<del> 'columns' => [],
<del> 'indexes' => [],
<del> 'constraints' => [],
<del> 'options' => [],
<del> 'typeMap' => [],
<del> 'temporary' => true,
<del> ];
<del> $this->assertSame($expected, $result);
<del> }
<del>
<ide> /**
<ide> * Assertion for comparing a regex pattern against a query having its identifiers
<ide> * quoted. It accepts queries quoted with the characters `<` and `>`. If the third | 2 |
PHP | PHP | display column listing when using fetch_assoc | 41af46bd21065da7ca97539b400617a3961f3d77 | <ide><path>src/Illuminate/Database/Query/Processors/SqlServerProcessor.php
<ide> public function processInsertGetId(Builder $query, $sql, $values, $sequence = nu
<ide> public function processColumnListing($results)
<ide> {
<ide> $mapping = function ($r) {
<add> $r = (object) $r;
<ide> return $r->name;
<ide> };
<ide> | 1 |
Text | Text | remove code tags from name | 5ebd007390f8d93e27f7b7cfe9dd20c4881c42f9 | <ide><path>curriculum/challenges/english/14-responsive-web-design-22/learn-css-transforms-by-building-a-penguin/619d30350883802921bfcccc.md
<ide> You should defined a new `@keyframes` rule.
<ide> assert.notEmpty(new __helpers.CSSHelp(document).getCSSRules('keyframes'));
<ide> ```
<ide>
<del>You should give the `@keyframes` rule a `name` of `--fcc-expected--`, but found `--fcc-actual--`.
<add>You should give the `@keyframes` rule a name of `--fcc-expected--`, but found `--fcc-actual--`.
<ide>
<ide> ```js
<ide> assert.equal(new __helpers.CSSHelp(document).getCSSRules('keyframes')?.[0]?.name, 'wave'); | 1 |
Python | Python | use rnns to answer questions from babi | de78ddff9c6c14e606fce8d88d04de0eff77319b | <ide><path>examples/babi_rnn.py
<add>from __future__ import absolute_import
<add>from __future__ import print_function
<add>import re
<add>import tarfile
<add>
<add>import numpy as np
<add>np.random.seed(1337) # for reproducibility
<add>
<add>from keras.datasets.data_utils import get_file
<add>from keras.layers.embeddings import Embedding
<add>from keras.layers.core import Dense, Merge
<add>from keras.layers import recurrent
<add>from keras.models import Sequential
<add>from keras.preprocessing.sequence import pad_sequences
<add>
<add>'''
<add>Trains two recurrent neural networks based upon a story and a question.
<add>The resulting merged vector is then queried to answer a range of bAbI tasks.
<add>
<add>The results are comparable to those for an LSTM model provided in Weston et al.:
<add>"Towards AI-Complete Question Answering: A Set of Prerequisite Toy Tasks"
<add>http://arxiv.org/abs/1502.05698
<add>
<add>For the resources related to the bAbI project, refer to:
<add>https://research.facebook.com/researchers/1543934539189348
<add>
<add>Notes:
<add>
<add>- With default word, sentence, and query vector sizes, the GRU model achieves:
<add> - 52.1% test accuracy on QA1 in 20 epochs (2 seconds per epoch on CPU)
<add> - 37.0% test accuracy on QA2 in 20 epochs (16 seconds per epoch on CPU)
<add>In comparison, the Facebook paper achieves 50% and 20% for the LSTM baseline.
<add>
<add>- The task does not traditionally parse the question separately. This likely
<add>improves accuracy and is a good example of merging two RNNs.
<add>
<add>- The word vector embeddings are not shared between the story and question RNNs.
<add>
<add>- See how the accuracy changes given 10,000 training samples (en-10k) instead
<add>of only 1000. 1000 was used in order to be comparable to the original paper.
<add>
<add>- Experiment with GRU, LSTM, and JZS1-3 as they give subtly different results.
<add>
<add>- The length and noise (i.e. 'useless' story components) impact the ability for
<add>LSTMs / GRUs to provide the correct answer. Given only the supporting facts,
<add>these RNNs can achieve 100% accuracy on many tasks. Memory networks and neural
<add>networks that use attentional processes can efficiently search through this
<add>noise to find the relevant statements, improving performance substantially.
<add>This becomes especially obvious on QA2 and QA3, both far longer than QA1.
<add>'''
<add>
<add>def tokenize(sent):
<add> '''Return the tokens of a sentence including punctuation.
<add>
<add> >>> tokenize('Bob dropped the apple. Where is the apple?')
<add> ['Bob', 'dropped', 'the', 'apple', '.', 'Where', 'is', 'the', 'apple', '?']
<add> '''
<add> return [x.strip() for x in re.split('(\W+)?', sent) if x.strip()]
<add>
<add>def parse_stories(lines, only_supporting=False):
<add> '''Parse stories provided in the bAbi tasks format
<add>
<add> If only_supporting is true, only the sentences that support the answer are kept.
<add> '''
<add> data = []
<add> story = []
<add> for line in lines:
<add> line = line.strip()
<add> nid, line = line.split(' ', 1)
<add> nid = int(nid)
<add> if nid == 1:
<add> story = []
<add> if '\t' in line:
<add> q, a, supporting = line.split('\t')
<add> q = tokenize(q)
<add> substory = None
<add> if only_supporting:
<add> # Only select the related substory
<add> supporting = map(int, supporting.split())
<add> substory = [story[i - 1] for i in supporting]
<add> else:
<add> # Provide all the substories
<add> substory = [x for x in story if x]
<add> data.append((substory, q, a))
<add> story.append('')
<add> else:
<add> sent = tokenize(line)
<add> story.append(sent)
<add> return data
<add>
<add>def get_stories(f, only_supporting=False, max_length=None):
<add> '''Given a file name, read the file, retrieve the stories, and then convert the sentences into a single story.
<add>
<add> If max_length is supplied, any stories longer than max_length tokens will be discarded.
<add> '''
<add> data = parse_stories(f.readlines(), only_supporting=only_supporting)
<add> flatten = lambda data: reduce(lambda x, y: x + y, data)
<add> data = [(flatten(story), q, answer) for story, q, answer in data if not max_length or len(flatten(story)) < max_length]
<add> return data
<add>
<add>def vectorize_stories(data):
<add> X = []
<add> Xq = []
<add> Y = []
<add> for story, query, answer in data:
<add> x = [word_idx[w] for w in story]
<add> xq = [word_idx[w] for w in query]
<add> y = np.zeros(vocab_size)
<add> y[word_idx[answer]] = 1
<add> X.append(x)
<add> Xq.append(xq)
<add> Y.append(y)
<add> return pad_sequences(X, maxlen=story_maxlen), pad_sequences(Xq, maxlen=query_maxlen), np.array(Y)
<add>
<add>RNN = recurrent.GRU
<add>EMBED_HIDDEN_SIZE = 50
<add>SENT_HIDDEN_SIZE = 100
<add>QUERY_HIDDEN_SIZE = 100
<add>BATCH_SIZE = 32
<add>EPOCHS = 20
<add>print('RNN / Embed / Sent / Query = {}, {}, {}, {}'.format(RNN, EMBED_HIDDEN_SIZE, SENT_HIDDEN_SIZE, QUERY_HIDDEN_SIZE))
<add>
<add>path = get_file('babi-tasks-v1-2.tar.gz', origin='http://www.thespermwhale.com/jaseweston/babi/tasks_1-20_v1-2.tar.gz')
<add>tar = tarfile.open(path)
<add># Default QA1 with 1000 samples
<add>#challenge = 'tasks_1-20_v1-2/en/qa1_single-supporting-fact_{}.txt'
<add># QA1 with 10,000 samples
<add>#challenge = 'tasks_1-20_v1-2/en-10k/qa1_single-supporting-fact_{}.txt'
<add># QA2 with 1000 samples
<add>challenge = 'tasks_1-20_v1-2/en/qa2_two-supporting-facts_{}.txt'
<add># QA2 with 1000 samples
<add>#challenge = 'tasks_1-20_v1-2/en-10k/qa2_two-supporting-facts_{}.txt'
<add>train = get_stories(tar.extractfile(challenge.format('train')))
<add>test = get_stories(tar.extractfile(challenge.format('test')))
<add>
<add>vocab = sorted(reduce(lambda x, y: x | y, (set(story + q) for story, q, answer in train + test)))
<add># Reserve 0 for masking via pad_sequences
<add>vocab_size = len(vocab) + 1
<add>word_idx = dict((c, i + 1) for i, c in enumerate(vocab))
<add>story_maxlen = max(map(len, (x for x, _, _ in train + test)))
<add>query_maxlen = max(map(len, (x for _, x, _ in train + test)))
<add>
<add>X, Xq, Y = vectorize_stories(train)
<add>tX, tXq, tY = vectorize_stories(test)
<add>
<add>print('vocab = {}'.format(vocab))
<add>print('X.shape = {}'.format(X.shape))
<add>print('Xq.shape = {}'.format(Xq.shape))
<add>print('Y.shape = {}'.format(Y.shape))
<add>print('story_maxlen, query_maxlen = {}, {}'.format(story_maxlen, query_maxlen))
<add>
<add>print('Build model...')
<add>
<add>sentrnn = Sequential()
<add>sentrnn.add(Embedding(vocab_size, EMBED_HIDDEN_SIZE, mask_zero=True))
<add>sentrnn.add(RNN(EMBED_HIDDEN_SIZE, SENT_HIDDEN_SIZE, return_sequences=False))
<add>
<add>qrnn = Sequential()
<add>qrnn.add(Embedding(vocab_size, EMBED_HIDDEN_SIZE))
<add>qrnn.add(RNN(EMBED_HIDDEN_SIZE, QUERY_HIDDEN_SIZE, return_sequences=False))
<add>
<add>model = Sequential()
<add>model.add(Merge([sentrnn, qrnn], mode='concat'))
<add>model.add(Dense(SENT_HIDDEN_SIZE + QUERY_HIDDEN_SIZE, vocab_size, activation='softmax'))
<add>
<add>model.compile(optimizer='adam', loss='categorical_crossentropy', class_mode='categorical')
<add>
<add>print('Training')
<add>model.fit([X, Xq], Y, batch_size=BATCH_SIZE, nb_epoch=EPOCHS, validation_split=0.05, show_accuracy=True)
<add>loss, acc = model.evaluate([tX, tXq], tY, batch_size=BATCH_SIZE, show_accuracy=True)
<add>print('Test loss / test accuracy = {:.4f} / {:.4f}'.format(loss, acc)) | 1 |
Java | Java | avoid infinite loop in patternmatchutils | db80378dbef4bba302a3f1248f7315ae1ef8f614 | <ide><path>spring-core/src/main/java/org/springframework/util/PatternMatchUtils.java
<ide> /*
<del> * Copyright 2002-2007 the original author or authors.
<add> * Copyright 2002-2015 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> public static boolean simpleMatch(String pattern, String str) {
<ide> return str.endsWith(pattern.substring(1));
<ide> }
<ide> String part = pattern.substring(1, nextIndex);
<add> if ("".equals(part)) {
<add> return simpleMatch(pattern.substring(nextIndex), str);
<add> }
<ide> int partIndex = str.indexOf(part);
<ide> while (partIndex != -1) {
<ide> if (simpleMatch(pattern.substring(nextIndex), str.substring(partIndex + part.length()))) {
<ide> public static boolean simpleMatch(String pattern, String str) {
<ide> */
<ide> public static boolean simpleMatch(String[] patterns, String str) {
<ide> if (patterns != null) {
<del> for (int i = 0; i < patterns.length; i++) {
<del> if (simpleMatch(patterns[i], str)) {
<add> for (String pattern : patterns) {
<add> if (simpleMatch(pattern, str)) {
<ide> return true;
<ide> }
<ide> }
<ide><path>spring-core/src/test/java/org/springframework/util/PatternMatchUtilsTests.java
<ide> /*
<del> * Copyright 2002-2007 the original author or authors.
<add> * Copyright 2002-2015 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide>
<ide> package org.springframework.util;
<ide>
<del>import junit.framework.TestCase;
<add>import org.junit.Test;
<add>
<add>import static org.junit.Assert.*;
<ide>
<ide> /**
<ide> * @author Juergen Hoeller
<ide> * @author Johan Gorter
<ide> */
<del>public class PatternMatchUtilsTests extends TestCase {
<add>public class PatternMatchUtilsTests {
<ide>
<add> @Test
<ide> public void testTrivial() {
<ide> assertEquals(false, PatternMatchUtils.simpleMatch((String) null, ""));
<ide> assertEquals(false, PatternMatchUtils.simpleMatch("1", null));
<ide> doTest("*", "123", true);
<ide> doTest("123", "123", true);
<ide> }
<ide>
<add> @Test
<ide> public void testStartsWith() {
<ide> doTest("get*", "getMe", true);
<ide> doTest("get*", "setMe", false);
<ide> }
<ide>
<add> @Test
<ide> public void testEndsWith() {
<ide> doTest("*Test", "getMeTest", true);
<ide> doTest("*Test", "setMe", false);
<ide> }
<ide>
<add> @Test
<ide> public void testBetween() {
<ide> doTest("*stuff*", "getMeTest", false);
<ide> doTest("*stuff*", "getstuffTest", true);
<ide> public void testBetween() {
<ide> doTest("*stuff*", "stuff", true);
<ide> }
<ide>
<add> @Test
<ide> public void testStartsEnds() {
<ide> doTest("on*Event", "onMyEvent", true);
<ide> doTest("on*Event", "onEvent", true);
<ide> doTest("3*3", "3", false);
<ide> doTest("3*3", "33", true);
<ide> }
<ide>
<add> @Test
<ide> public void testStartsEndsBetween() {
<ide> doTest("12*45*78", "12345678", true);
<ide> doTest("12*45*78", "123456789", false);
<ide> public void testStartsEndsBetween() {
<ide> doTest("3*3*3", "333", true);
<ide> }
<ide>
<add> @Test
<ide> public void testRidiculous() {
<ide> doTest("*1*2*3*", "0011002001010030020201030", true);
<ide> doTest("1*2*3*4", "10300204", false);
<ide> public void testRidiculous() {
<ide> doTest("*1*2*3*", "132", false);
<ide> }
<ide>
<add> @Test
<add> public void testPatternVariants() {
<add> doTest("*a", "*", false);
<add> doTest("*a", "a", true);
<add> doTest("*a", "b", false);
<add> doTest("*a", "aa", true);
<add> doTest("*a", "ba", true);
<add> doTest("*a", "ab", false);
<add> doTest("**a", "*", false);
<add> doTest("**a", "a", true);
<add> doTest("**a", "b", false);
<add> doTest("**a", "aa", true);
<add> doTest("**a", "ba", true);
<add> doTest("**a", "ab", false);
<add> }
<add>
<ide> private void doTest(String pattern, String str, boolean shouldMatch) {
<ide> assertEquals(shouldMatch, PatternMatchUtils.simpleMatch(pattern, str));
<ide> } | 2 |
Ruby | Ruby | add missing require for `string#to_d` | a1c57cf69f2454d5ba3a086237c1c827e6c9de5a | <ide><path>activesupport/lib/active_support/xml_mini.rb
<ide> require "time"
<ide> require "base64"
<ide> require "bigdecimal"
<add>require "bigdecimal/util"
<ide> require "active_support/core_ext/module/delegation"
<ide> require "active_support/core_ext/string/inflections"
<ide> require "active_support/core_ext/date_time/calculations" | 1 |
Ruby | Ruby | add tests to aliased _filter callbacks | 1b97d41e52e4888681b81f99335d851d434458d1 | <ide><path>actionpack/test/abstract/callbacks_test.rb
<ide> class TestCallbacksWithArgs < ActiveSupport::TestCase
<ide> assert_equal "Hello world Howdy!", controller.response_body
<ide> end
<ide> end
<add>
<add> class AliasedCallbacks < ControllerWithCallbacks
<add> before_filter :first
<add> after_filter :second
<add> around_filter :aroundz
<add>
<add> def first
<add> @text = "Hello world"
<add> end
<add>
<add> def second
<add> @second = "Goodbye"
<add> end
<add>
<add> def aroundz
<add> @aroundz = "FIRST"
<add> yield
<add> @aroundz << "SECOND"
<add> end
<add>
<add> def index
<add> @text ||= nil
<add> self.response_body = @text.to_s
<add> end
<add> end
<add>
<add> class TestAliasedCallbacks < ActiveSupport::TestCase
<add> def setup
<add> @controller = AliasedCallbacks.new
<add> end
<add>
<add> test "before_filter works" do
<add> @controller.process(:index)
<add> assert_equal "Hello world", @controller.response_body
<add> end
<add>
<add> test "after_filter works" do
<add> @controller.process(:index)
<add> assert_equal "Goodbye", @controller.instance_variable_get("@second")
<add> end
<add>
<add> test "around_filter works" do
<add> @controller.process(:index)
<add> assert_equal "FIRSTSECOND", @controller.instance_variable_get("@aroundz")
<add> end
<add> end
<ide> end
<ide> end | 1 |
Go | Go | fix temparchive cleanup w/ one read | 32ba6ab83c7e47d627a2b971e7f6ca9b56e1be85 | <ide><path>pkg/archive/archive.go
<ide> func NewTempArchive(src Archive, dir string) (*TempArchive, error) {
<ide> return nil, err
<ide> }
<ide> size := st.Size()
<del> return &TempArchive{f, size}, nil
<add> return &TempArchive{f, size, 0}, nil
<ide> }
<ide>
<ide> type TempArchive struct {
<ide> *os.File
<ide> Size int64 // Pre-computed from Stat().Size() as a convenience
<add> read int64
<ide> }
<ide>
<ide> func (archive *TempArchive) Read(data []byte) (int, error) {
<ide> n, err := archive.File.Read(data)
<del> if err != nil {
<add> archive.read += int64(n)
<add> if err != nil || archive.read == archive.Size {
<add> archive.File.Close()
<ide> os.Remove(archive.File.Name())
<ide> }
<ide> return n, err | 1 |
Javascript | Javascript | reset numintersection in projectplanes() | cf9357b8e1cfd1a3e0287ed87aef66b707d72b9d | <ide><path>src/renderers/webgl/WebGLClipping.js
<ide> function WebGLClipping() {
<ide> }
<ide>
<ide> scope.numPlanes = nPlanes;
<add> scope.numIntersection = 0;
<ide>
<ide> return dstArray;
<ide> | 1 |
Python | Python | add tests for spark_jdbc_script | 067806d5985301f21da78f0a81056dbec348e6ba | <ide><path>airflow/providers/apache/spark/hooks/spark_jdbc_script.py
<ide> # under the License.
<ide> #
<ide> import argparse
<add>from typing import List, Optional
<ide>
<ide> from pyspark.sql import SparkSession
<ide>
<add>SPARK_WRITE_TO_JDBC = "spark_to_jdbc"
<add>SPARK_READ_FROM_JDBC = "jdbc_to_spark"
<add>
<ide>
<ide> def set_common_options(spark_source,
<ide> url='localhost:5432',
<ide> def spark_read_from_jdbc(spark_session, url, user, password, metastore_table, jd
<ide> .saveAsTable(metastore_table, format=save_format, mode=save_mode)
<ide>
<ide>
<del>if __name__ == "__main__": # pragma: no cover
<del> # parse the parameters
<add>def _parse_arguments(args: Optional[List[str]] = None):
<ide> parser = argparse.ArgumentParser(description='Spark-JDBC')
<ide> parser.add_argument('-cmdType', dest='cmd_type', action='store')
<ide> parser.add_argument('-url', dest='url', action='store')
<ide> def spark_read_from_jdbc(spark_session, url, user, password, metastore_table, jd
<ide> parser.add_argument('-upperBound', dest='upper_bound', action='store')
<ide> parser.add_argument('-createTableColumnTypes',
<ide> dest='create_table_column_types', action='store')
<del> arguments = parser.parse_args()
<add> return parser.parse_args(args=args)
<ide>
<del> # Disable dynamic allocation by default to allow num_executors to take effect.
<del> spark = SparkSession.builder \
<add>
<add>def _create_spark_session(arguments) -> SparkSession:
<add> return SparkSession.builder \
<ide> .appName(arguments.name) \
<ide> .enableHiveSupport() \
<ide> .getOrCreate()
<ide>
<del> if arguments.cmd_type == "spark_to_jdbc":
<add>
<add>def _run_spark(arguments):
<add> # Disable dynamic allocation by default to allow num_executors to take effect.
<add> spark = _create_spark_session(arguments)
<add>
<add> if arguments.cmd_type == SPARK_WRITE_TO_JDBC:
<ide> spark_write_to_jdbc(spark,
<ide> arguments.url,
<ide> arguments.user,
<ide> def spark_read_from_jdbc(spark_session, url, user, password, metastore_table, jd
<ide> arguments.batch_size,
<ide> arguments.num_partitions,
<ide> arguments.create_table_column_types)
<del> elif arguments.cmd_type == "jdbc_to_spark":
<add> elif arguments.cmd_type == SPARK_READ_FROM_JDBC:
<ide> spark_read_from_jdbc(spark,
<ide> arguments.url,
<ide> arguments.user,
<ide> def spark_read_from_jdbc(spark_session, url, user, password, metastore_table, jd
<ide> arguments.partition_column,
<ide> arguments.lower_bound,
<ide> arguments.upper_bound)
<add>
<add>
<add>if __name__ == "__main__": # pragma: no cover
<add> _run_spark(arguments=_parse_arguments())
<ide><path>tests/providers/apache/spark/hooks/test_spark_jdbc_script.py
<add># Licensed to the Apache Software Foundation (ASF) under one
<add># or more contributor license agreements. See the NOTICE file
<add># distributed with this work for additional information
<add># regarding copyright ownership. The ASF licenses this file
<add># to you under the Apache License, Version 2.0 (the
<add># "License"); you may not use this file except in compliance
<add># with the License. You may obtain a copy of the License at
<add>#
<add># http://www.apache.org/licenses/LICENSE-2.0
<add>#
<add># Unless required by applicable law or agreed to in writing,
<add># software distributed under the License is distributed on an
<add># "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
<add># KIND, either express or implied. See the License for the
<add># specific language governing permissions and limitations
<add># under the License.
<add>import mock
<add>import pytest
<add>from pyspark.sql.readwriter import DataFrameReader, DataFrameWriter
<add>
<add>from airflow.providers.apache.spark.hooks.spark_jdbc_script import (
<add> SPARK_READ_FROM_JDBC, SPARK_WRITE_TO_JDBC, _create_spark_session, _parse_arguments, _run_spark,
<add> spark_read_from_jdbc, spark_write_to_jdbc,
<add>)
<add>
<add>
<add>@pytest.fixture()
<add>def mock_spark_session():
<add> with mock.patch('airflow.providers.apache.spark.hooks.spark_jdbc_script.SparkSession') as mok:
<add> yield mok
<add>
<add>
<add>class TestSparkJDBCScrip:
<add> jdbc_arguments = [
<add> '-cmdType', 'spark_to_jdbc',
<add> '-url', 'jdbc:postgresql://localhost:5432/default',
<add> '-user', 'user',
<add> '-password', 'supersecret',
<add> '-metastoreTable', 'hiveMcHiveFace',
<add> '-jdbcTable', 'tableMcTableFace',
<add> '-jdbcDriver', 'org.postgresql.Driver',
<add> '-jdbcTruncate', 'false',
<add> '-saveMode', 'append',
<add> '-saveFormat', 'parquet',
<add> '-batchsize', '100',
<add> '-fetchsize', '200',
<add> '-name', 'airflow-spark-jdbc-script-test',
<add> '-numPartitions', '10',
<add> '-partitionColumn', 'columnMcColumnFace',
<add> '-lowerBound', '10',
<add> '-upperBound', '20',
<add> '-createTableColumnTypes', 'columnMcColumnFace INTEGER(100), name CHAR(64),'
<add> 'comments VARCHAR(1024)'
<add> ]
<add>
<add> default_arguments = {
<add> 'cmd_type': 'spark_to_jdbc',
<add> 'url': 'jdbc:postgresql://localhost:5432/default',
<add> 'user': 'user',
<add> 'password': 'supersecret',
<add> 'metastore_table': 'hiveMcHiveFace',
<add> 'jdbc_table': 'tableMcTableFace',
<add> 'jdbc_driver': 'org.postgresql.Driver',
<add> 'truncate': 'false',
<add> 'save_mode': 'append',
<add> 'save_format': 'parquet',
<add> 'batch_size': '100',
<add> 'fetch_size': '200',
<add> 'name': 'airflow-spark-jdbc-script-test',
<add> 'num_partitions': '10',
<add> 'partition_column': 'columnMcColumnFace',
<add> 'lower_bound': '10',
<add> 'upper_bound': '20',
<add> 'create_table_column_types': 'columnMcColumnFace INTEGER(100), name CHAR(64),'
<add> 'comments VARCHAR(1024)'
<add> }
<add>
<add> def test_parse_arguments(self):
<add> # When
<add> parsed_arguments = _parse_arguments(args=self.jdbc_arguments)
<add>
<add> # Then
<add> for argument_name, argument_value in self.default_arguments.items():
<add> assert getattr(parsed_arguments, argument_name) == argument_value
<add>
<add> @mock.patch('airflow.providers.apache.spark.hooks.spark_jdbc_script.spark_write_to_jdbc')
<add> def test_run_spark_write_to_jdbc(self, mock_spark_write_to_jdbc, mock_spark_session):
<add> # Given
<add> arguments = _parse_arguments(['-cmdType', SPARK_WRITE_TO_JDBC] + self.jdbc_arguments[2:])
<add> spark_session = mock_spark_session.builder \
<add> .appName(arguments.name) \
<add> .enableHiveSupport() \
<add> .getOrCreate()
<add>
<add> # When
<add> _run_spark(arguments=arguments)
<add>
<add> # Then
<add> mock_spark_write_to_jdbc.assert_called_once_with(
<add> spark_session,
<add> arguments.url,
<add> arguments.user,
<add> arguments.password,
<add> arguments.metastore_table,
<add> arguments.jdbc_table,
<add> arguments.jdbc_driver,
<add> arguments.truncate,
<add> arguments.save_mode,
<add> arguments.batch_size,
<add> arguments.num_partitions,
<add> arguments.create_table_column_types,
<add> )
<add>
<add> @mock.patch('airflow.providers.apache.spark.hooks.spark_jdbc_script.spark_read_from_jdbc')
<add> def test_run_spark_read_from_jdbc(self, mock_spark_read_from_jdbc, mock_spark_session):
<add> # Given
<add> arguments = _parse_arguments(['-cmdType', SPARK_READ_FROM_JDBC] + self.jdbc_arguments[2:])
<add> spark_session = mock_spark_session.builder \
<add> .appName(arguments.name) \
<add> .enableHiveSupport() \
<add> .getOrCreate()
<add>
<add> # When
<add> _run_spark(arguments=arguments)
<add>
<add> # Then
<add> mock_spark_read_from_jdbc.assert_called_once_with(
<add> spark_session,
<add> arguments.url,
<add> arguments.user,
<add> arguments.password,
<add> arguments.metastore_table,
<add> arguments.jdbc_table,
<add> arguments.jdbc_driver,
<add> arguments.save_mode,
<add> arguments.save_format,
<add> arguments.fetch_size,
<add> arguments.num_partitions,
<add> arguments.partition_column,
<add> arguments.lower_bound,
<add> arguments.upper_bound
<add> )
<add>
<add> @pytest.mark.system("spark")
<add> @mock.patch.object(DataFrameWriter, 'save')
<add> def test_spark_write_to_jdbc(self, mock_writer_save):
<add> # Given
<add> arguments = _parse_arguments(self.jdbc_arguments)
<add> spark_session = _create_spark_session(arguments)
<add> spark_session.sql("CREATE TABLE IF NOT EXISTS " + arguments.metastore_table + " (key INT)")
<add> # When
<add>
<add> spark_write_to_jdbc(
<add> spark_session=spark_session,
<add> url=arguments.url,
<add> user=arguments.user,
<add> password=arguments.password,
<add> metastore_table=arguments.metastore_table,
<add> jdbc_table=arguments.jdbc_table,
<add> driver=arguments.jdbc_driver,
<add> truncate=arguments.truncate,
<add> save_mode=arguments.save_mode,
<add> batch_size=arguments.batch_size,
<add> num_partitions=arguments.num_partitions,
<add> create_table_column_types=arguments.create_table_column_types,
<add> )
<add>
<add> # Then
<add> mock_writer_save.assert_called_once_with(mode=arguments.save_mode)
<add>
<add> @pytest.mark.system("spark")
<add> @mock.patch.object(DataFrameReader, 'load')
<add> def test_spark_read_from_jdbc(self, mock_reader_load):
<add> # Given
<add> arguments = _parse_arguments(self.jdbc_arguments)
<add> spark_session = _create_spark_session(arguments)
<add> spark_session.sql("CREATE TABLE IF NOT EXISTS " + arguments.metastore_table + " (key INT)")
<add>
<add> # When
<add> spark_read_from_jdbc(
<add> spark_session,
<add> arguments.url,
<add> arguments.user,
<add> arguments.password,
<add> arguments.metastore_table,
<add> arguments.jdbc_table,
<add> arguments.jdbc_driver,
<add> arguments.save_mode,
<add> arguments.save_format,
<add> arguments.fetch_size,
<add> arguments.num_partitions,
<add> arguments.partition_column,
<add> arguments.lower_bound,
<add> arguments.upper_bound,
<add> )
<add>
<add> # Then
<add> mock_reader_load().write.saveAsTable.assert_called_once_with(
<add> arguments.metastore_table, format=arguments.save_format, mode=arguments.save_mode
<add> )
<ide><path>tests/test_project_structure.py
<ide> 'tests/providers/apache/cassandra/sensors/test_record.py',
<ide> 'tests/providers/apache/cassandra/sensors/test_table.py',
<ide> 'tests/providers/apache/hdfs/sensors/test_web_hdfs.py',
<del> 'tests/providers/apache/spark/hooks/test_spark_jdbc_script.py',
<ide> 'tests/providers/google/cloud/operators/test_datastore.py',
<ide> 'tests/providers/google/cloud/transfers/test_sql_to_gcs.py',
<ide> 'tests/providers/google/cloud/utils/test_field_sanitizer.py', | 3 |
Text | Text | add cssnext-loader to readme | 23fab97c196f49abc4c890b1473519989192877c | <ide><path>README.md
<ide> Please see [Using Loaders](http://webpack.github.io/docs/using-loaders.html) for
<ide> **styling**
<ide> * [`style`](https://github.com/webpack/style-loader): Add exports of a module as style to DOM
<ide> * [`css`](https://github.com/webpack/css-loader): Loads css file with resolved imports and returns css code
<add>* [`cssnext`](https://github.com/cssnext/cssnext-loader): Loads and compiles a css file using [cssnext](http://cssnext.io/)
<ide> * [`less`](https://github.com/webpack/less-loader): Loads and compiles a less file
<ide> * [`sass`](https://github.com/jtangelder/sass-loader): Loads and compiles a scss file
<ide> * [`stylus`](https://github.com/shama/stylus-loader): Loads and compiles a stylus file | 1 |
Python | Python | fix python 3 support | 904b82759cce6f85d06564c42123da030da52341 | <ide><path>django/db/models/fields/related.py
<ide> def deconstruct(self):
<ide> rel = self.rel
<ide> if self.rel.field_name:
<ide> kwargs['to_field'] = self.rel.field_name
<del> if isinstance(self.rel.to, basestring):
<add> if isinstance(self.rel.to, six.string_types):
<ide> kwargs['to'] = self.rel.to
<ide> else:
<ide> kwargs['to'] = "%s.%s" % (self.rel.to._meta.app_label, self.rel.to._meta.object_name)
<ide> def deconstruct(self):
<ide> del kwargs['help_text']
<ide> # Rel needs more work.
<ide> rel = self.rel
<del> if isinstance(self.rel.to, basestring):
<add> if isinstance(self.rel.to, six.string_types):
<ide> kwargs['to'] = self.rel.to
<ide> else:
<ide> kwargs['to'] = "%s.%s" % (self.rel.to._meta.app_label, self.rel.to._meta.object_name) | 1 |
Python | Python | read parameters from cli, load model & tokenizer | b3261e7ace153a78c19e35bba367e28e9ccdd2fa | <ide><path>examples/run_seq2seq_finetuning.py
<ide> Natural Language Understanding and Generation.” (May 2019) ArXiv:1905.03197
<ide> """
<ide>
<add>import argparse
<ide> import logging
<ide> import random
<ide>
<ide> import numpy as np
<ide> import torch
<ide>
<add>from transformers import BertConfig, Bert2Rnd, BertTokenizer
<add>
<ide> logger = logging.getLogger(__name__)
<ide>
<ide>
<ide> def set_seed(args):
<ide> random.seed(args.seed)
<ide> np.random.seed(args.seed)
<ide> torch.manual_seed(args.seed)
<del> if args.n_gpu > 0:
<del> torch.cuda.manual_seed_all(args.seed)
<ide>
<ide>
<del>def train(args, train_dataset, model, tokenizer):
<del> """ Fine-tune the pretrained model on the corpus. """
<del> # Data sampler
<del> # Data loader
<del> # Training
<add>def load_and_cache_examples(args, tokenizer):
<ide> raise NotImplementedError
<ide>
<ide>
<del>def evaluate(args, model, tokenizer, prefix=""):
<add>def train(args, train_dataset, model, tokenizer):
<add> """ Fine-tune the pretrained model on the corpus. """
<ide> raise NotImplementedError
<ide>
<ide>
<ide> def main():
<del> raise NotImplementedError
<add> parser = argparse.ArgumentParser()
<add>
<add> # Required parameters
<add> parser.add_argument("--train_data_file",
<add> default=None,
<add> type=str,
<add> required=True,
<add> help="The input training data file (a text file).")
<add> parser.add_argument("--output_dir",
<add> default=None,
<add> type=str,
<add> required=True,
<add> help="The output directory where the model predictions and checkpoints will be written.")
<add>
<add> # Optional parameters
<add> parser.add_argument("--model_name_or_path",
<add> default="bert-base-cased",
<add> type=str,
<add> help="The model checkpoint for weights initialization.")
<add> parser.add_argument("--seed", default=42, type=int)
<add> args = parser.parse_args()
<add>
<add> # Set up training device
<add> device = torch.device("cpu")
<add>
<add> # Set seed
<add> set_seed(args)
<add>
<add> # Load pretrained model and tokenizer
<add> config_class, model_class, tokenizer_class = BertConfig, Bert2Rnd, BertTokenizer
<add> config = config_class.from_pretrained(args.model_name_or_path)
<add> tokenizer = tokenizer_class.from_pretrained(args.model_name_or_path)
<add> model = model_class.from_pretrained(args.model_name_or_path, config=config)
<add> model.to(device)
<add>
<add> logger.info("Training/evaluation parameters %s", args)
<add>
<add> # Training
<add> train_dataset = load_and_cache_examples(args, tokenizer)
<add> global_step, tr_loss = train(args, train_dataset, model, tokenizer)
<add> logger.info(" global_step = %s, average loss = %s", global_step, tr_loss)
<ide>
<ide>
<del>def __main__():
<add>if __name__ == "__main__":
<ide> main()
<ide><path>examples/run_summarization.py
<del># coding=utf-8
<del># Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
<del># Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
<del>#
<del># Licensed under the Apache License, Version 2.0 (the "License");
<del># you may not use this file except in compliance with the License.
<del># You may obtain a copy of the License at
<del>#
<del># http://www.apache.org/licenses/LICENSE-2.0
<del>#
<del># Unless required by applicable law or agreed to in writing, software
<del># distributed under the License is distributed on an "AS IS" BASIS,
<del># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<del># See the License for the specific language governing permissions and
<del># limitations under the License.
<del>""" Finetuning seq2seq models for abstractive summarization.
<del>
<del>The finetuning method for abstractive summarization is inspired by [1]. We
<del>concatenate the document and summary, mask words of the summary at random and
<del>maximizing the likelihood of masked words.
<del>
<del>[1] Dong Li, Nan Yang, Wenhui Wang, Furu Wei, Xiaodong Liu, Yu Wang, Jianfeng
<del>Gao, Ming Zhou, and Hsiao-Wuen Hon. “Unified Language Model Pre-Training for
<del>Natural Language Understanding and Generation.” (May 2019) ArXiv:1905.03197
<del>"""
<del>
<del>import logging
<del>import random
<del>
<del>import numpy as np
<del>import torch
<del>
<del>logger = logging.getLogger(__name__)
<del>
<del>
<del>def set_seed(args):
<del> random.seed(args.seed)
<del> np.random.seed(args.seed)
<del> torch.manual_seed(args.seed)
<del> if args.n_gpu > 0:
<del> torch.cuda.manual_seed_all(args.seed)
<del>
<del>
<del>def train(args, train_dataset, model, tokenizer):
<del> raise NotImplementedError
<del>
<del>
<del>def evaluate(args, model, tokenizer, prefix=""):
<del> raise NotImplementedError | 2 |
Ruby | Ruby | allow --get for non-interactive builds | 34e51fb16b219cdf04bec342980abdd8d10ed7f5 | <ide><path>Library/Homebrew/build.rb
<ide> def install f
<ide> end
<ide>
<ide> f.brew do
<add> if ARGV.flag? '--git'
<add> system "git init"
<add> system "git add -A"
<add> end
<ide> if ARGV.flag? '--interactive'
<ide> ohai "Entering interactive mode"
<ide> puts "Type `exit' to return and finalize the installation"
<ide> puts "Install to this prefix: #{f.prefix}"
<ide>
<ide> if ARGV.flag? '--git'
<del> system "git init"
<del> system "git add -A"
<ide> puts "This directory is now a git repo. Make your changes and then use:"
<ide> puts " git diff | pbcopy"
<ide> puts "to copy the diff to the clipboard." | 1 |
Python | Python | fix compatibility.json link | 8af4b9e4dfd6e8e273be5613c7dde017ae2a3354 | <ide><path>spacy/about.py
<ide>
<ide> __docs__ = 'https://spacy.io/docs/usage'
<ide> __download_url__ = 'https://github.com/explosion/spacy-models/releases/download'
<del>__compatibility__ = 'https://raw.githubusercontent.com/explosion/spacy-models/master/compatibility.json?token=ANAt54fi5zcUtnwGhMLw2klWwcAyHkZGks5Y0nw1wA%3D%3D'
<add>__compatibility__ = 'https://raw.githubusercontent.com/explosion/spacy-models/master/compatibility.json'
<ide> __shortcuts__ = {'en': 'en_core_web_sm', 'de': 'de_core_web_md', 'vectors': 'en_vectors_glove_md'} | 1 |
PHP | PHP | add hasheaders() method to http client request | f57d1a301543788c8c6e5ebe160ddaf5d60d25ea | <ide><path>src/Illuminate/Http/Client/Request.php
<ide> public function hasHeader($key, $value = null)
<ide> return empty(array_diff($value, $headers[$key]));
<ide> }
<ide>
<add> /**
<add> * Determine if the request has the given headers.
<add> *
<add> * @param array|string $headers
<add> * @return bool
<add> */
<add> public function hasHeaders($headers)
<add> {
<add> if (is_string($headers)) {
<add> $headers = [$headers => null];
<add> }
<add>
<add> foreach ($headers as $key => $value) {
<add> if (! $this -> hasHeader($key, $value)) {
<add> return false;
<add> }
<add> }
<add>
<add> return true;
<add> }
<add>
<ide> /**
<ide> * Get the values for the header with the given name.
<ide> *
<ide><path>tests/Http/HttpClientTest.php
<ide> public function testGetWithArrayQueryParamEncodes()
<ide> && $request['foo;bar; space test'] === 'laravel';
<ide> });
<ide> }
<add>
<add> public function testCanConfirmManyHeaders()
<add> {
<add> $this->factory->fake();
<add>
<add> $this->factory->withHeaders([
<add> 'X-Test-Header' => 'foo',
<add> 'X-Test-ArrayHeader' => ['bar', 'baz'],
<add> ])->post('http://foo.com/json');
<add>
<add> $this->factory->assertSent(function (Request $request) {
<add> return $request->url() === 'http://foo.com/json' &&
<add> $request->hasHeaders([
<add> 'X-Test-Header' => 'foo',
<add> 'X-Test-ArrayHeader' => ['bar', 'baz'],
<add> ]);
<add> });
<add> }
<add>
<add> public function testCanConfirmManyHeadersUsingAString()
<add> {
<add> $this->factory->fake();
<add>
<add> $this->factory->withHeaders([
<add> 'X-Test-Header' => 'foo',
<add> 'X-Test-ArrayHeader' => ['bar', 'baz'],
<add> ])->post('http://foo.com/json');
<add>
<add> $this->factory->assertSent(function (Request $request) {
<add> return $request->url() === 'http://foo.com/json' &&
<add> $request->hasHeaders('X-Test-Header');
<add> });
<add> }
<ide> } | 2 |
Javascript | Javascript | add vm benchmark test | 5d703ec874a6b9ef6ba4fc9a49b63b17b046aee4 | <ide><path>test/parallel/test-benchmark-vm.js
<add>'use strict';
<add>
<add>require('../common');
<add>
<add>const runBenchmark = require('../common/benchmark');
<add>
<add>runBenchmark('vm',
<add> [
<add> 'breakOnSigint=0',
<add> 'withSigintListener=0',
<add> 'n=1'
<add> ],
<add> { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 }); | 1 |
Python | Python | use np.atleast_nd() to boost dimensions to ndmin | b233716a031cb523f9bc65dda2c22f69f6f0736a | <ide><path>numpy/lib/npyio.py
<ide> def loadtxt(fname, dtype=float, comments='#', delimiter=None,
<ide> data-type, arrays are returned for each field. Default is False.
<ide> ndmin : int, optional
<ide> The returned array will have at least `ndmin` dimensions.
<del> Otherwise single-dimensional axes will be squeezed.
<add> Otherwise mono-dimensional axes will be squeezed.
<ide> Legal values: 0 (default), 1 or 2.
<ide> .. versionadded:: 1.6.0
<ide>
<ide> def split_line(line):
<ide> fh.close()
<ide>
<ide> X = np.array(X, dtype)
<add> # Multicolumn data are returned with shape (1, N, M), i.e.
<add> # (1, 1, M) for a single row - remove the singleton dimension there
<ide> if X.ndim == 3 and X.shape[:2] == (1, 1):
<ide> X.shape = (1, -1)
<ide>
<ide> # Verify that the array has at least dimensions `ndmin`.
<ide> # Check correctness of the values of `ndmin`
<ide> if not ndmin in [0, 1, 2]:
<ide> raise ValueError('Illegal value of ndmin keyword: %s' % ndmin)
<del> # Tweak the size and shape of the arrays
<add> # Tweak the size and shape of the arrays - remove extraneous dimensions
<ide> if X.ndim > ndmin:
<ide> X = np.squeeze(X)
<del> # Has to be in this order for the odd case ndmin=1, X.squeeze().ndim=0
<add> # and ensure we have the minimum number of dimensions asked for
<add> # - has to be in this order for the odd case ndmin=1, X.squeeze().ndim=0
<ide> if X.ndim < ndmin:
<ide> if ndmin == 1:
<del> X.shape = (X.size, )
<add> X = np.atleast_1d(X)
<ide> elif ndmin == 2:
<del> X.shape = (X.size, 1)
<add> X = np.atleast_2d(X).T
<ide>
<ide> if unpack:
<ide> if len(dtype_types) > 1:
<ide><path>numpy/lib/tests/test_io.py
<ide> def test_ndmin_keyword(self):
<ide> c = StringIO()
<ide> c.write(asbytes('1,2,3\n4,5,6'))
<ide> c.seek(0)
<add> assert_raises(ValueError, np.loadtxt, c, ndmin=3)
<add> c.seek(0)
<add> assert_raises(ValueError, np.loadtxt, c, ndmin=1.5)
<add> c.seek(0)
<ide> x = np.loadtxt(c, dtype=int, delimiter=',', ndmin=1)
<ide> a = np.array([[1, 2, 3], [4, 5, 6]])
<ide> assert_array_equal(x, a)
<ide> def test_ndmin_keyword(self):
<ide> d.seek(0)
<ide> x = np.loadtxt(d, dtype=int, delimiter=',', ndmin=2)
<ide> assert_(x.shape == (1, 3))
<del> assert_raises(ValueError, np.loadtxt, d, ndmin=3)
<del> assert_raises(ValueError, np.loadtxt, d, ndmin=1.5)
<add> d.seek(0)
<add> x = np.loadtxt(d, dtype=int, delimiter=',', ndmin=1)
<add> assert_(x.shape == (3,))
<add> d.seek(0)
<add> x = np.loadtxt(d, dtype=int, delimiter=',', ndmin=0)
<add> assert_(x.shape == (3,))
<ide> e = StringIO()
<ide> e.write(asbytes('0\n1\n2'))
<ide> e.seek(0)
<ide> x = np.loadtxt(e, dtype=int, delimiter=',', ndmin=2)
<ide> assert_(x.shape == (3, 1))
<add> e.seek(0)
<add> x = np.loadtxt(e, dtype=int, delimiter=',', ndmin=1)
<add> assert_(x.shape == (3,))
<add> e.seek(0)
<add> x = np.loadtxt(e, dtype=int, delimiter=',', ndmin=0)
<add> assert_(x.shape == (3,))
<ide> f = StringIO()
<ide> assert_(np.loadtxt(f, ndmin=2).shape == (0, 1,))
<ide> assert_(np.loadtxt(f, ndmin=1).shape == (0,)) | 2 |
Python | Python | use safe_dump. fixes #123 | b1105edfedd6fed932fc97520fd8e0a8cbf05f1f | <ide><path>djangorestframework/renderers.py
<ide> def render(self, obj=None, media_type=None):
<ide> if obj is None:
<ide> return ''
<ide>
<del> return yaml.dump(obj)
<add> return yaml.safe_dump(obj)
<ide> else:
<ide> YAMLRenderer = None
<ide> | 1 |
Javascript | Javascript | extend timeouts in child/exec tests | d77f490a048c26b35ff46b7f75fa18493b687d04 | <ide><path>test/simple/test-child-process-execsync.js
<ide> var execSync = require('child_process').execSync;
<ide> var execFileSync = require('child_process').execFileSync;
<ide>
<ide> var TIMER = 200;
<del>var SLEEP = 1000;
<add>var SLEEP = 2000;
<ide>
<ide> var start = Date.now();
<ide> var err;
<ide><path>test/simple/test-cluster-worker-init.js
<ide> if (cluster.isMaster) {
<ide> var worker = cluster.fork();
<ide> var timer = setTimeout(function() {
<ide> assert(false, 'message not received');
<del> }, 1000);
<add> }, 5000);
<ide>
<ide> timer.unref();
<ide> | 2 |
Javascript | Javascript | add node.d and node.1 to installer | 8bec3febd848c4917c22c68d9de6d737f945b81f | <ide><path>tools/installer.js
<ide> if (cmd === 'install') {
<ide> 'deps/uv/include/uv.h'
<ide> ], 'include/node/');
<ide>
<add> // man page
<add> copy(['doc/node.1'], 'share/man/man1/');
<add>
<add> // dtrace
<add> if (!process.platform.match(/^linux/)) {
<add> copy(['src/node.d'], 'lib/dtrace/');
<add> }
<add>
<ide> // Private uv headers
<ide> copy([
<ide> 'deps/uv/include/uv-private/eio.h', 'deps/uv/include/uv-private/ev.h',
<ide> if (cmd === 'install') {
<ide> } else {
<ide> remove([
<ide> 'bin/node', 'bin/npm', 'bin/node-waf',
<del> 'include/node/*', 'lib/node_modules', 'lib/node'
<add> 'include/node/*', 'lib/node_modules', 'lib/node',
<add> 'lib/dtrace/node.d', 'share/man/man1/node.1'
<ide> ]);
<ide> }
<ide> | 1 |
Javascript | Javascript | remove repeated word | 4d885cbd626caf42922ff5917fbd81afc3cc2086 | <ide><path>src/ng/anchorScroll.js
<ide> function $AnchorScrollProvider() {
<ide> * @name $anchorScrollProvider#disableAutoScrolling
<ide> *
<ide> * @description
<del> * By default, {@link ng.$anchorScroll $anchorScroll()} will automatically will detect changes to
<add> * By default, {@link ng.$anchorScroll $anchorScroll()} will automatically detect changes to
<ide> * {@link ng.$location#hash $location.hash()} and scroll to the element matching the new hash.<br />
<ide> * Use this method to disable automatic scrolling.
<ide> * | 1 |
Go | Go | add todo lines for windows | a34a7930b5c1e9a1e6ddd4a40b1810a86f7d24ab | <ide><path>docker/flags.go
<ide> func getHomeDir() string {
<ide> }
<ide>
<ide> func getDaemonConfDir() string {
<add> // TODO: update for Windows daemon
<ide> if runtime.GOOS == "windows" {
<ide> return filepath.Join(os.Getenv("USERPROFILE"), ".docker")
<ide> }
<ide><path>integration-cli/docker_cli_daemon_test.go
<ide> func TestDaemonVolumesBindsRefs(t *testing.T) {
<ide> }
<ide>
<ide> func TestDaemonKeyGeneration(t *testing.T) {
<add> // TODO: skip or update for Windows daemon
<ide> os.Remove("/etc/docker/key.json")
<ide> d := NewDaemon(t)
<ide> if err := d.Start(); err != nil { | 2 |
Ruby | Ruby | remove date methods that are present in 1.9 ruby | 8f0d7c897319f4faaffba7ffb22d4581d45811a3 | <ide><path>activesupport/lib/active_support/core_ext/date/calculations.rb
<ide> def years_since(years)
<ide> advance(:years => years)
<ide> end
<ide>
<del> # Shorthand for years_ago(1)
<del> def prev_year
<del> years_ago(1)
<del> end unless method_defined?(:prev_year)
<del>
<del> # Shorthand for years_since(1)
<del> def next_year
<del> years_since(1)
<del> end unless method_defined?(:next_year)
<del>
<del> # Shorthand for months_ago(1)
<del> def prev_month
<del> months_ago(1)
<del> end unless method_defined?(:prev_month)
<del>
<del> # Shorthand for months_since(1)
<del> def next_month
<del> months_since(1)
<del> end unless method_defined?(:next_month)
<del>
<ide> # Returns number of days to start of this week. Week is assumed to start on
<ide> # +start_day+, default is +:monday+.
<ide> def days_to_week_start(start_day = :monday) | 1 |
Ruby | Ruby | add a regression test for per-fiber tagged logging | 19d85783614b6d96600aa39aab88791d0c66a78f | <ide><path>activesupport/test/tagged_logging_test.rb
<ide> def flush(*)
<ide> assert_equal "Dull story\n[OMG] Cool story\n[BCX] Funky time\n", @output.string
<ide> end
<ide>
<add> test "keeps each tag in their own thread even when pushed directly" do
<add> Thread.new do
<add> @logger.push_tags("OMG")
<add> @logger.info "Cool story"
<add> end.join
<add> @logger.info "Funky time"
<add> assert_equal "[OMG] Cool story\nFunky time\n", @output.string
<add> end
<add>
<ide> test "keeps each tag in their own instance" do
<ide> other_output = StringIO.new
<ide> other_logger = ActiveSupport::TaggedLogging.new(MyLogger.new(other_output)) | 1 |
Text | Text | fix image name in testing guide | c2c0b8dc4e9bb4d7f51a1254d517d3f20a3e684d | <ide><path>docs/contributing/test.md
<ide> Try this now.
<ide> 2. Start a Moby development image.
<ide>
<ide> If you are following along with this guide, you should have a
<del> `dry-run-test` image.
<add> `docker-dev:dry-run-test` image.
<ide>
<ide> ```bash
<del> $ docker run --privileged --rm -ti -v `pwd`:/go/src/github.com/docker/docker dry-run-test /bin/bash
<add> $ docker run --privileged --rm -ti -v `pwd`:/go/src/github.com/docker/docker docker-dev:dry-run-test /bin/bash
<ide> ```
<ide>
<ide> 3. Run the unit tests using the `hack/test/unit` script. | 1 |
Java | Java | fix nullpointerexception in jackson2smiledecoder | 5f3c7ca559ac5f7d4d37917d568001579b596f2b | <ide><path>spring-web/src/main/java/org/springframework/http/codec/json/Jackson2Tokenizer.java
<ide> private Flux<TokenBuffer> endOfInput() {
<ide> private List<TokenBuffer> parseTokenBufferFlux() throws IOException {
<ide> List<TokenBuffer> result = new ArrayList<>();
<ide>
<del> while (true) {
<add> // SPR-16151: Smile data format uses null to separate documents
<add> boolean previousNull = false;
<add> while (!this.parser.isClosed()) {
<ide> JsonToken token = this.parser.nextToken();
<del> // SPR-16151: Smile data format uses null to separate documents
<ide> if (token == JsonToken.NOT_AVAILABLE ||
<del> (token == null && (token = this.parser.nextToken()) == null)) {
<add> token == null && previousNull) {
<ide> break;
<ide> }
<add> else if (token == null ) { // !previousNull
<add> previousNull = true;
<add> continue;
<add> }
<ide> updateDepth(token);
<ide> if (!this.tokenizeArrayElements) {
<ide> processTokenNormal(token, result);
<ide> private void processTokenNormal(JsonToken token, List<TokenBuffer> result) throw
<ide>
<ide> private void processTokenArray(JsonToken token, List<TokenBuffer> result) throws IOException {
<ide> if (!isTopLevelArrayToken(token)) {
<add> if (!this.parser.hasCurrentToken()) {
<add> System.out.println("NO CURRENT TOKEN: " + token);
<add> }
<ide> this.tokenBuffer.copyCurrentEvent(this.parser);
<ide> }
<ide> | 1 |
Javascript | Javascript | use jquery.merge only if it really necessary | d086aa16b3aa862185684b69dc3e27ee5dbc32fc | <ide><path>src/manipulation.js
<ide> jQuery.fn.extend({
<ide>
<ide> // Keep references to cloned scripts for later restoration
<ide> if ( hasScripts ) {
<del> jQuery.merge( scripts, getAll( node, "script" ) );
<add> core_push.apply( scripts, getAll( node, "script" ) );
<ide> }
<ide> }
<ide>
<ide> jQuery.extend({
<ide> if ( elem || elem === 0 ) {
<ide> // Add nodes directly
<ide> if ( jQuery.type( elem ) === "object" ) {
<del> jQuery.merge( ret, elem.nodeType ? [ elem ] : elem );
<add> core_push.apply( ret, elem.nodeType ? [ elem ] : elem );
<ide>
<ide> // Convert non-html into a text node
<ide> } else if ( !rhtml.test( elem ) ) {
<ide> jQuery.extend({
<ide> tmp = tmp.lastChild;
<ide> }
<ide>
<del> jQuery.merge( ret, tmp.childNodes );
<add> core_push.apply( ret, tmp.childNodes );
<ide>
<ide> // Fix #12392 for WebKit and IE > 9
<ide> tmp.textContent = ""; | 1 |
Javascript | Javascript | remove gatsby proxy | 4896e45eea8c2b186dc56228f2a202778b3a78ff | <ide><path>client/gatsby-config.js
<ide> const {
<ide> localeChallengesRootDir
<ide> } = require('./utils/buildChallenges');
<ide>
<del>const { API_PROXY: proxyUrl = 'http://localhost:3000' } = process.env;
<del>
<ide> const curriculumIntroRoot = path.resolve(__dirname, './src/pages');
<ide>
<ide> module.exports = {
<ide> siteMetadata: {
<ide> title: 'freeCodeCamp',
<ide> siteUrl: 'https://www.freecodecamp.org'
<ide> },
<del> proxy: {
<del> prefix: '/internal',
<del> url: proxyUrl
<del> },
<ide> plugins: [
<ide> 'gatsby-plugin-react-helmet',
<ide> 'gatsby-plugin-postcss',
<ide><path>client/src/components/Donation/components/DonateForm.js
<ide> class DonateForm extends Component {
<ide> }));
<ide>
<ide> const chargeStripePath = isSignedIn
<del> ? '/internal/donate/charge-stripe'
<add> ? `${apiLocation}/internal/donate/charge-stripe`
<ide> : `${apiLocation}/unauthenticated/donate/charge-stripe`;
<ide> return postJSON$(chargeStripePath, {
<ide> token,
<ide><path>client/src/utils/ajax.js
<add>import { apiLocation } from '../../config/env.json';
<add>
<ide> import axios from 'axios';
<ide>
<del>const base = '/internal';
<add>const base = apiLocation + '/internal';
<add>
<ide> axios.defaults.withCredentials = true;
<ide>
<ide> function get(path) { | 3 |
PHP | PHP | add coverage to uncovered method | 70513b4b8364a8f080296cb21c0953cbba2eeecd | <ide><path>tests/TestCase/TestSuite/IntegrationTestCaseTest.php
<ide> use Cake\TestSuite\IntegrationTestCase;
<ide> use Cake\Test\Fixture\AssertIntegrationTestCase;
<ide> use Cake\Utility\Security;
<add>use PHPUnit\Framework\Error\Deprecated;
<ide>
<ide> /**
<ide> * Self test of the IntegrationTestCase
<ide> public function setUp()
<ide> Router::$initialized = true;
<ide> }
<ide>
<add> /**
<add> * Check for a deprecation warning
<add> */
<add> public function testUseHttpServerWarning()
<add> {
<add> $this->expectException(Deprecated::class);
<add> $this->useHttpServer(false);
<add> }
<add>
<ide> /**
<ide> * Test building a request.
<ide> * | 1 |
Python | Python | remove debugging registrations | 35e9d29162038cc7df155e64aab4564d0841bb32 | <ide><path>official/vision/beta/configs/backbones.py
<ide> class RevNet(hyperparams.Config):
<ide> # Specifies the depth of RevNet.
<ide> model_id: int = 56
<ide>
<del>from official.vision.beta.projects.yolo.configs.backbones import DarkNet
<ide>
<ide> @dataclasses.dataclass
<ide> class Backbone(hyperparams.OneOfConfig):
<ide> class Backbone(hyperparams.OneOfConfig):
<ide> efficientnet: EfficientNet = EfficientNet()
<ide> spinenet: SpineNet = SpineNet()
<ide> mobilenet: MobileNet = MobileNet()
<del> darknet: DarkNet = DarkNet()
<ide><path>official/vision/beta/dataloaders/classification_input.py
<ide> def __init__(self,
<ide> aug_rand_hflip=True,
<ide> dtype='float32'):
<ide> """Initializes parameters for parsing annotations in the dataset.
<add>
<ide> Args:
<ide> output_size: `Tenssor` or `list` for [height, width] of output image. The
<ide> output_size should be divided by the largest feature stride 2^max_level. | 2 |
PHP | PHP | remove duplicated call | f39e296e37799c22852f92bb13b1d35f8d27a53b | <ide><path>src/View/Widget/FileWidget.php
<ide> public function render(array $data, ContextInterface $context): string
<ide>
<ide> unset($data['val']);
<ide>
<del> if (isset($data['fieldName'])) {
<del> $data = $this->setRequired($data, $context, $data['fieldName']);
<del> }
<del>
<ide> return $this->_templates->format('file', [
<ide> 'name' => $data['name'],
<ide> 'templateVars' => $data['templateVars'], | 1 |
PHP | PHP | move merge() into set2 | e736ea3af98bb4b6f0f33f6b30567f1d3af48d0f | <ide><path>lib/Cake/Test/Case/Utility/Set2Test.php
<ide> public function testFlatten() {
<ide> $this->assertEquals($expected, $result);
<ide> }
<ide>
<add>/**
<add> * Test diff();
<add> *
<add> * @return void
<add> */
<add> public function testDiff() {
<add> $a = array(
<add> 0 => array('name' => 'main'),
<add> 1 => array('name' => 'about')
<add> );
<add> $b = array(
<add> 0 => array('name' => 'main'),
<add> 1 => array('name' => 'about'),
<add> 2 => array('name' => 'contact')
<add> );
<add>
<add> $result = Set2::diff($a, array());
<add> $expected = $a;
<add> $this->assertEquals($expected, $result);
<add>
<add> $result = Set2::diff(array(), $b);
<add> $expected = $b;
<add> $this->assertEquals($expected, $result);
<add>
<add> $result = Set2::diff($a, $b);
<add> $expected = array(
<add> 2 => array('name' => 'contact')
<add> );
<add> $this->assertEquals($expected, $result);
<add>
<add>
<add> $b = array(
<add> 0 => array('name' => 'me'),
<add> 1 => array('name' => 'about')
<add> );
<add>
<add> $result = Set2::diff($a, $b);
<add> $expected = array(
<add> 0 => array('name' => 'main')
<add> );
<add> $this->assertEquals($expected, $result);
<add>
<add> $a = array();
<add> $b = array('name' => 'bob', 'address' => 'home');
<add> $result = Set2::diff($a, $b);
<add> $this->assertEquals($result, $b);
<add>
<add>
<add> $a = array('name' => 'bob', 'address' => 'home');
<add> $b = array();
<add> $result = Set2::diff($a, $b);
<add> $this->assertEquals($result, $a);
<add>
<add> $a = array('key' => true, 'another' => false, 'name' => 'me');
<add> $b = array('key' => 1, 'another' => 0);
<add> $expected = array('name' => 'me');
<add> $result = Set2::diff($a, $b);
<add> $this->assertEquals($expected, $result);
<add>
<add> $a = array('key' => 'value', 'another' => null, 'name' => 'me');
<add> $b = array('key' => 'differentValue', 'another' => null);
<add> $expected = array('key' => 'value', 'name' => 'me');
<add> $result = Set2::diff($a, $b);
<add> $this->assertEquals($expected, $result);
<add>
<add> $a = array('key' => 'value', 'another' => null, 'name' => 'me');
<add> $b = array('key' => 'differentValue', 'another' => 'value');
<add> $expected = array('key' => 'value', 'another' => null, 'name' => 'me');
<add> $result = Set2::diff($a, $b);
<add> $this->assertEquals($expected, $result);
<add>
<add> $a = array('key' => 'value', 'another' => null, 'name' => 'me');
<add> $b = array('key' => 'differentValue', 'another' => 'value');
<add> $expected = array('key' => 'differentValue', 'another' => 'value', 'name' => 'me');
<add> $result = Set2::diff($b, $a);
<add> $this->assertEquals($expected, $result);
<add>
<add> $a = array('key' => 'value', 'another' => null, 'name' => 'me');
<add> $b = array(0 => 'differentValue', 1 => 'value');
<add> $expected = $a + $b;
<add> $result = Set2::diff($a, $b);
<add> $this->assertEquals($expected, $result);
<add> }
<add>
<add>/**
<add> * Test merge()
<add> *
<add> * @return void
<add> */
<add> public function testMerge() {
<add> $result = Set2::merge(array('foo'), array('bar'));
<add> $this->assertEquals($result, array('foo', 'bar'));
<add>
<add> $result = Set2::merge(array('foo'), array('user' => 'bob', 'no-bar'), 'bar');
<add> $this->assertEquals($result, array('foo', 'user' => 'bob', 'no-bar', 'bar'));
<add>
<add> $a = array('foo', 'foo2');
<add> $b = array('bar', 'bar2');
<add> $expected = array('foo', 'foo2', 'bar', 'bar2');
<add> $this->assertEquals($expected, Set2::merge($a, $b));
<add>
<add> $a = array('foo' => 'bar', 'bar' => 'foo');
<add> $b = array('foo' => 'no-bar', 'bar' => 'no-foo');
<add> $expected = array('foo' => 'no-bar', 'bar' => 'no-foo');
<add> $this->assertEquals($expected, Set2::merge($a, $b));
<add>
<add> $a = array('users' => array('bob', 'jim'));
<add> $b = array('users' => array('lisa', 'tina'));
<add> $expected = array('users' => array('bob', 'jim', 'lisa', 'tina'));
<add> $this->assertEquals($expected, Set2::merge($a, $b));
<add>
<add> $a = array('users' => array('jim', 'bob'));
<add> $b = array('users' => 'none');
<add> $expected = array('users' => 'none');
<add> $this->assertEquals($expected, Set2::merge($a, $b));
<add>
<add> $a = array('users' => array('lisa' => array('id' => 5, 'pw' => 'secret')), 'cakephp');
<add> $b = array('users' => array('lisa' => array('pw' => 'new-pass', 'age' => 23)), 'ice-cream');
<add> $expected = array(
<add> 'users' => array('lisa' => array('id' => 5, 'pw' => 'new-pass', 'age' => 23)),
<add> 'cakephp',
<add> 'ice-cream'
<add> );
<add> $result = Set2::merge($a, $b);
<add> $this->assertEquals($expected, $result);
<add>
<add> $c = array(
<add> 'users' => array('lisa' => array('pw' => 'you-will-never-guess', 'age' => 25, 'pet' => 'dog')),
<add> 'chocolate'
<add> );
<add> $expected = array(
<add> 'users' => array('lisa' => array('id' => 5, 'pw' => 'you-will-never-guess', 'age' => 25, 'pet' => 'dog')),
<add> 'cakephp',
<add> 'ice-cream',
<add> 'chocolate'
<add> );
<add> $this->assertEquals($expected, Set2::merge($a, $b, $c));
<add>
<add> $this->assertEquals($expected, Set2::merge($a, $b, array(), $c));
<add>
<add> $a = array(
<add> 'Tree',
<add> 'CounterCache',
<add> 'Upload' => array(
<add> 'folder' => 'products',
<add> 'fields' => array('image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id')
<add> )
<add> );
<add> $b = array(
<add> 'Cacheable' => array('enabled' => false),
<add> 'Limit',
<add> 'Bindable',
<add> 'Validator',
<add> 'Transactional'
<add> );
<add> $expected = array(
<add> 'Tree',
<add> 'CounterCache',
<add> 'Upload' => array(
<add> 'folder' => 'products',
<add> 'fields' => array('image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id')
<add> ),
<add> 'Cacheable' => array('enabled' => false),
<add> 'Limit',
<add> 'Bindable',
<add> 'Validator',
<add> 'Transactional'
<add> );
<add> $this->assertEquals(Set2::merge($a, $b), $expected);
<add> }
<add>
<ide> }
<ide><path>lib/Cake/Utility/Set2.php
<ide> public static function filter(array $data) {
<ide> /**
<ide> * Collapses a multi-dimensional array into a single dimension, using a delimited array path for
<ide> * each array element's key, i.e. array(array('Foo' => array('Bar' => 'Far'))) becomes
<del> * array('0.Foo.Bar' => 'Far').
<add> * array('0.Foo.Bar' => 'Far').)
<ide> *
<ide> * @param array $data Array to flatten
<ide> * @param string $separator String used to separate array key elements in a path, defaults to '.'
<ide> public static function flatten(array $data, $separator = '.') {
<ide> return $result;
<ide> }
<ide>
<add>/**
<add> * This function can be thought of as a hybrid between PHP's `array_merge` and `array_merge_recursive`.
<add> *
<add> * The difference between this method and the built-in ones, is that if an array key contains another array, then
<add> * Set2::merge() will behave in a recursive fashion (unlike `array_merge`). But it will not act recursively for
<add> * keys that contain scalar values (unlike `array_merge_recursive`).
<add> *
<add> * Note: This function will work with an unlimited amount of arguments and typecasts non-array parameters into arrays.
<add> *
<add> * @param array $data Array to be merged
<add> * @param mixed $merge Array to merge with. The argument and all trailing arguments will be array cast when merged
<add> * @return array Merged array
<add> * @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::merge
<add> */
<ide> public static function merge(array $data, $merge) {
<del>
<add> $args = func_get_args();
<add> $return = current($args);
<add>
<add> while (($arg = next($args)) !== false) {
<add> foreach ((array)$arg as $key => $val) {
<add> if (!empty($return[$key]) && is_array($return[$key]) && is_array($val)) {
<add> $return[$key] = self::merge($return[$key], $val);
<add> } elseif (is_int($key)) {
<add> $return[] = $val;
<add> } else {
<add> $return[$key] = $val;
<add> }
<add> }
<add> }
<add> return $return;
<ide> }
<ide>
<ide> /**
<ide> public static function sort(array $data, $path, $dir) {
<ide>
<ide> }
<ide>
<add>/**
<add> * Computes the difference between two complex arrays.
<add> * This method differs from the built-in array_diff() in that it will preserve keys
<add> * and work on multi-dimensional arrays.
<add> *
<add> * @param mixed $data First value
<add> * @param mixed $data2 Second value
<add> * @return array Returns the key => value pairs that are not common in $data and $data2
<add> * The expression for this function is ($data - $data2) + ($data2 - ($data - $data2))
<add> * @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::diff
<add> */
<ide> public static function diff(array $data, $data2) {
<del>
<add> if (empty($data)) {
<add> return (array)$data2;
<add> }
<add> if (empty($data2)) {
<add> return (array)$data;
<add> }
<add> $intersection = array_intersect_key($data, $data2);
<add> while (($key = key($intersection)) !== null) {
<add> if ($data[$key] == $data2[$key]) {
<add> unset($data[$key]);
<add> unset($data2[$key]);
<add> }
<add> next($intersection);
<add> }
<add> return $data + $data2;
<ide> }
<ide>
<ide> public static function normalize(array $data, $assoc = true) { | 2 |
Javascript | Javascript | add test for options validation of createserver | 52e1bbde01e1f35b13a9a14a2d428fd318c7ef4a | <ide><path>test/parallel/test-http2-createsecureserver-nooptions.js
<del>'use strict';
<del>
<del>const common = require('../common');
<del>if (!common.hasCrypto)
<del> common.skip('missing crypto');
<del>
<del>const assert = require('assert');
<del>const http2 = require('http2');
<del>
<del>// Error if options are not passed to createSecureServer
<del>const invalidOptions = [() => {}, 1, 'test', null];
<del>invalidOptions.forEach((invalidOption) => {
<del> assert.throws(
<del> () => http2.createSecureServer(invalidOption),
<del> {
<del> name: 'TypeError',
<del> code: 'ERR_INVALID_ARG_TYPE',
<del> message: 'The "options" argument must be of type Object. Received ' +
<del> `type ${typeof invalidOption}`
<del> }
<del> );
<del>});
<ide><path>test/parallel/test-http2-createsecureserver-options.js
<add>'use strict';
<add>
<add>const common = require('../common');
<add>if (!common.hasCrypto)
<add> common.skip('missing crypto');
<add>
<add>const assert = require('assert');
<add>const http2 = require('http2');
<add>
<add>// Error if invalid options are passed to createSecureServer
<add>const invalidOptions = [() => {}, 1, 'test', null, Symbol('test')];
<add>invalidOptions.forEach((invalidOption) => {
<add> assert.throws(
<add> () => http2.createSecureServer(invalidOption),
<add> {
<add> name: 'TypeError',
<add> code: 'ERR_INVALID_ARG_TYPE',
<add> message: 'The "options" argument must be of type Object. Received ' +
<add> `type ${typeof invalidOption}`
<add> }
<add> );
<add>});
<add>
<add>// Error if invalid options.settings are passed to createSecureServer
<add>invalidOptions.forEach((invalidSettingsOption) => {
<add> assert.throws(
<add> () => http2.createSecureServer({ settings: invalidSettingsOption }),
<add> {
<add> name: 'TypeError',
<add> code: 'ERR_INVALID_ARG_TYPE',
<add> message: 'The "options.settings" property must be of type Object. ' +
<add> `Received type ${typeof invalidSettingsOption}`
<add> }
<add> );
<add>});
<ide><path>test/parallel/test-http2-createserver-options.js
<add>'use strict';
<add>
<add>const common = require('../common');
<add>if (!common.hasCrypto)
<add> common.skip('missing crypto');
<add>
<add>const assert = require('assert');
<add>const http2 = require('http2');
<add>
<add>// Error if invalid options are passed to createServer
<add>const invalidOptions = [1, true, 'test', null, Symbol('test')];
<add>invalidOptions.forEach((invalidOption) => {
<add> assert.throws(
<add> () => http2.createServer(invalidOption),
<add> {
<add> name: 'TypeError',
<add> code: 'ERR_INVALID_ARG_TYPE',
<add> message: 'The "options" argument must be of type Object. Received ' +
<add> `type ${typeof invalidOption}`
<add> }
<add> );
<add>});
<add>
<add>// Error if invalid options.settings are passed to createServer
<add>invalidOptions.forEach((invalidSettingsOption) => {
<add> assert.throws(
<add> () => http2.createServer({ settings: invalidSettingsOption }),
<add> {
<add> name: 'TypeError',
<add> code: 'ERR_INVALID_ARG_TYPE',
<add> message: 'The "options.settings" property must be of type Object. ' +
<add> `Received type ${typeof invalidSettingsOption}`
<add> }
<add> );
<add>}); | 3 |
Python | Python | remove test code | 7e1a7afec2e29f7fac45708ec80fa654dfc2c193 | <ide><path>libcloud/test/storage/test_minio.py
<ide> def setUp(self):
<ide> self.driver = self.create_driver()
<ide>
<ide> def test_connection_class_type(self):
<del> return
<ide> self.assertEqual(self.driver.connectionCls, MinIOConnectionAWS4)
<ide>
<ide> def test_connection_class_default_host(self):
<del> return
<ide> self.assertEqual(self.driver.connectionCls.host, self.default_host)
<ide> self.assertEqual(self.driver.connectionCls.port, 443)
<ide> | 1 |
Python | Python | fix 2.5 >= try/except/finally | d857eaf35b6a51b7208c90eb20c963ffe9c7cdf2 | <ide><path>numpy/testing/tests/test_utils.py
<ide> def f():
<ide> failed = False
<ide> filters = sys.modules['warnings'].filters[:]
<ide> try:
<del> # Should raise an AssertionError
<del> assert_warns(UserWarning, f)
<del> failed = True
<del> except AssertionError:
<del> pass
<add> try:
<add> # Should raise an AssertionError
<add> assert_warns(UserWarning, f)
<add> failed = True
<add> except AssertionError:
<add> pass
<ide> finally:
<ide> sys.modules['warnings'].filters = filters
<ide> | 1 |
Java | Java | add assembly tracking, minor fixes and cleanup | 35c8da6ca2f0c446d9e50d1c5507cc80e5ccb996 | <ide><path>src/main/java/io/reactivex/Completable.java
<ide> public abstract class Completable implements CompletableSource {
<ide> * @throws NullPointerException if sources is null
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<del> public static Completable amb(final CompletableSource... sources) {
<add> public static Completable ambArray(final CompletableSource... sources) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<ide> if (sources.length == 0) {
<ide> return complete();
<ide> public static Completable amb(final CompletableSource... sources) {
<ide> return wrap(sources[0]);
<ide> }
<ide>
<del> return new CompletableAmbArray(sources);
<add> return RxJavaPlugins.onAssembly(new CompletableAmbArray(sources));
<ide> }
<ide>
<ide> /**
<ide> public static Completable amb(final CompletableSource... sources) {
<ide> public static Completable amb(final Iterable<? extends CompletableSource> sources) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<ide>
<del> return new CompletableAmbIterable(sources);
<add> return RxJavaPlugins.onAssembly(new CompletableAmbIterable(sources));
<ide> }
<ide>
<ide> /**
<ide> public static Completable amb(final Iterable<? extends CompletableSource> source
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static Completable complete() {
<del> return CompletableEmpty.INSTANCE;
<add> return RxJavaPlugins.onAssembly(CompletableEmpty.INSTANCE);
<ide> }
<ide>
<ide> /**
<ide> public static Completable complete() {
<ide> * @throws NullPointerException if sources is null
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<del> public static Completable concat(CompletableSource... sources) {
<add> public static Completable concatArray(CompletableSource... sources) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<ide> if (sources.length == 0) {
<ide> return complete();
<ide> } else
<ide> if (sources.length == 1) {
<ide> return wrap(sources[0]);
<ide> }
<del> return new CompletableConcatArray(sources);
<add> return RxJavaPlugins.onAssembly(new CompletableConcatArray(sources));
<ide> }
<ide>
<ide> /**
<ide> public static Completable concat(CompletableSource... sources) {
<ide> public static Completable concat(Iterable<? extends CompletableSource> sources) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<ide>
<del> return new CompletableConcatIterable(sources);
<add> return RxJavaPlugins.onAssembly(new CompletableConcatIterable(sources));
<ide> }
<ide>
<ide> /**
<ide> public static Completable concat(Publisher<? extends CompletableSource> sources,
<ide> if (prefetch < 1) {
<ide> throw new IllegalArgumentException("prefetch > 0 required but it was " + prefetch);
<ide> }
<del> return new CompletableConcat(sources, prefetch);
<add> return RxJavaPlugins.onAssembly(new CompletableConcat(sources, prefetch));
<ide> }
<ide>
<ide> /**
<ide> public static Completable unsafeCreate(CompletableSource source) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static Completable defer(final Callable<? extends CompletableSource> completableSupplier) {
<ide> ObjectHelper.requireNonNull(completableSupplier, "completableSupplier");
<del> return new CompletableDefer(completableSupplier);
<add> return RxJavaPlugins.onAssembly(new CompletableDefer(completableSupplier));
<ide> }
<ide>
<ide> /**
<ide> public static Completable defer(final Callable<? extends CompletableSource> comp
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static Completable error(final Callable<? extends Throwable> errorSupplier) {
<ide> ObjectHelper.requireNonNull(errorSupplier, "errorSupplier is null");
<del> return new CompletableErrorSupplier(errorSupplier);
<add> return RxJavaPlugins.onAssembly(new CompletableErrorSupplier(errorSupplier));
<ide> }
<ide>
<ide> /**
<ide> public static Completable error(final Callable<? extends Throwable> errorSupplie
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static Completable error(final Throwable error) {
<ide> ObjectHelper.requireNonNull(error, "error is null");
<del> return new CompletableError(error);
<add> return RxJavaPlugins.onAssembly(new CompletableError(error));
<ide> }
<ide>
<ide>
<ide> public static Completable error(final Throwable error) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static Completable fromAction(final Action run) {
<ide> ObjectHelper.requireNonNull(run, "run is null");
<del> return new CompletableFromAction(run);
<add> return RxJavaPlugins.onAssembly(new CompletableFromAction(run));
<ide> }
<ide>
<ide> /**
<ide> public static Completable fromAction(final Action run) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static Completable fromCallable(final Callable<?> callable) {
<ide> ObjectHelper.requireNonNull(callable, "callable is null");
<del> return new CompletableFromCallable(callable);
<add> return RxJavaPlugins.onAssembly(new CompletableFromCallable(callable));
<ide> }
<ide>
<ide> /**
<ide> public static Completable fromFuture(final Future<?> future) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Completable fromObservable(final ObservableSource<T> observable) {
<ide> ObjectHelper.requireNonNull(observable, "observable is null");
<del> return new CompletableFromObservable<T>(observable);
<add> return RxJavaPlugins.onAssembly(new CompletableFromObservable<T>(observable));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Completable fromObservable(final ObservableSource<T> observabl
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Completable fromPublisher(final Publisher<T> publisher) {
<ide> ObjectHelper.requireNonNull(publisher, "publisher is null");
<del> return new CompletableFromPublisher<T>(publisher);
<add> return RxJavaPlugins.onAssembly(new CompletableFromPublisher<T>(publisher));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Completable fromPublisher(final Publisher<T> publisher) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Completable fromSingle(final SingleSource<T> single) {
<ide> ObjectHelper.requireNonNull(single, "single is null");
<del> return new CompletableFromSingle<T>(single);
<add> return RxJavaPlugins.onAssembly(new CompletableFromSingle<T>(single));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Completable fromSingle(final SingleSource<T> single) {
<ide> * @throws NullPointerException if sources is null
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<del> public static Completable merge(CompletableSource... sources) {
<add> public static Completable mergeArray(CompletableSource... sources) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<ide> if (sources.length == 0) {
<ide> return complete();
<ide> } else
<ide> if (sources.length == 1) {
<ide> return wrap(sources[0]);
<ide> }
<del> return new CompletableMergeArray(sources);
<add> return RxJavaPlugins.onAssembly(new CompletableMergeArray(sources));
<ide> }
<ide>
<ide> /**
<ide> public static Completable merge(CompletableSource... sources) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static Completable merge(Iterable<? extends CompletableSource> sources) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<del> return new CompletableMergeIterable(sources);
<add> return RxJavaPlugins.onAssembly(new CompletableMergeIterable(sources));
<ide> }
<ide>
<ide> /**
<ide> private static Completable merge0(Publisher<? extends CompletableSource> sources
<ide> if (maxConcurrency < 1) {
<ide> throw new IllegalArgumentException("maxConcurrency > 0 required but it was " + maxConcurrency);
<ide> }
<del> return new CompletableMerge(sources, maxConcurrency, delayErrors);
<add> return RxJavaPlugins.onAssembly(new CompletableMerge(sources, maxConcurrency, delayErrors));
<ide> }
<ide>
<ide> /**
<ide> private static Completable merge0(Publisher<? extends CompletableSource> sources
<ide> * @throws NullPointerException if sources is null
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<del> public static Completable mergeDelayError(CompletableSource... sources) {
<add> public static Completable mergeArrayDelayError(CompletableSource... sources) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<del> return new CompletableMergeDelayErrorArray(sources);
<add> return RxJavaPlugins.onAssembly(new CompletableMergeDelayErrorArray(sources));
<ide> }
<ide>
<ide> /**
<ide> public static Completable mergeDelayError(CompletableSource... sources) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static Completable mergeDelayError(Iterable<? extends CompletableSource> sources) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<del> return new CompletableMergeDelayErrorIterable(sources);
<add> return RxJavaPlugins.onAssembly(new CompletableMergeDelayErrorIterable(sources));
<ide> }
<ide>
<ide>
<ide> public static Completable mergeDelayError(Publisher<? extends CompletableSource>
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static Completable never() {
<del> return CompletableNever.INSTANCE;
<add> return RxJavaPlugins.onAssembly(CompletableNever.INSTANCE);
<ide> }
<ide>
<ide> /**
<ide> public static Completable timer(long delay, TimeUnit unit) {
<ide> public static Completable timer(final long delay, final TimeUnit unit, final Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new CompletableTimer(delay, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new CompletableTimer(delay, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public static <R> Completable using(
<ide> ObjectHelper.requireNonNull(completableFunction, "completableFunction is null");
<ide> ObjectHelper.requireNonNull(disposer, "disposer is null");
<ide>
<del> return new CompletableUsing<R>(resourceSupplier, completableFunction, disposer, eager);
<add> return RxJavaPlugins.onAssembly(new CompletableUsing<R>(resourceSupplier, completableFunction, disposer, eager));
<ide> }
<ide>
<ide> /**
<ide> public static <R> Completable using(
<ide> public static Completable wrap(CompletableSource source) {
<ide> ObjectHelper.requireNonNull(source, "source is null");
<ide> if (source instanceof Completable) {
<del> return (Completable)source;
<add> return RxJavaPlugins.onAssembly((Completable)source);
<ide> }
<del> return new CompletableFromUnsafeSource(source);
<add> return RxJavaPlugins.onAssembly(new CompletableFromUnsafeSource(source));
<ide> }
<ide>
<ide> /**
<ide> public static Completable wrap(CompletableSource source) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Completable ambWith(CompletableSource other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return amb(this, other);
<add> return ambArray(this, other);
<ide> }
<ide>
<ide> /**
<ide> public final Completable ambWith(CompletableSource other) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <T> Observable<T> andThen(ObservableSource<T> next) {
<ide> ObjectHelper.requireNonNull(next, "next is null");
<del> return new ObservableDelaySubscriptionOther<T, Object>(next, toObservable());
<add> return RxJavaPlugins.onAssembly(new ObservableDelaySubscriptionOther<T, Object>(next, toObservable()));
<ide> }
<ide>
<ide> /**
<ide> public final <T> Observable<T> andThen(ObservableSource<T> next) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <T> Flowable<T> andThen(Publisher<T> next) {
<ide> ObjectHelper.requireNonNull(next, "next is null");
<del> return new FlowableDelaySubscriptionOther<T, Object>(next, toFlowable());
<add> return RxJavaPlugins.onAssembly(new FlowableDelaySubscriptionOther<T, Object>(next, toFlowable()));
<ide> }
<ide>
<ide> /**
<ide> public final <T> Flowable<T> andThen(Publisher<T> next) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <T> Single<T> andThen(SingleSource<T> next) {
<ide> ObjectHelper.requireNonNull(next, "next is null");
<del> return new SingleDelayWithCompletable<T>(next, this);
<add> return RxJavaPlugins.onAssembly(new SingleDelayWithCompletable<T>(next, this));
<ide> }
<ide>
<ide> /**
<ide> public final Completable compose(CompletableTransformer transformer) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Completable concatWith(CompletableSource other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return concat(this, other);
<add> return concatArray(this, other);
<ide> }
<ide>
<ide> /**
<ide> public final Completable delay(long delay, TimeUnit unit, Scheduler scheduler) {
<ide> public final Completable delay(final long delay, final TimeUnit unit, final Scheduler scheduler, final boolean delayError) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new CompletableDelay(this, delay, unit, scheduler, delayError);
<add> return RxJavaPlugins.onAssembly(new CompletableDelay(this, delay, unit, scheduler, delayError));
<ide> }
<ide>
<ide> /**
<ide> private Completable doOnLifecycle(
<ide> ObjectHelper.requireNonNull(onTerminate, "onTerminate is null");
<ide> ObjectHelper.requireNonNull(onAfterTerminate, "onAfterTerminate is null");
<ide> ObjectHelper.requireNonNull(onDisposed, "onDisposed is null");
<del> return new CompletablePeek(this, onSubscribe, onError, onComplete, onTerminate, onAfterTerminate, onDisposed);
<add> return RxJavaPlugins.onAssembly(new CompletablePeek(this, onSubscribe, onError, onComplete, onTerminate, onAfterTerminate, onDisposed));
<ide> }
<ide>
<ide> /**
<ide> public final Completable doAfterTerminate(final Action onAfterTerminate) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Completable lift(final CompletableOperator onLift) {
<ide> ObjectHelper.requireNonNull(onLift, "onLift is null");
<del> return new CompletableLift(this, onLift);
<add> return RxJavaPlugins.onAssembly(new CompletableLift(this, onLift));
<ide> }
<ide>
<ide> /**
<ide> public final Completable lift(final CompletableOperator onLift) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Completable mergeWith(CompletableSource other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return merge(this, other);
<add> return mergeArray(this, other);
<ide> }
<ide>
<ide> /**
<ide> public final Completable mergeWith(CompletableSource other) {
<ide> @SchedulerSupport(SchedulerSupport.CUSTOM)
<ide> public final Completable observeOn(final Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new CompletableObserveOn(this, scheduler);
<add> return RxJavaPlugins.onAssembly(new CompletableObserveOn(this, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Completable onErrorComplete() {
<ide> public final Completable onErrorComplete(final Predicate<? super Throwable> predicate) {
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<ide>
<del> return new CompletableOnErrorComplete(this, predicate);
<add> return RxJavaPlugins.onAssembly(new CompletableOnErrorComplete(this, predicate));
<ide> }
<ide>
<ide> /**
<ide> public final Completable onErrorComplete(final Predicate<? super Throwable> pred
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Completable onErrorResumeNext(final Function<? super Throwable, ? extends CompletableSource> errorMapper) {
<ide> ObjectHelper.requireNonNull(errorMapper, "errorMapper is null");
<del> return new CompletableResumeNext(this, errorMapper);
<add> return RxJavaPlugins.onAssembly(new CompletableResumeNext(this, errorMapper));
<ide> }
<ide>
<ide> /**
<ide> public final Completable retryWhen(Function<? super Flowable<? extends Throwable
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Completable startWith(CompletableSource other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return concat(other, this);
<add> return concatArray(other, this);
<ide> }
<ide>
<ide> /**
<ide> public final Disposable subscribe(final Action onComplete) {
<ide> public final Completable subscribeOn(final Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide>
<del> return new CompletableSubscribeOn(this, scheduler);
<add> return RxJavaPlugins.onAssembly(new CompletableSubscribeOn(this, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Completable timeout(long timeout, TimeUnit unit, Scheduler schedule
<ide> private Completable timeout0(long timeout, TimeUnit unit, Scheduler scheduler, CompletableSource other) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new CompletableTimeout(this, timeout, unit, scheduler, other);
<add> return RxJavaPlugins.onAssembly(new CompletableTimeout(this, timeout, unit, scheduler, other));
<ide> }
<ide>
<ide> /**
<ide> public final <U> U to(Function<? super Completable, U> converter) {
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <T> Flowable<T> toFlowable() {
<del> return new CompletableToFlowable<T>(this);
<add> return RxJavaPlugins.onAssembly(new CompletableToFlowable<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final <T> Flowable<T> toFlowable() {
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <T> Observable<T> toObservable() {
<del> return new CompletableToObservable<T>(this);
<add> return RxJavaPlugins.onAssembly(new CompletableToObservable<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final <T> Observable<T> toObservable() {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <T> Single<T> toSingle(final Callable<? extends T> completionValueSupplier) {
<ide> ObjectHelper.requireNonNull(completionValueSupplier, "completionValueSupplier is null");
<del> return new CompletableToSingle<T>(this, completionValueSupplier, null);
<add> return RxJavaPlugins.onAssembly(new CompletableToSingle<T>(this, completionValueSupplier, null));
<ide> }
<ide>
<ide> /**
<ide> public final <T> Single<T> toSingle(final Callable<? extends T> completionValueS
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <T> Single<T> toSingleDefault(final T completionValue) {
<ide> ObjectHelper.requireNonNull(completionValue, "completionValue is null");
<del> return new CompletableToSingle<T>(this, null, completionValue);
<add> return RxJavaPlugins.onAssembly(new CompletableToSingle<T>(this, null, completionValue));
<ide> }
<ide>
<ide> /**
<ide> public final <T> Single<T> toSingleDefault(final T completionValue) {
<ide> @SchedulerSupport(SchedulerSupport.CUSTOM)
<ide> public final Completable unsubscribeOn(final Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new CompletableUnsubscribeOn(this, scheduler);
<add> return RxJavaPlugins.onAssembly(new CompletableUnsubscribeOn(this, scheduler));
<ide> }
<ide> // -------------------------------------------------------------------------
<ide> // Fluent test support, super handy and reduces test preparation boilerplate
<ide><path>src/main/java/io/reactivex/Flowable.java
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Flowable<T> amb(Iterable<? extends Publisher<? extends T>> sources) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<del> return new FlowableAmb<T>(null, sources);
<add> return RxJavaPlugins.onAssembly(new FlowableAmb<T>(null, sources));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> amb(Iterable<? extends Publisher<? extends T>> sou
<ide> */
<ide> @BackpressureSupport(BackpressureKind.PASS_THROUGH)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<del> public static <T> Flowable<T> amb(Publisher<? extends T>... sources) {
<add> public static <T> Flowable<T> ambArray(Publisher<? extends T>... sources) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<ide> int len = sources.length;
<ide> if (len == 0) {
<ide> public static <T> Flowable<T> amb(Publisher<? extends T>... sources) {
<ide> if (len == 1) {
<ide> return fromPublisher(sources[0]);
<ide> }
<del> return new FlowableAmb<T>(sources, null);
<add> return RxJavaPlugins.onAssembly(new FlowableAmb<T>(sources, null));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Flowable<R> combineLatest(Publisher<? extends T>[] sources,
<ide> if (sources.length == 0) {
<ide> return empty();
<ide> }
<del> return new FlowableCombineLatest<T, R>(sources, combiner, bufferSize, false);
<add> return RxJavaPlugins.onAssembly(new FlowableCombineLatest<T, R>(sources, combiner, bufferSize, false));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Flowable<R> combineLatest(Iterable<? extends Publisher<? ex
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<ide> ObjectHelper.requireNonNull(combiner, "combiner is null");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new FlowableCombineLatest<T, R>(sources, combiner, bufferSize, false);
<add> return RxJavaPlugins.onAssembly(new FlowableCombineLatest<T, R>(sources, combiner, bufferSize, false));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Flowable<R> combineLatestDelayError(Publisher<? extends T>[
<ide> if (sources.length == 0) {
<ide> return empty();
<ide> }
<del> return new FlowableCombineLatest<T, R>(sources, combiner, bufferSize, true);
<add> return RxJavaPlugins.onAssembly(new FlowableCombineLatest<T, R>(sources, combiner, bufferSize, true));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Flowable<R> combineLatestDelayError(Iterable<? extends Publ
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<ide> ObjectHelper.requireNonNull(combiner, "combiner is null");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new FlowableCombineLatest<T, R>(sources, combiner, bufferSize, true);
<add> return RxJavaPlugins.onAssembly(new FlowableCombineLatest<T, R>(sources, combiner, bufferSize, true));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> concatArray(Publisher<? extends T>... sources) {
<ide> if (sources.length == 1) {
<ide> return fromPublisher(sources[0]);
<ide> }
<del> return new FlowableConcatArray<T>(sources, false);
<add> return RxJavaPlugins.onAssembly(new FlowableConcatArray<T>(sources, false));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> concatArrayDelayError(Publisher<? extends T>... so
<ide> if (sources.length == 1) {
<ide> return fromPublisher(sources[0]);
<ide> }
<del> return new FlowableConcatArray<T>(sources, true);
<add> return RxJavaPlugins.onAssembly(new FlowableConcatArray<T>(sources, true));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> concatArrayEager(Publisher<? extends T>... sources
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> @SuppressWarnings({ "rawtypes", "unchecked" })
<ide> public static <T> Flowable<T> concatArrayEager(int maxConcurrency, int prefetch, Publisher<? extends T>... sources) {
<del> return new FlowableConcatMapEager(new FlowableFromArray(sources), Functions.identity(), maxConcurrency, prefetch, ErrorMode.IMMEDIATE);
<add> return RxJavaPlugins.onAssembly(new FlowableConcatMapEager(new FlowableFromArray(sources), Functions.identity(), maxConcurrency, prefetch, ErrorMode.IMMEDIATE));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> concatEager(Publisher<? extends Publisher<? extend
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> @SuppressWarnings({ "rawtypes", "unchecked" })
<ide> public static <T> Flowable<T> concatEager(Publisher<? extends Publisher<? extends T>> sources, int maxConcurrency, int prefetch) {
<del> return new FlowableConcatMapEager(sources, Functions.identity(), maxConcurrency, prefetch, ErrorMode.IMMEDIATE);
<add> return RxJavaPlugins.onAssembly(new FlowableConcatMapEager(sources, Functions.identity(), maxConcurrency, prefetch, ErrorMode.IMMEDIATE));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> concatEager(Iterable<? extends Publisher<? extends
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> @SuppressWarnings({ "rawtypes", "unchecked" })
<ide> public static <T> Flowable<T> concatEager(Iterable<? extends Publisher<? extends T>> sources, int maxConcurrency, int prefetch) {
<del> return new FlowableConcatMapEager(new FlowableFromIterable(sources), Functions.identity(), maxConcurrency, prefetch, ErrorMode.IMMEDIATE);
<add> return RxJavaPlugins.onAssembly(new FlowableConcatMapEager(new FlowableFromIterable(sources), Functions.identity(), maxConcurrency, prefetch, ErrorMode.IMMEDIATE));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> concatEager(Iterable<? extends Publisher<? extends
<ide> @BackpressureSupport(BackpressureKind.SPECIAL)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Flowable<T> create(FlowableOnSubscribe<T> source, FlowableEmitter.BackpressureMode mode) {
<del> return new FlowableCreate<T>(source, mode);
<add> return RxJavaPlugins.onAssembly(new FlowableCreate<T>(source, mode));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> create(FlowableOnSubscribe<T> source, FlowableEmit
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Flowable<T> defer(Callable<? extends Publisher<? extends T>> supplier) {
<ide> ObjectHelper.requireNonNull(supplier, "supplier is null");
<del> return new FlowableDefer<T>(supplier);
<add> return RxJavaPlugins.onAssembly(new FlowableDefer<T>(supplier));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> defer(Callable<? extends Publisher<? extends T>> s
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> @SuppressWarnings("unchecked")
<ide> public static <T> Flowable<T> empty() {
<del> return (Flowable<T>) FlowableEmpty.INSTANCE;
<add> return RxJavaPlugins.onAssembly((Flowable<T>) FlowableEmpty.INSTANCE);
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> empty() {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Flowable<T> error(Callable<? extends Throwable> errorSupplier) {
<ide> ObjectHelper.requireNonNull(errorSupplier, "errorSupplier is null");
<del> return new FlowableError<T>(errorSupplier);
<add> return RxJavaPlugins.onAssembly(new FlowableError<T>(errorSupplier));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> fromArray(T... values) {
<ide> ObjectHelper.requireNonNull(values, "values is null");
<ide> if (values.length == 0) {
<ide> return empty();
<del> } else
<del> if (values.length == 1) {
<del> return just(values[0]);
<del> }
<del> return new FlowableFromArray<T>(values);
<add> }
<add> if (values.length == 1) {
<add> return just(values[0]);
<add> }
<add> return RxJavaPlugins.onAssembly(new FlowableFromArray<T>(values));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> fromArray(T... values) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Flowable<T> fromCallable(Callable<? extends T> supplier) {
<ide> ObjectHelper.requireNonNull(supplier, "supplier is null");
<del> return new FlowableFromCallable<T>(supplier);
<add> return RxJavaPlugins.onAssembly(new FlowableFromCallable<T>(supplier));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> fromCallable(Callable<? extends T> supplier) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Flowable<T> fromFuture(Future<? extends T> future) {
<ide> ObjectHelper.requireNonNull(future, "future is null");
<del> return new FlowableFromFuture<T>(future, 0L, null);
<add> return RxJavaPlugins.onAssembly(new FlowableFromFuture<T>(future, 0L, null));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> fromFuture(Future<? extends T> future) {
<ide> public static <T> Flowable<T> fromFuture(Future<? extends T> future, long timeout, TimeUnit unit) {
<ide> ObjectHelper.requireNonNull(future, "future is null");
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<del> return new FlowableFromFuture<T>(future, timeout, unit);
<add> return RxJavaPlugins.onAssembly(new FlowableFromFuture<T>(future, timeout, unit));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> fromFuture(Future<? extends T> future, Scheduler s
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Flowable<T> fromIterable(Iterable<? extends T> source) {
<ide> ObjectHelper.requireNonNull(source, "source is null");
<del> return new FlowableFromIterable<T>(source);
<add> return RxJavaPlugins.onAssembly(new FlowableFromIterable<T>(source));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> fromIterable(Iterable<? extends T> source) {
<ide> @SuppressWarnings("unchecked")
<ide> public static <T> Flowable<T> fromPublisher(final Publisher<? extends T> publisher) {
<ide> if (publisher instanceof Flowable) {
<del> return (Flowable<T>)publisher;
<add> return RxJavaPlugins.onAssembly((Flowable<T>)publisher);
<ide> }
<ide> ObjectHelper.requireNonNull(publisher, "publisher is null");
<ide>
<del> return new FlowableFromPublisher<T>(publisher);
<add> return RxJavaPlugins.onAssembly(new FlowableFromPublisher<T>(publisher));
<ide> }
<ide>
<ide> /**
<ide> public static <T, S> Flowable<T> generate(Callable<S> initialState, BiFunction<S
<ide> ObjectHelper.requireNonNull(initialState, "initialState is null");
<ide> ObjectHelper.requireNonNull(generator, "generator is null");
<ide> ObjectHelper.requireNonNull(disposeState, "disposeState is null");
<del> return new FlowableGenerate<T, S>(initialState, generator, disposeState);
<add> return RxJavaPlugins.onAssembly(new FlowableGenerate<T, S>(initialState, generator, disposeState));
<ide> }
<ide>
<ide> /**
<ide> public static Flowable<Long> interval(long initialDelay, long period, TimeUnit u
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide>
<del> return new FlowableInterval(initialDelay, period, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new FlowableInterval(initialDelay, period, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public static Flowable<Long> intervalRange(long start, long count, long initialD
<ide> @BackpressureSupport(BackpressureKind.ERROR)
<ide> @SchedulerSupport(SchedulerSupport.CUSTOM)
<ide> public static Flowable<Long> intervalRange(long start, long count, long initialDelay, long period, TimeUnit unit, Scheduler scheduler) {
<add> ObjectHelper.requireNonNull(unit, "unit is null");
<add> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide> if (count == 0L) {
<del> return Flowable.<Long>empty().delay(initialDelay, unit);
<add> return RxJavaPlugins.onAssembly(Flowable.<Long>empty().delay(initialDelay, unit, scheduler));
<ide> }
<ide>
<ide> long end = start + (count - 1);
<ide> public static Flowable<Long> intervalRange(long start, long count, long initialD
<ide> if (period < 0) {
<ide> period = 0L;
<ide> }
<del> ObjectHelper.requireNonNull(unit, "unit is null");
<del> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide>
<del> return new FlowableIntervalRange(start, end, initialDelay, period, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new FlowableIntervalRange(start, end, initialDelay, period, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public static Flowable<Long> intervalRange(long start, long count, long initialD
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Flowable<T> just(T value) {
<ide> ObjectHelper.requireNonNull(value, "value is null");
<del> return new FlowableJust<T>(value);
<add> return RxJavaPlugins.onAssembly(new FlowableJust<T>(value));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> mergeDelayError(
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> @SuppressWarnings("unchecked")
<ide> public static <T> Flowable<T> never() {
<del> return (Flowable<T>) FlowableNever.INSTANCE;
<add> return RxJavaPlugins.onAssembly((Flowable<T>) FlowableNever.INSTANCE);
<ide> }
<ide>
<ide> /**
<ide> public static Flowable<Integer> range(int start, int count) {
<ide> if ((long)start + (count - 1) > Integer.MAX_VALUE) {
<ide> throw new IllegalArgumentException("Integer overflow");
<ide> }
<del> return new FlowableRange(start, count);
<add> return RxJavaPlugins.onAssembly(new FlowableRange(start, count));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<Boolean> sequenceEqual(Publisher<? extends T> p1, Pub
<ide> ObjectHelper.requireNonNull(p2, "p2 is null");
<ide> ObjectHelper.requireNonNull(isEqual, "isEqual is null");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new FlowableSequenceEqual<T>(p1, p2, isEqual, bufferSize);
<add> return RxJavaPlugins.onAssembly(new FlowableSequenceEqual<T>(p1, p2, isEqual, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public static Flowable<Long> timer(long delay, TimeUnit unit, Scheduler schedule
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide>
<del> return new FlowableTimer(delay, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new FlowableTimer(delay, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public static Flowable<Long> timer(long delay, TimeUnit unit, Scheduler schedule
<ide> * @param <T> the value type emitted
<ide> * @param onSubscribe the Publisher instance to wrap
<ide> * @return the new Flowable instance
<add> * @throws IllegalArgumentException if {@code onSubscribe} is a subclass of {@code Flowable}; such
<add> * instances don't need conversion and is possibly a port remnant from 1.x or one should use {@link #hide()}
<add> * instead.
<ide> */
<ide> @BackpressureSupport(BackpressureKind.NONE)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Flowable<T> unsafeCreate(Publisher<T> onSubscribe) {
<ide> if (onSubscribe instanceof Flowable) {
<ide> throw new IllegalArgumentException("unsafeCreate(Flowable) should be upgraded");
<ide> }
<del> return new FlowableFromPublisher<T>(onSubscribe);
<add> return RxJavaPlugins.onAssembly(new FlowableFromPublisher<T>(onSubscribe));
<ide> }
<ide>
<ide> /**
<ide> public static <T, D> Flowable<T> using(Callable<? extends D> resourceSupplier,
<ide> ObjectHelper.requireNonNull(resourceSupplier, "resourceSupplier is null");
<ide> ObjectHelper.requireNonNull(sourceSupplier, "sourceSupplier is null");
<ide> ObjectHelper.requireNonNull(disposer, "disposer is null");
<del> return new FlowableUsing<T, D>(resourceSupplier, sourceSupplier, disposer, eager);
<add> return RxJavaPlugins.onAssembly(new FlowableUsing<T, D>(resourceSupplier, sourceSupplier, disposer, eager));
<ide> }
<ide>
<ide> /**
<ide> private static void verifyPositive(long value, String paramName) {
<ide> public static <T, R> Flowable<R> zip(Iterable<? extends Publisher<? extends T>> sources, Function<? super Object[], ? extends R> zipper) {
<ide> ObjectHelper.requireNonNull(zipper, "zipper is null");
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<del> return new FlowableZip<T, R>(null, sources, zipper, bufferSize(), false);
<add> return RxJavaPlugins.onAssembly(new FlowableZip<T, R>(null, sources, zipper, bufferSize(), false));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Flowable<R> zipArray(Function<? super Object[], ? extends R
<ide> }
<ide> ObjectHelper.requireNonNull(zipper, "zipper is null");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new FlowableZip<T, R>(sources, null, zipper, bufferSize, delayError);
<add> return RxJavaPlugins.onAssembly(new FlowableZip<T, R>(sources, null, zipper, bufferSize, delayError));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Flowable<R> zipIterable(Iterable<? extends Publisher<? exte
<ide> ObjectHelper.requireNonNull(zipper, "zipper is null");
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new FlowableZip<T, R>(null, sources, zipper, bufferSize, delayError);
<add> return RxJavaPlugins.onAssembly(new FlowableZip<T, R>(null, sources, zipper, bufferSize, delayError));
<ide> }
<ide>
<ide> // ***************************************************************************************************
<ide> public static <T, R> Flowable<R> zipIterable(Iterable<? extends Publisher<? exte
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<Boolean> all(Predicate<? super T> predicate) {
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<del> return new FlowableAll<T>(this, predicate);
<add> return RxJavaPlugins.onAssembly(new FlowableAll<T>(this, predicate));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<Boolean> all(Predicate<? super T> predicate) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> ambWith(Publisher<? extends T> other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return amb(this, other);
<add> return ambArray(this, other);
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> ambWith(Publisher<? extends T> other) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<Boolean> any(Predicate<? super T> predicate) {
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<del> return new FlowableAny<T>(this, predicate);
<add> return RxJavaPlugins.onAssembly(new FlowableAny<T>(this, predicate));
<ide> }
<ide>
<ide> /**
<del> * Returns the first item emitted by this {@code BlockingObservable}, or throws
<add> * Returns the first item emitted by this {@code Flowable}, or throws
<ide> * {@code NoSuchElementException} if it emits no items.
<ide> * <dl>
<ide> * <dt><b>Backpressure:</b></dt>
<ide> public final Flowable<Boolean> any(Predicate<? super T> predicate) {
<ide> * <dd>{@code blockingFirst} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return the first item emitted by this {@code BlockingObservable}
<add> * @return the first item emitted by this {@code Flowable}
<ide> * @throws NoSuchElementException
<del> * if this {@code BlockingObservable} emits no items
<add> * if this {@code Flowable} emits no items
<ide> * @see <a href="http://reactivex.io/documentation/operators/first.html">ReactiveX documentation: First</a>
<ide> */
<ide> public final T blockingFirst() {
<ide> public final T blockingFirst() {
<ide> }
<ide>
<ide> /**
<del> * Returns the first item emitted by this {@code BlockingObservable}, or a default value if it emits no
<add> * Returns the first item emitted by this {@code Flowable}, or a default value if it emits no
<ide> * items.
<ide> * <dl>
<ide> * <dt><b>Backpressure:</b></dt>
<ide> public final T blockingFirst() {
<ide> * </dl>
<ide> *
<ide> * @param defaultValue
<del> * a default value to return if this {@code BlockingObservable} emits no items
<del> * @return the first item emitted by this {@code BlockingObservable}, or the default value if it emits no
<add> * a default value to return if this {@code Flowable} emits no items
<add> * @return the first item emitted by this {@code Flowable}, or the default value if it emits no
<ide> * items
<ide> * @see <a href="http://reactivex.io/documentation/operators/first.html">ReactiveX documentation: First</a>
<ide> */
<ide> public final T blockingFirst(T defaultValue) {
<ide> }
<ide>
<ide> /**
<del> * Invokes a method on each item emitted by this {@code BlockingObservable} and blocks until the Observable
<add> * Invokes a method on each item emitted by this {@code Flowable} and blocks until the Observable
<ide> * completes.
<ide> * <p>
<ide> * <em>Note:</em> This will block even if the underlying Observable is asynchronous.
<ide> public final T blockingFirst(T defaultValue) {
<ide> * </dl>
<ide> *
<ide> * @param onNext
<del> * the {@link Consumer} to invoke for each item emitted by the {@code BlockingObservable}
<add> * the {@link Consumer} to invoke for each item emitted by the {@code Flowable}
<ide> * @throws RuntimeException
<ide> * if an error occurs
<ide> * @see <a href="http://reactivex.io/documentation/operators/subscribe.html">ReactiveX documentation: Subscribe</a>
<ide> public final void blockingForEach(Consumer<? super T> onNext) {
<ide> }
<ide>
<ide> /**
<del> * Converts this {@code BlockingObservable} into an {@link Iterable}.
<add> * Converts this {@code Flowable} into an {@link Iterable}.
<ide> * <p>
<ide> * <img width="640" height="315" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.toIterable.png" alt="">
<ide> * <dl>
<ide> public final void blockingForEach(Consumer<? super T> onNext) {
<ide> * <dd>{@code blockingITerable} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return an {@link Iterable} version of this {@code BlockingObservable}
<add> * @return an {@link Iterable} version of this {@code Flowable}
<ide> * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX documentation: To</a>
<ide> */
<ide> public final Iterable<T> blockingIterable() {
<ide> return blockingIterable(bufferSize());
<ide> }
<ide>
<ide> /**
<del> * Converts this {@code BlockingObservable} into an {@link Iterable}.
<add> * Converts this {@code Flowable} into an {@link Iterable}.
<ide> * <p>
<ide> * <img width="640" height="315" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.toIterable.png" alt="">
<ide> * <dl>
<ide> * <dt><b>Backpressure:</b></dt>
<ide> * <dd>The operator consumes the source {@code Flowable} in an unbounded manner
<ide> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<del> * <dd>{@code blockingFlowable} does not operate by default on a particular {@link Scheduler}.</dd>
<add> * <dd>{@code blockingIterable} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<ide> * @param bufferSize the number of items to prefetch from the current Flowable
<del> * @return an {@link Iterable} version of this {@code BlockingObservable}
<add> * @return an {@link Iterable} version of this {@code Flowable}
<ide> * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX documentation: To</a>
<ide> */
<ide> public final Iterable<T> blockingIterable(int bufferSize) {
<ide> public final Iterable<T> blockingIterable(int bufferSize) {
<ide> }
<ide>
<ide> /**
<del> * Returns the last item emitted by this {@code BlockingObservable}, or throws
<del> * {@code NoSuchElementException} if this {@code BlockingObservable} emits no items.
<add> * Returns the last item emitted by this {@code Flowable}, or throws
<add> * {@code NoSuchElementException} if this {@code Flowable} emits no items.
<ide> * <p>
<ide> * <img width="640" height="315" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.last.png" alt="">
<ide> * <dl>
<ide> public final Iterable<T> blockingIterable(int bufferSize) {
<ide> * <dd>{@code blockingLast} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return the last item emitted by this {@code BlockingObservable}
<add> * @return the last item emitted by this {@code Flowable}
<ide> * @throws NoSuchElementException
<del> * if this {@code BlockingObservable} emits no items
<add> * if this {@code Flowable} emits no items
<ide> * @see <a href="http://reactivex.io/documentation/operators/last.html">ReactiveX documentation: Last</a>
<ide> */
<ide> public final T blockingLast() {
<ide> public final T blockingLast() {
<ide> }
<ide>
<ide> /**
<del> * Returns the last item emitted by this {@code BlockingObservable}, or a default value if it emits no
<add> * Returns the last item emitted by this {@code Flowable}, or a default value if it emits no
<ide> * items.
<ide> * <p>
<ide> * <img width="640" height="310" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.lastOrDefault.png" alt="">
<ide> public final T blockingLast() {
<ide> * </dl>
<ide> *
<ide> * @param defaultValue
<del> * a default value to return if this {@code BlockingObservable} emits no items
<del> * @return the last item emitted by the {@code BlockingObservable}, or the default value if it emits no
<add> * a default value to return if this {@code Flowable} emits no items
<add> * @return the last item emitted by the {@code Flowable}, or the default value if it emits no
<ide> * items
<ide> * @see <a href="http://reactivex.io/documentation/operators/last.html">ReactiveX documentation: Last</a>
<ide> */
<ide> public final T blockingLast(T defaultValue) {
<ide> }
<ide>
<ide> /**
<del> * Returns an {@link Iterable} that returns the latest item emitted by this {@code BlockingObservable},
<add> * Returns an {@link Iterable} that returns the latest item emitted by this {@code Flowable},
<ide> * waiting if necessary for one to become available.
<ide> * <p>
<del> * If this {@code BlockingObservable} produces items faster than {@code Iterator.next} takes them,
<add> * If this {@code Flowable} produces items faster than {@code Iterator.next} takes them,
<ide> * {@code onNext} events might be skipped, but {@code onError} or {@code onCompleted} events are not.
<ide> * <p>
<ide> * Note also that an {@code onNext} directly followed by {@code onCompleted} might hide the {@code onNext}
<ide> public final T blockingLast(T defaultValue) {
<ide> * <dd>{@code blockingLatest} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return an Iterable that always returns the latest item emitted by this {@code BlockingObservable}
<add> * @return an Iterable that always returns the latest item emitted by this {@code Flowable}
<ide> * @see <a href="http://reactivex.io/documentation/operators/first.html">ReactiveX documentation: First</a>
<ide> */
<ide> public final Iterable<T> blockingLatest() {
<ide> public final Iterable<T> blockingLatest() {
<ide>
<ide> /**
<ide> * Returns an {@link Iterable} that always returns the item most recently emitted by this
<del> * {@code BlockingObservable}.
<add> * {@code Flowable}.
<ide> * <p>
<ide> * <img width="640" height="490" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.mostRecent.png" alt="">
<ide> * <dl>
<ide> public final Iterable<T> blockingLatest() {
<ide> *
<ide> * @param initialValue
<ide> * the initial value that the {@link Iterable} sequence will yield if this
<del> * {@code BlockingObservable} has not yet emitted an item
<del> * @return an {@link Iterable} that on each iteration returns the item that this {@code BlockingObservable}
<add> * {@code Flowable} has not yet emitted an item
<add> * @return an {@link Iterable} that on each iteration returns the item that this {@code Flowable}
<ide> * has most recently emitted
<ide> * @see <a href="http://reactivex.io/documentation/operators/first.html">ReactiveX documentation: First</a>
<ide> */
<ide> public final Iterable<T> blockingMostRecent(T initialValue) {
<ide> }
<ide>
<ide> /**
<del> * Returns an {@link Iterable} that blocks until this {@code BlockingObservable} emits another item, then
<add> * Returns an {@link Iterable} that blocks until this {@code Flowable} emits another item, then
<ide> * returns that item.
<ide> * <p>
<ide> * <img width="640" height="490" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.next.png" alt="">
<ide> public final Iterable<T> blockingMostRecent(T initialValue) {
<ide> * <dd>{@code blockingNext} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return an {@link Iterable} that blocks upon each iteration until this {@code BlockingObservable} emits
<add> * @return an {@link Iterable} that blocks upon each iteration until this {@code Flowable} emits
<ide> * a new item, whereupon the Iterable returns that item
<ide> * @see <a href="http://reactivex.io/documentation/operators/takelast.html">ReactiveX documentation: TakeLast</a>
<ide> */
<ide> public final Iterable<T> blockingNext() {
<ide> }
<ide>
<ide> /**
<del> * If this {@code BlockingObservable} completes after emitting a single item, return that item, otherwise
<add> * If this {@code Flowable} completes after emitting a single item, return that item, otherwise
<ide> * throw a {@code NoSuchElementException}.
<ide> * <p>
<ide> * <img width="640" height="315" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.single.png" alt="">
<ide> public final Iterable<T> blockingNext() {
<ide> * <dd>{@code blockingSingle} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return the single item emitted by this {@code BlockingObservable}
<add> * @return the single item emitted by this {@code Flowable}
<ide> * @see <a href="http://reactivex.io/documentation/operators/first.html">ReactiveX documentation: First</a>
<ide> */
<ide> public final T blockingSingle() {
<ide> return single().blockingFirst();
<ide> }
<ide>
<ide> /**
<del> * If this {@code BlockingObservable} completes after emitting a single item, return that item; if it emits
<add> * If this {@code Flowable} completes after emitting a single item, return that item; if it emits
<ide> * more than one item, throw an {@code IllegalArgumentException}; if it emits no items, return a default
<ide> * value.
<ide> * <p>
<ide> public final T blockingSingle() {
<ide> * </dl>
<ide> *
<ide> * @param defaultValue
<del> * a default value to return if this {@code BlockingObservable} emits no items
<del> * @return the single item emitted by this {@code BlockingObservable}, or the default value if it emits no
<add> * a default value to return if this {@code Flowable} emits no items
<add> * @return the single item emitted by this {@code Flowable}, or the default value if it emits no
<ide> * items
<ide> * @see <a href="http://reactivex.io/documentation/operators/first.html">ReactiveX documentation: First</a>
<ide> */
<ide> public final T blockingSingle(T defaultValue) {
<ide> }
<ide>
<ide> /**
<del> * Returns a {@link Future} representing the single value emitted by this {@code BlockingObservable}.
<add> * Returns a {@link Future} representing the single value emitted by this {@code Flowable}.
<ide> * <p>
<ide> * If the {@link Flowable} emits more than one item, {@link java.util.concurrent.Future} will receive an
<ide> * {@link java.lang.IllegalArgumentException}. If the {@link Flowable} is empty, {@link java.util.concurrent.Future}
<ide> * will receive an {@link java.util.NoSuchElementException}.
<ide> * <p>
<del> * If the {@code BlockingObservable} may emit more than one item, use {@code Observable.toList().toBlocking().toFuture()}.
<add> * If the {@code Flowable} may emit more than one item, use {@code Observable.toList().toBlocking().toFuture()}.
<ide> * <p>
<ide> * <img width="640" height="395" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.toFuture.png" alt="">
<ide> * <dl>
<ide> public final T blockingSingle(T defaultValue) {
<ide> * <dd>{@code toFuture} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return a {@link Future} that expects a single item to be emitted by this {@code BlockingObservable}
<add> * @return a {@link Future} that expects a single item to be emitted by this {@code Flowable}
<ide> * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX documentation: To</a>
<ide> */
<ide> public final Future<T> toFuture() {
<ide> public final Flowable<List<T>> buffer(int count, int skip) {
<ide> @BackpressureSupport(BackpressureKind.FULL)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <U extends Collection<? super T>> Flowable<U> buffer(int count, int skip, Callable<U> bufferSupplier) {
<del> return new FlowableBuffer<T, U>(this, count, skip, bufferSupplier);
<add> return RxJavaPlugins.onAssembly(new FlowableBuffer<T, U>(this, count, skip, bufferSupplier));
<ide> }
<ide>
<ide> /**
<ide> public final <U extends Collection<? super T>> Flowable<U> buffer(long timespan,
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide> ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null");
<del> return new FlowableBufferTimed<T, U>(this, timespan, timeskip, unit, scheduler, bufferSupplier, Integer.MAX_VALUE, false);
<add> return RxJavaPlugins.onAssembly(new FlowableBufferTimed<T, U>(this, timespan, timeskip, unit, scheduler, bufferSupplier, Integer.MAX_VALUE, false));
<ide> }
<ide>
<ide> /**
<ide> public final <U extends Collection<? super T>> Flowable<U> buffer(
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide> ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null");
<ide> verifyPositive(count, "count");
<del> return new FlowableBufferTimed<T, U>(this, timespan, timespan, unit, scheduler, bufferSupplier, count, restartTimerOnMaxSize);
<add> return RxJavaPlugins.onAssembly(new FlowableBufferTimed<T, U>(this, timespan, timespan, unit, scheduler, bufferSupplier, count, restartTimerOnMaxSize));
<ide> }
<ide>
<ide> /**
<ide> public final <TOpening, TClosing, U extends Collection<? super T>> Flowable<U> b
<ide> ObjectHelper.requireNonNull(bufferOpenings, "bufferOpenings is null");
<ide> ObjectHelper.requireNonNull(bufferClosingSelector, "bufferClosingSelector is null");
<ide> ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null");
<del> return new FlowableBufferBoundary<T, U, TOpening, TClosing>(this, bufferOpenings, bufferClosingSelector, bufferSupplier);
<add> return RxJavaPlugins.onAssembly(new FlowableBufferBoundary<T, U, TOpening, TClosing>(this, bufferOpenings, bufferClosingSelector, bufferSupplier));
<ide> }
<ide>
<ide> /**
<ide> public final <B> Flowable<List<T>> buffer(Publisher<B> boundary, final int initi
<ide> public final <B, U extends Collection<? super T>> Flowable<U> buffer(Publisher<B> boundary, Callable<U> bufferSupplier) {
<ide> ObjectHelper.requireNonNull(boundary, "boundary is null");
<ide> ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null");
<del> return new FlowableBufferExactBoundary<T, U, B>(this, boundary, bufferSupplier);
<add> return RxJavaPlugins.onAssembly(new FlowableBufferExactBoundary<T, U, B>(this, boundary, bufferSupplier));
<ide> }
<ide>
<ide> /**
<ide> public final <B, U extends Collection<? super T>> Flowable<U> buffer(Callable<?
<ide> Callable<U> bufferSupplier) {
<ide> ObjectHelper.requireNonNull(boundarySupplier, "boundarySupplier is null");
<ide> ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null");
<del> return new FlowableBufferBoundarySupplier<T, U, B>(this, boundarySupplier, bufferSupplier);
<add> return RxJavaPlugins.onAssembly(new FlowableBufferBoundarySupplier<T, U, B>(this, boundarySupplier, bufferSupplier));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Flowable<U> cast(final Class<U> clazz) {
<ide> public final <U> Flowable<U> collect(Callable<? extends U> initialValueSupplier, BiConsumer<? super U, ? super T> collector) {
<ide> ObjectHelper.requireNonNull(initialValueSupplier, "initialValueSupplier is null");
<ide> ObjectHelper.requireNonNull(collector, "collectior is null");
<del> return new FlowableCollect<T, U>(this, initialValueSupplier, collector);
<add> return RxJavaPlugins.onAssembly(new FlowableCollect<T, U>(this, initialValueSupplier, collector));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Flowable<R> concatMap(Function<? super T, ? extends Publisher<?
<ide> return FlowableScalarXMap.scalarXMap(v, mapper);
<ide> }
<ide> verifyPositive(prefetch, "prefetch");
<del> return new FlowableConcatMap<T, R>(this, mapper, prefetch, ErrorMode.IMMEDIATE);
<add> return RxJavaPlugins.onAssembly(new FlowableConcatMap<T, R>(this, mapper, prefetch, ErrorMode.IMMEDIATE));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Flowable<R> concatMapDelayError(Function<? super T, ? extends P
<ide> return FlowableScalarXMap.scalarXMap(v, mapper);
<ide> }
<ide> verifyPositive(prefetch, "prefetch");
<del> return new FlowableConcatMap<T, R>(this, mapper, prefetch, tillTheEnd ? ErrorMode.END : ErrorMode.IMMEDIATE);
<add> return RxJavaPlugins.onAssembly(new FlowableConcatMap<T, R>(this, mapper, prefetch, tillTheEnd ? ErrorMode.END : ErrorMode.IMMEDIATE));
<ide> }
<ide>
<ide>
<ide> public final <R> Flowable<R> concatMapEager(Function<? super T, ? extends Publis
<ide> int maxConcurrency, int prefetch) {
<ide> verifyPositive(maxConcurrency, "maxConcurrency");
<ide> verifyPositive(prefetch, "prefetch");
<del> return new FlowableConcatMapEager<T, R>(this, mapper, maxConcurrency, prefetch, ErrorMode.IMMEDIATE);
<add> return RxJavaPlugins.onAssembly(new FlowableConcatMapEager<T, R>(this, mapper, maxConcurrency, prefetch, ErrorMode.IMMEDIATE));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Flowable<R> concatMapEagerDelayError(Function<? super T, ? exte
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <R> Flowable<R> concatMapEagerDelayError(Function<? super T, ? extends Publisher<? extends R>> mapper,
<ide> int maxConcurrency, int prefetch, boolean tillTheEnd) {
<del> return new FlowableConcatMapEager<T, R>(this, mapper, maxConcurrency, prefetch, tillTheEnd ? ErrorMode.END : ErrorMode.BOUNDARY);
<add> return RxJavaPlugins.onAssembly(new FlowableConcatMapEager<T, R>(this, mapper, maxConcurrency, prefetch, tillTheEnd ? ErrorMode.END : ErrorMode.BOUNDARY));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Flowable<U> concatMapIterable(Function<? super T, ? extends Ite
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <U> Flowable<U> concatMapIterable(final Function<? super T, ? extends Iterable<? extends U>> mapper, int prefetch) {
<ide> ObjectHelper.requireNonNull(mapper, "mapper is null");
<del> return new FlowableFlattenIterable<T, U>(this, mapper, prefetch);
<add> return RxJavaPlugins.onAssembly(new FlowableFlattenIterable<T, U>(this, mapper, prefetch));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<Boolean> contains(final Object element) {
<ide> @BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<Long> count() {
<del> return new FlowableCount<T>(this);
<add> return RxJavaPlugins.onAssembly(new FlowableCount<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<Long> count() {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <U> Flowable<T> debounce(Function<? super T, ? extends Publisher<U>> debounceSelector) {
<ide> ObjectHelper.requireNonNull(debounceSelector, "debounceSelector is null");
<del> return new FlowableDebounce<T, U>(this, debounceSelector);
<add> return RxJavaPlugins.onAssembly(new FlowableDebounce<T, U>(this, debounceSelector));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> debounce(long timeout, TimeUnit unit) {
<ide> public final Flowable<T> debounce(long timeout, TimeUnit unit, Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new FlowableDebounceTimed<T>(this, timeout, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new FlowableDebounceTimed<T>(this, timeout, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> delay(long delay, TimeUnit unit, Scheduler scheduler, b
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide>
<del> return new FlowableDelay<T>(this, delay, unit, scheduler, delayError);
<add> return RxJavaPlugins.onAssembly(new FlowableDelay<T>(this, delay, unit, scheduler, delayError));
<ide> }
<ide>
<ide> /**
<ide> public final <U, V> Flowable<T> delay(Publisher<U> subscriptionDelay,
<ide> */
<ide> public final <U> Flowable<T> delaySubscription(Publisher<U> other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return new FlowableDelaySubscriptionOther<T, U>(this, other);
<add> return RxJavaPlugins.onAssembly(new FlowableDelaySubscriptionOther<T, U>(this, other));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> delaySubscription(long delay, TimeUnit unit, Scheduler
<ide> public final <T2> Flowable<T2> dematerialize() {
<ide> @SuppressWarnings("unchecked")
<ide> Flowable<Notification<T2>> m = (Flowable<Notification<T2>>)this;
<del> return new FlowableDematerialize<T2>(m);
<add> return RxJavaPlugins.onAssembly(new FlowableDematerialize<T2>(m));
<ide> }
<ide>
<ide> /**
<ide> public final <K> Flowable<T> distinctUntilChanged(Function<? super T, K> keySele
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> distinctUntilChanged(BiPredicate<? super T, ? super T> comparer) {
<ide> ObjectHelper.requireNonNull(comparer, "comparer is null");
<del> return new FlowableDistinctUntilChanged<T>(this, comparer);
<add> return RxJavaPlugins.onAssembly(new FlowableDistinctUntilChanged<T>(this, comparer));
<ide> }
<ide>
<ide> /**
<ide> private Flowable<T> doOnEach(Consumer<? super T> onNext, Consumer<? super Throwa
<ide> ObjectHelper.requireNonNull(onError, "onError is null");
<ide> ObjectHelper.requireNonNull(onComplete, "onComplete is null");
<ide> ObjectHelper.requireNonNull(onAfterTerminate, "onAfterTerminate is null");
<del> return new FlowableDoOnEach<T>(this, onNext, onError, onComplete, onAfterTerminate);
<add> return RxJavaPlugins.onAssembly(new FlowableDoOnEach<T>(this, onNext, onError, onComplete, onAfterTerminate));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> doOnLifecycle(final Consumer<? super Subscription> onSu
<ide> ObjectHelper.requireNonNull(onSubscribe, "onSubscribe is null");
<ide> ObjectHelper.requireNonNull(onRequest, "onRequest is null");
<ide> ObjectHelper.requireNonNull(onCancel, "onCancel is null");
<del> return new FlowableDoOnLifecycle<T>(this, onSubscribe, onRequest, onCancel);
<add> return RxJavaPlugins.onAssembly(new FlowableDoOnLifecycle<T>(this, onSubscribe, onRequest, onCancel));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> elementAt(long index) {
<ide> if (index < 0) {
<ide> throw new IndexOutOfBoundsException("index >= 0 required but it was " + index);
<ide> }
<del> return new FlowableElementAt<T>(this, index, null);
<add> return RxJavaPlugins.onAssembly(new FlowableElementAt<T>(this, index, null));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> elementAt(long index, T defaultValue) {
<ide> throw new IndexOutOfBoundsException("index >= 0 required but it was " + index);
<ide> }
<ide> ObjectHelper.requireNonNull(defaultValue, "defaultValue is null");
<del> return new FlowableElementAt<T>(this, index, defaultValue);
<add> return RxJavaPlugins.onAssembly(new FlowableElementAt<T>(this, index, defaultValue));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> elementAt(long index, T defaultValue) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> filter(Predicate<? super T> predicate) {
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<del> return new FlowableFilter<T>(this, predicate);
<add> return RxJavaPlugins.onAssembly(new FlowableFilter<T>(this, predicate));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Flowable<R> flatMap(Function<? super T, ? extends Publisher<? e
<ide> }
<ide> verifyPositive(maxConcurrency, "maxConcurrency");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new FlowableFlatMap<T, R>(this, mapper, delayErrors, maxConcurrency, bufferSize);
<add> return RxJavaPlugins.onAssembly(new FlowableFlatMap<T, R>(this, mapper, delayErrors, maxConcurrency, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Flowable<U> flatMapIterable(final Function<? super T, ? extends
<ide> @BackpressureSupport(BackpressureKind.FULL)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <U> Flowable<U> flatMapIterable(final Function<? super T, ? extends Iterable<? extends U>> mapper, int bufferSize) {
<del> return new FlowableFlattenIterable<T, U>(this, mapper, bufferSize);
<add> return RxJavaPlugins.onAssembly(new FlowableFlattenIterable<T, U>(this, mapper, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public final <K, V> Flowable<GroupedFlowable<K, V>> groupBy(Function<? super T,
<ide> ObjectHelper.requireNonNull(valueSelector, "valueSelector is null");
<ide> verifyPositive(bufferSize, "bufferSize");
<ide>
<del> return new FlowableGroupBy<T, K, V>(this, keySelector, valueSelector, bufferSize, delayError);
<add> return RxJavaPlugins.onAssembly(new FlowableGroupBy<T, K, V>(this, keySelector, valueSelector, bufferSize, delayError));
<ide> }
<ide>
<ide> /**
<ide> public final <TRight, TLeftEnd, TRightEnd, R> Flowable<R> groupJoin(
<ide> Function<? super T, ? extends Publisher<TLeftEnd>> leftEnd,
<ide> Function<? super TRight, ? extends Publisher<TRightEnd>> rightEnd,
<ide> BiFunction<? super T, ? super Flowable<TRight>, ? extends R> resultSelector) {
<del> return new FlowableGroupJoin<T, TRight, TLeftEnd, TRightEnd, R>(
<del> this, other, leftEnd, rightEnd, resultSelector);
<add> return RxJavaPlugins.onAssembly(new FlowableGroupJoin<T, TRight, TLeftEnd, TRightEnd, R>(
<add> this, other, leftEnd, rightEnd, resultSelector));
<ide> }
<ide>
<ide> /**
<ide> public final <TRight, TLeftEnd, TRightEnd, R> Flowable<R> groupJoin(
<ide> @BackpressureSupport(BackpressureKind.PASS_THROUGH)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> hide() {
<del> return new FlowableHide<T>(this);
<add> return RxJavaPlugins.onAssembly(new FlowableHide<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> hide() {
<ide> @BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> ignoreElements() {
<del> return new FlowableIgnoreElements<T>(this);
<add> return RxJavaPlugins.onAssembly(new FlowableIgnoreElements<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final <TRight, TLeftEnd, TRightEnd, R> Flowable<R> join(
<ide> Function<? super T, ? extends Publisher<TLeftEnd>> leftEnd,
<ide> Function<? super TRight, ? extends Publisher<TRightEnd>> rightEnd,
<ide> BiFunction<? super T, ? super TRight, ? extends R> resultSelector) {
<del> return new FlowableJoin<T, TRight, TLeftEnd, TRightEnd, R>(
<del> this, other, leftEnd, rightEnd, resultSelector);
<add> return RxJavaPlugins.onAssembly(new FlowableJoin<T, TRight, TLeftEnd, TRightEnd, R>(
<add> this, other, leftEnd, rightEnd, resultSelector));
<ide> }
<ide>
<ide>
<ide> public final Flowable<T> last(T defaultValue) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <R> Flowable<R> lift(FlowableOperator<? extends R, ? super T> lifter) {
<ide> ObjectHelper.requireNonNull(lifter, "lifter is null");
<del> // using onSubscribe so the fusing has access to the underlying raw Publisher
<del> return new FlowableLift<R, T>(this, lifter);
<add> return RxJavaPlugins.onAssembly(new FlowableLift<R, T>(this, lifter));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Flowable<R> lift(FlowableOperator<? extends R, ? super T> lifte
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <R> Flowable<R> map(Function<? super T, ? extends R> mapper) {
<ide> ObjectHelper.requireNonNull(mapper, "mapper is null");
<del> return new FlowableMap<T, R>(this, mapper);
<add> return RxJavaPlugins.onAssembly(new FlowableMap<T, R>(this, mapper));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Flowable<R> map(Function<? super T, ? extends R> mapper) {
<ide> @BackpressureSupport(BackpressureKind.FULL)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<Notification<T>> materialize() {
<del> return new FlowableMaterialize<T>(this);
<add> return RxJavaPlugins.onAssembly(new FlowableMaterialize<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> observeOn(Scheduler scheduler, boolean delayError) {
<ide> public final Flowable<T> observeOn(Scheduler scheduler, boolean delayError, int bufferSize) {
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new FlowableObserveOn<T>(this, scheduler, delayError, bufferSize);
<add> return RxJavaPlugins.onAssembly(new FlowableObserveOn<T>(this, scheduler, delayError, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> onBackpressureBuffer(int capacity, boolean delayError)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> onBackpressureBuffer(int capacity, boolean delayError, boolean unbounded) {
<ide> verifyPositive(capacity, "bufferSize");
<del> return new FlowableOnBackpressureBuffer<T>(this, capacity, unbounded, delayError, Functions.EMPTY_ACTION);
<add> return RxJavaPlugins.onAssembly(new FlowableOnBackpressureBuffer<T>(this, capacity, unbounded, delayError, Functions.EMPTY_ACTION));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> onBackpressureBuffer(int capacity, boolean delayError,
<ide> public final Flowable<T> onBackpressureBuffer(int capacity, boolean delayError, boolean unbounded,
<ide> Action onOverflow) {
<ide> ObjectHelper.requireNonNull(onOverflow, "onOverflow is null");
<del> return new FlowableOnBackpressureBuffer<T>(this, capacity, unbounded, delayError, onOverflow);
<add> return RxJavaPlugins.onAssembly(new FlowableOnBackpressureBuffer<T>(this, capacity, unbounded, delayError, onOverflow));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> onBackpressureBuffer(int capacity, Action onOverflow) {
<ide> public final Publisher<T> onBackpressureBuffer(long capacity, Action onOverflow, BackpressureOverflowStrategy overflowStrategy) {
<ide> ObjectHelper.requireNonNull(overflowStrategy, "strategy is null");
<ide> verifyPositive(capacity, "capacity");
<del> return new FlowableOnBackpressureBufferStrategy<T>(this, capacity, onOverflow, overflowStrategy);
<add> return RxJavaPlugins.onAssembly(new FlowableOnBackpressureBufferStrategy<T>(this, capacity, onOverflow, overflowStrategy));
<ide> }
<ide>
<ide> /**
<ide> public final Publisher<T> onBackpressureBuffer(long capacity, Action onOverflow,
<ide> @BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> onBackpressureDrop() {
<del> return new FlowableOnBackpressureDrop<T>(this);
<add> return RxJavaPlugins.onAssembly(new FlowableOnBackpressureDrop<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> onBackpressureDrop() {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> onBackpressureDrop(Consumer<? super T> onDrop) {
<ide> ObjectHelper.requireNonNull(onDrop, "onDrop is null");
<del> return new FlowableOnBackpressureDrop<T>(this, onDrop);
<add> return RxJavaPlugins.onAssembly(new FlowableOnBackpressureDrop<T>(this, onDrop));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> onBackpressureDrop(Consumer<? super T> onDrop) {
<ide> @BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> onBackpressureLatest() {
<del> return new FlowableOnBackpressureLatest<T>(this);
<add> return RxJavaPlugins.onAssembly(new FlowableOnBackpressureLatest<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> onBackpressureLatest() {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> onErrorResumeNext(Function<? super Throwable, ? extends Publisher<? extends T>> resumeFunction) {
<ide> ObjectHelper.requireNonNull(resumeFunction, "resumeFunction is null");
<del> return new FlowableOnErrorNext<T>(this, resumeFunction, false);
<add> return RxJavaPlugins.onAssembly(new FlowableOnErrorNext<T>(this, resumeFunction, false));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> onErrorResumeNext(final Publisher<? extends T> next) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> onErrorReturn(Function<? super Throwable, ? extends T> valueSupplier) {
<ide> ObjectHelper.requireNonNull(valueSupplier, "valueSupplier is null");
<del> return new FlowableOnErrorReturn<T>(this, valueSupplier);
<add> return RxJavaPlugins.onAssembly(new FlowableOnErrorReturn<T>(this, valueSupplier));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> onErrorReturnValue(final T value) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> onExceptionResumeNext(final Publisher<? extends T> next) {
<ide> ObjectHelper.requireNonNull(next, "next is null");
<del> return new FlowableOnErrorNext<T>(this, Functions.justFunction(next), true);
<add> return RxJavaPlugins.onAssembly(new FlowableOnErrorNext<T>(this, Functions.justFunction(next), true));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> onExceptionResumeNext(final Publisher<? extends T> next
<ide> @BackpressureSupport(BackpressureKind.PASS_THROUGH)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> onTerminateDetach() {
<del> return new FlowableDetach<T>(this);
<add> return RxJavaPlugins.onAssembly(new FlowableDetach<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Flowable<R> publish(Function<? super Flowable<T>, ? extends Pub
<ide> public final <R> Flowable<R> publish(Function<? super Flowable<T>, ? extends Publisher<? extends R>> selector, int prefetch) {
<ide> ObjectHelper.requireNonNull(selector, "selector is null");
<ide> verifyPositive(prefetch, "prefetch");
<del> return new FlowablePublishMulticast<T, R>(this, selector, prefetch, false);
<add> return RxJavaPlugins.onAssembly(new FlowablePublishMulticast<T, R>(this, selector, prefetch, false));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> repeat(long count) {
<ide> if (count == 0) {
<ide> return empty();
<ide> }
<del> return new FlowableRepeat<T>(this, count);
<add> return RxJavaPlugins.onAssembly(new FlowableRepeat<T>(this, count));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> repeat(long count) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> repeatUntil(BooleanSupplier stop) {
<ide> ObjectHelper.requireNonNull(stop, "stop is null");
<del> return new FlowableRepeatUntil<T>(this, stop);
<add> return RxJavaPlugins.onAssembly(new FlowableRepeatUntil<T>(this, stop));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> repeatUntil(BooleanSupplier stop) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> repeatWhen(final Function<? super Flowable<Object>, ? extends Publisher<?>> handler) {
<ide> ObjectHelper.requireNonNull(handler, "handler is null");
<del> return new FlowableRepeatWhen<T>(this, handler);
<add> return RxJavaPlugins.onAssembly(new FlowableRepeatWhen<T>(this, handler));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> retry() {
<ide> public final Flowable<T> retry(BiPredicate<? super Integer, ? super Throwable> predicate) {
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<ide>
<del> return new FlowableRetryBiPredicate<T>(this, predicate);
<add> return RxJavaPlugins.onAssembly(new FlowableRetryBiPredicate<T>(this, predicate));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> retry(long times, Predicate<? super Throwable> predicat
<ide> }
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<ide>
<del> return new FlowableRetryPredicate<T>(this, times, predicate);
<add> return RxJavaPlugins.onAssembly(new FlowableRetryPredicate<T>(this, times, predicate));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> retryWhen(
<ide> final Function<? super Flowable<? extends Throwable>, ? extends Publisher<?>> handler) {
<ide> ObjectHelper.requireNonNull(handler, "handler is null");
<ide>
<del> return new FlowableRetryWhen<T>(this, handler);
<add> return RxJavaPlugins.onAssembly(new FlowableRetryWhen<T>(this, handler));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> sample(long period, TimeUnit unit) {
<ide> public final Flowable<T> sample(long period, TimeUnit unit, Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new FlowableSampleTimed<T>(this, period, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new FlowableSampleTimed<T>(this, period, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> sample(long period, TimeUnit unit, Scheduler scheduler)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <U> Flowable<T> sample(Publisher<U> sampler) {
<ide> ObjectHelper.requireNonNull(sampler, "sampler is null");
<del> return new FlowableSamplePublisher<T>(this, sampler);
<add> return RxJavaPlugins.onAssembly(new FlowableSamplePublisher<T>(this, sampler));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Flowable<T> sample(Publisher<U> sampler) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> scan(BiFunction<T, T, T> accumulator) {
<ide> ObjectHelper.requireNonNull(accumulator, "accumulator is null");
<del> return new FlowableScan<T>(this, accumulator);
<add> return RxJavaPlugins.onAssembly(new FlowableScan<T>(this, accumulator));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Flowable<R> scan(final R initialValue, BiFunction<R, ? super T,
<ide> public final <R> Flowable<R> scanWith(Callable<R> seedSupplier, BiFunction<R, ? super T, R> accumulator) {
<ide> ObjectHelper.requireNonNull(seedSupplier, "seedSupplier is null");
<ide> ObjectHelper.requireNonNull(accumulator, "accumulator is null");
<del> return new FlowableScanSeed<T, R>(this, seedSupplier, accumulator);
<add> return RxJavaPlugins.onAssembly(new FlowableScanSeed<T, R>(this, seedSupplier, accumulator));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Flowable<R> scanWith(Callable<R> seedSupplier, BiFunction<R, ?
<ide> @BackpressureSupport(BackpressureKind.PASS_THROUGH)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> serialize() {
<del> return new FlowableSerialized<T>(this);
<add> return RxJavaPlugins.onAssembly(new FlowableSerialized<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> share() {
<ide> @BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> single() {
<del> return new FlowableSingle<T>(this, null);
<add> return RxJavaPlugins.onAssembly(new FlowableSingle<T>(this, null));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> single() {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> single(T defaultValue) {
<ide> ObjectHelper.requireNonNull(defaultValue, "defaultValue is null");
<del> return new FlowableSingle<T>(this, defaultValue);
<add> return RxJavaPlugins.onAssembly(new FlowableSingle<T>(this, defaultValue));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> single(T defaultValue) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> skip(long count) {
<ide> if (count <= 0L) {
<del> return this;
<add> return RxJavaPlugins.onAssembly(this);
<ide> }
<del> return new FlowableSkip<T>(this, count);
<add> return RxJavaPlugins.onAssembly(new FlowableSkip<T>(this, count));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> skipLast(int count) {
<ide> throw new IndexOutOfBoundsException("count >= 0 required but it was " + count);
<ide> }
<ide> if (count == 0) {
<del> return this;
<add> return RxJavaPlugins.onAssembly(this);
<ide> }
<del> return new FlowableSkipLast<T>(this, count);
<add> return RxJavaPlugins.onAssembly(new FlowableSkipLast<T>(this, count));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> skipLast(long time, TimeUnit unit, Scheduler scheduler,
<ide> verifyPositive(bufferSize, "bufferSize");
<ide> // the internal buffer holds pairs of (timestamp, value) so double the default buffer size
<ide> int s = bufferSize << 1;
<del> return new FlowableSkipLastTimed<T>(this, time, unit, scheduler, s, delayError);
<add> return RxJavaPlugins.onAssembly(new FlowableSkipLastTimed<T>(this, time, unit, scheduler, s, delayError));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> skipLast(long time, TimeUnit unit, Scheduler scheduler,
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <U> Flowable<T> skipUntil(Publisher<U> other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return new FlowableSkipUntil<T, U>(this, other);
<add> return RxJavaPlugins.onAssembly(new FlowableSkipUntil<T, U>(this, other));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Flowable<T> skipUntil(Publisher<U> other) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> skipWhile(Predicate<? super T> predicate) {
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<del> return new FlowableSkipWhile<T>(this, predicate);
<add> return RxJavaPlugins.onAssembly(new FlowableSkipWhile<T>(this, predicate));
<ide> }
<ide> /**
<ide> * Returns a Flowable that emits the events emitted by source Publisher, in a
<ide> public final Flowable<T> startWith(T value) {
<ide> public final Flowable<T> startWithArray(T... values) {
<ide> Flowable<T> fromArray = fromArray(values);
<ide> if (fromArray == empty()) {
<del> return this;
<add> return RxJavaPlugins.onAssembly(this);
<ide> }
<ide> return concatArray(fromArray, this);
<ide> }
<ide> public final void subscribe(Subscriber<? super T> s) {
<ide> @SchedulerSupport(SchedulerSupport.CUSTOM)
<ide> public final Flowable<T> subscribeOn(Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new FlowableSubscribeOn<T>(this, scheduler);
<add> return RxJavaPlugins.onAssembly(new FlowableSubscribeOn<T>(this, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> subscribeOn(Scheduler scheduler) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> switchIfEmpty(Publisher<? extends T> other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return new FlowableSwitchIfEmpty<T>(this, other);
<add> return RxJavaPlugins.onAssembly(new FlowableSwitchIfEmpty<T>(this, other));
<ide> }
<ide>
<ide> /**
<ide> <R> Flowable<R> switchMap0(Function<? super T, ? extends Publisher<? extends R>>
<ide> return FlowableScalarXMap.scalarXMap(v, mapper);
<ide> }
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new FlowableSwitchMap<T, R>(this, mapper, bufferSize, delayError);
<add> return RxJavaPlugins.onAssembly(new FlowableSwitchMap<T, R>(this, mapper, bufferSize, delayError));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> take(long count) {
<ide> if (count < 0) {
<ide> throw new IllegalArgumentException("n >= required but it was " + count);
<ide> }
<del> return new FlowableTake<T>(this, count);
<add> return RxJavaPlugins.onAssembly(new FlowableTake<T>(this, count));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> takeLast(int count) {
<ide> return ignoreElements();
<ide> } else
<ide> if (count == 1) {
<del> return new FlowableTakeLastOne<T>(this);
<add> return RxJavaPlugins.onAssembly(new FlowableTakeLastOne<T>(this));
<ide> }
<del> return new FlowableTakeLast<T>(this, count);
<add> return RxJavaPlugins.onAssembly(new FlowableTakeLast<T>(this, count));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> takeLast(long count, long time, TimeUnit unit, Schedule
<ide> if (count < 0) {
<ide> throw new IndexOutOfBoundsException("count >= 0 required but it was " + count);
<ide> }
<del> return new FlowableTakeLastTimed<T>(this, count, time, unit, scheduler, bufferSize, delayError);
<add> return RxJavaPlugins.onAssembly(new FlowableTakeLastTimed<T>(this, count, time, unit, scheduler, bufferSize, delayError));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> takeLast(long time, TimeUnit unit, Scheduler scheduler,
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> takeUntil(Predicate<? super T> stopPredicate) {
<ide> ObjectHelper.requireNonNull(stopPredicate, "stopPredicate is null");
<del> return new FlowableTakeUntilPredicate<T>(this, stopPredicate);
<add> return RxJavaPlugins.onAssembly(new FlowableTakeUntilPredicate<T>(this, stopPredicate));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> takeUntil(Predicate<? super T> stopPredicate) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <U> Flowable<T> takeUntil(Publisher<U> other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return new FlowableTakeUntil<T, U>(this, other);
<add> return RxJavaPlugins.onAssembly(new FlowableTakeUntil<T, U>(this, other));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Flowable<T> takeUntil(Publisher<U> other) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<T> takeWhile(Predicate<? super T> predicate) {
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<del> return new FlowableTakeWhile<T>(this, predicate);
<add> return RxJavaPlugins.onAssembly(new FlowableTakeWhile<T>(this, predicate));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> throttleFirst(long windowDuration, TimeUnit unit) {
<ide> public final Flowable<T> throttleFirst(long skipDuration, TimeUnit unit, Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new FlowableThrottleFirstTimed<T>(this, skipDuration, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new FlowableThrottleFirstTimed<T>(this, skipDuration, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<Timed<T>> timeInterval(TimeUnit unit) {
<ide> public final Flowable<Timed<T>> timeInterval(TimeUnit unit, Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new FlowableTimeInterval<T>(this, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new FlowableTimeInterval<T>(this, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> private Flowable<T> timeout0(long timeout, TimeUnit timeUnit, Flowable<? extends
<ide> Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(timeUnit, "timeUnit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new FlowableTimeoutTimed<T>(this, timeout, timeUnit, scheduler, other);
<add> return RxJavaPlugins.onAssembly(new FlowableTimeoutTimed<T>(this, timeout, timeUnit, scheduler, other));
<ide> }
<ide>
<ide> private <U, V> Flowable<T> timeout0(
<ide> Callable<? extends Publisher<U>> firstTimeoutSelector,
<ide> Function<? super T, ? extends Publisher<V>> timeoutSelector,
<ide> Publisher<? extends T> other) {
<ide> ObjectHelper.requireNonNull(timeoutSelector, "timeoutSelector is null");
<del> return new FlowableTimeout<T, U, V>(this, firstTimeoutSelector, timeoutSelector, other);
<add> return RxJavaPlugins.onAssembly(new FlowableTimeout<T, U, V>(this, firstTimeoutSelector, timeoutSelector, other));
<ide> }
<ide>
<ide> /**
<ide> public final <R> R to(Function<? super Flowable<T>, R> converter) {
<ide> @BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Completable toCompletable() {
<del> return new CompletableFromPublisher<T>(this);
<add> return RxJavaPlugins.onAssembly(new CompletableFromPublisher<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Completable toCompletable() {
<ide> @BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<List<T>> toList() {
<del> return new FlowableToList<T, List<T>>(this);
<add> return RxJavaPlugins.onAssembly(new FlowableToList<T, List<T>>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<List<T>> toList() {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Flowable<List<T>> toList(final int capacityHint) {
<ide> verifyPositive(capacityHint, "capacityHint");
<del> return new FlowableToList<T, List<T>>(this, Functions.<T>createArrayList(capacityHint));
<add> return RxJavaPlugins.onAssembly(new FlowableToList<T, List<T>>(this, Functions.<T>createArrayList(capacityHint)));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<List<T>> toList(final int capacityHint) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <U extends Collection<? super T>> Flowable<U> toList(Callable<U> collectionSupplier) {
<ide> ObjectHelper.requireNonNull(collectionSupplier, "collectionSupplier is null");
<del> return new FlowableToList<T, U>(this, collectionSupplier);
<add> return RxJavaPlugins.onAssembly(new FlowableToList<T, U>(this, collectionSupplier));
<ide> }
<ide>
<ide> /**
<ide> public final <K, V> Flowable<Map<K, Collection<V>>> toMultimap(
<ide> @BackpressureSupport(BackpressureKind.NONE)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> toObservable() {
<del> return new ObservableFromPublisher<T>(this);
<add> return RxJavaPlugins.onAssembly(new ObservableFromPublisher<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> toObservable() {
<ide> @BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Single<T> toSingle() {
<del> return new SingleFromPublisher<T>(this);
<add> return RxJavaPlugins.onAssembly(new SingleFromPublisher<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<List<T>> toSortedList(int capacityHint) {
<ide> @SchedulerSupport(SchedulerSupport.CUSTOM)
<ide> public final Flowable<T> unsubscribeOn(Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new FlowableUnsubscribeOn<T>(this, scheduler);
<add> return RxJavaPlugins.onAssembly(new FlowableUnsubscribeOn<T>(this, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<Flowable<T>> window(long count, long skip, int bufferSize)
<ide> verifyPositive(skip, "skip");
<ide> verifyPositive(count, "count");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new FlowableWindow<T>(this, count, skip, bufferSize);
<add> return RxJavaPlugins.onAssembly(new FlowableWindow<T>(this, count, skip, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<Flowable<T>> window(long timespan, long timeskip, TimeUnit
<ide> verifyPositive(bufferSize, "bufferSize");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<del> return new FlowableWindowTimed<T>(this, timespan, timeskip, unit, scheduler, Long.MAX_VALUE, bufferSize, false);
<add> return RxJavaPlugins.onAssembly(new FlowableWindowTimed<T>(this, timespan, timeskip, unit, scheduler, Long.MAX_VALUE, bufferSize, false));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<Flowable<T>> window(
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> verifyPositive(count, "count");
<del> return new FlowableWindowTimed<T>(this, timespan, timespan, unit, scheduler, count, bufferSize, restart);
<add> return RxJavaPlugins.onAssembly(new FlowableWindowTimed<T>(this, timespan, timespan, unit, scheduler, count, bufferSize, restart));
<ide> }
<ide>
<ide> /**
<ide> public final <B> Flowable<Flowable<T>> window(Publisher<B> boundary) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <B> Flowable<Flowable<T>> window(Publisher<B> boundary, int bufferSize) {
<ide> ObjectHelper.requireNonNull(boundary, "boundary is null");
<del> return new FlowableWindowBoundary<T, B>(this, boundary, bufferSize);
<add> return RxJavaPlugins.onAssembly(new FlowableWindowBoundary<T, B>(this, boundary, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public final <U, V> Flowable<Flowable<T>> window(
<ide> Function<? super U, ? extends Publisher<V>> windowClose, int bufferSize) {
<ide> ObjectHelper.requireNonNull(windowOpen, "windowOpen is null");
<ide> ObjectHelper.requireNonNull(windowClose, "windowClose is null");
<del> return new FlowableWindowBoundarySelector<T, U, V>(this, windowOpen, windowClose, bufferSize);
<add> return RxJavaPlugins.onAssembly(new FlowableWindowBoundarySelector<T, U, V>(this, windowOpen, windowClose, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public final <B> Flowable<Flowable<T>> window(Callable<? extends Publisher<B>> b
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <B> Flowable<Flowable<T>> window(Callable<? extends Publisher<B>> boundary, int bufferSize) {
<ide> ObjectHelper.requireNonNull(boundary, "boundary is null");
<del> return new FlowableWindowBoundarySupplier<T, B>(this, boundary, bufferSize);
<add> return RxJavaPlugins.onAssembly(new FlowableWindowBoundarySupplier<T, B>(this, boundary, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public final <U, R> Flowable<R> withLatestFrom(Publisher<? extends U> other,
<ide> ObjectHelper.requireNonNull(other, "other is null");
<ide> ObjectHelper.requireNonNull(combiner, "combiner is null");
<ide>
<del> return new FlowableWithLatestFrom<T, U, R>(this, combiner, other);
<add> return RxJavaPlugins.onAssembly(new FlowableWithLatestFrom<T, U, R>(this, combiner, other));
<ide> }
<ide>
<ide> /**
<ide> public final <T1, T2, T3, T4, R> Flowable<R> withLatestFrom(
<ide> public final <R> Flowable<R> withLatestFrom(Publisher<?>[] others, Function<? super Object[], R> combiner) {
<ide> ObjectHelper.requireNonNull(others, "others is null");
<ide> ObjectHelper.requireNonNull(combiner, "combiner is null");
<del> return new FlowableWithLatestFromMany<T, R>(this, others, combiner);
<add> return RxJavaPlugins.onAssembly(new FlowableWithLatestFromMany<T, R>(this, others, combiner));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Flowable<R> withLatestFrom(Publisher<?>[] others, Function<? su
<ide> public final <R> Flowable<R> withLatestFrom(Iterable<? extends Publisher<?>> others, Function<? super Object[], R> combiner) {
<ide> ObjectHelper.requireNonNull(others, "others is null");
<ide> ObjectHelper.requireNonNull(combiner, "combiner is null");
<del> return new FlowableWithLatestFromMany<T, R>(this, others, combiner);
<add> return RxJavaPlugins.onAssembly(new FlowableWithLatestFromMany<T, R>(this, others, combiner));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Flowable<R> withLatestFrom(Iterable<? extends Publisher<?>> oth
<ide> public final <U, R> Flowable<R> zipWith(Iterable<U> other, BiFunction<? super T, ? super U, ? extends R> zipper) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<ide> ObjectHelper.requireNonNull(zipper, "zipper is null");
<del> return new FlowableZipIterable<T, U, R>(this, other, zipper);
<add> return RxJavaPlugins.onAssembly(new FlowableZipIterable<T, U, R>(this, other, zipper));
<ide> }
<ide>
<ide> /**
<ide><path>src/main/java/io/reactivex/Observable.java
<ide> */
<ide> public static <T> Observable<T> amb(Iterable<? extends ObservableSource<? extends T>> sources) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<del> return new ObservableAmb<T>(null, sources);
<add> return RxJavaPlugins.onAssembly(new ObservableAmb<T>(null, sources));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> amb(Iterable<? extends ObservableSource<? extend
<ide> */
<ide> @SuppressWarnings("unchecked")
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<del> public static <T> Observable<T> amb(ObservableSource<? extends T>... sources) {
<add> public static <T> Observable<T> ambArray(ObservableSource<? extends T>... sources) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<ide> int len = sources.length;
<ide> if (len == 0) {
<ide> public static <T> Observable<T> amb(ObservableSource<? extends T>... sources) {
<ide> if (len == 1) {
<ide> return (Observable<T>)wrap(sources[0]);
<ide> }
<del> return new ObservableAmb<T>(sources, null);
<add> return RxJavaPlugins.onAssembly(new ObservableAmb<T>(sources, null));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Observable<R> combineLatest(Iterable<? extends ObservableSo
<ide>
<ide> // the queue holds a pair of values so we need to double the capacity
<ide> int s = bufferSize << 1;
<del> return new ObservableCombineLatest<T, R>(null, sources, combiner, s, false);
<add> return RxJavaPlugins.onAssembly(new ObservableCombineLatest<T, R>(null, sources, combiner, s, false));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Observable<R> combineLatest(ObservableSource<? extends T>[]
<ide>
<ide> // the queue holds a pair of values so we need to double the capacity
<ide> int s = bufferSize << 1;
<del> return new ObservableCombineLatest<T, R>(sources, null, combiner, s, false);
<add> return RxJavaPlugins.onAssembly(new ObservableCombineLatest<T, R>(sources, null, combiner, s, false));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Observable<R> combineLatestDelayError(ObservableSource<? ex
<ide> }
<ide> // the queue holds a pair of values so we need to double the capacity
<ide> int s = bufferSize << 1;
<del> return new ObservableCombineLatest<T, R>(sources, null, combiner, s, true);
<add> return RxJavaPlugins.onAssembly(new ObservableCombineLatest<T, R>(sources, null, combiner, s, true));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Observable<R> combineLatestDelayError(Iterable<? extends Ob
<ide>
<ide> // the queue holds a pair of values so we need to double the capacity
<ide> int s = bufferSize << 1;
<del> return new ObservableCombineLatest<T, R>(null, sources, combiner, s, true);
<add> return RxJavaPlugins.onAssembly(new ObservableCombineLatest<T, R>(null, sources, combiner, s, true));
<ide> }
<ide>
<ide> /**
<ide> public static final <T> Observable<T> concat(ObservableSource<? extends Observab
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static final <T> Observable<T> concat(ObservableSource<? extends ObservableSource<? extends T>> sources, int prefetch) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<del> return new ObservableConcatMap(sources, Functions.identity(), prefetch, ErrorMode.IMMEDIATE);
<add> return RxJavaPlugins.onAssembly(new ObservableConcatMap(sources, Functions.identity(), prefetch, ErrorMode.IMMEDIATE));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> concatArray(ObservableSource<? extends T>... sou
<ide> if (sources.length == 1) {
<ide> return wrap((ObservableSource<T>)sources[0]);
<ide> }
<del> return new ObservableConcatMap(fromArray(sources), Functions.identity(), bufferSize(), ErrorMode.BOUNDARY);
<add> return RxJavaPlugins.onAssembly(new ObservableConcatMap(fromArray(sources), Functions.identity(), bufferSize(), ErrorMode.BOUNDARY));
<ide> }
<ide>
<ide> /**
<ide> public static final <T> Observable<T> concatDelayError(ObservableSource<? extend
<ide> @SuppressWarnings({ "rawtypes", "unchecked" })
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static final <T> Observable<T> concatDelayError(ObservableSource<? extends ObservableSource<? extends T>> sources, int prefetch, boolean tillTheEnd) {
<del> return new ObservableConcatMap(sources, Functions.identity(), prefetch, tillTheEnd ? ErrorMode.END : ErrorMode.BOUNDARY);
<add> return RxJavaPlugins.onAssembly(new ObservableConcatMap(sources, Functions.identity(), prefetch, tillTheEnd ? ErrorMode.END : ErrorMode.BOUNDARY));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> concatEager(Iterable<? extends ObservableSource<
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Observable<T> create(ObservableOnSubscribe<T> source) {
<ide> ObjectHelper.requireNonNull(source, "source is null");
<del> return new ObservableCreate<T>(source);
<add> return RxJavaPlugins.onAssembly(new ObservableCreate<T>(source));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> create(ObservableOnSubscribe<T> source) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Observable<T> defer(Callable<? extends ObservableSource<? extends T>> supplier) {
<ide> ObjectHelper.requireNonNull(supplier, "supplier is null");
<del> return new ObservableDefer<T>(supplier);
<add> return RxJavaPlugins.onAssembly(new ObservableDefer<T>(supplier));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> defer(Callable<? extends ObservableSource<? exte
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> @SuppressWarnings("unchecked")
<ide> public static <T> Observable<T> empty() {
<del> return (Observable<T>) ObservableEmpty.INSTANCE;
<add> return RxJavaPlugins.onAssembly((Observable<T>) ObservableEmpty.INSTANCE);
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> empty() {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Observable<T> error(Callable<? extends Throwable> errorSupplier) {
<ide> ObjectHelper.requireNonNull(errorSupplier, "errorSupplier is null");
<del> return new ObservableError<T>(errorSupplier);
<add> return RxJavaPlugins.onAssembly(new ObservableError<T>(errorSupplier));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> fromArray(T... values) {
<ide> if (values.length == 1) {
<ide> return just(values[0]);
<ide> }
<del> return new ObservableFromArray<T>(values);
<add> return RxJavaPlugins.onAssembly(new ObservableFromArray<T>(values));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> fromArray(T... values) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Observable<T> fromCallable(Callable<? extends T> supplier) {
<ide> ObjectHelper.requireNonNull(supplier, "supplier is null");
<del> return new ObservableFromCallable<T>(supplier);
<add> return RxJavaPlugins.onAssembly(new ObservableFromCallable<T>(supplier));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> fromCallable(Callable<? extends T> supplier) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Observable<T> fromFuture(Future<? extends T> future) {
<ide> ObjectHelper.requireNonNull(future, "future is null");
<del> return new ObservableFromFuture<T>(future, 0L, null);
<add> return RxJavaPlugins.onAssembly(new ObservableFromFuture<T>(future, 0L, null));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> fromFuture(Future<? extends T> future) {
<ide> public static <T> Observable<T> fromFuture(Future<? extends T> future, long timeout, TimeUnit unit) {
<ide> ObjectHelper.requireNonNull(future, "future is null");
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<del> return new ObservableFromFuture<T>(future, timeout, unit);
<add> return RxJavaPlugins.onAssembly(new ObservableFromFuture<T>(future, timeout, unit));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> fromFuture(Future<? extends T> future, Scheduler
<ide> */
<ide> public static <T> Observable<T> fromIterable(Iterable<? extends T> source) {
<ide> ObjectHelper.requireNonNull(source, "source is null");
<del> return new ObservableFromIterable<T>(source);
<add> return RxJavaPlugins.onAssembly(new ObservableFromIterable<T>(source));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> fromIterable(Iterable<? extends T> source) {
<ide> */
<ide> public static <T> Observable<T> fromPublisher(Publisher<? extends T> publisher) {
<ide> ObjectHelper.requireNonNull(publisher, "publisher is null");
<del> return new ObservableFromPublisher<T>(publisher);
<add> return RxJavaPlugins.onAssembly(new ObservableFromPublisher<T>(publisher));
<ide> }
<ide>
<ide> /**
<del> * Returns a cold, synchronous, stateless and backpressure-aware generator of values.
<add> * Returns a cold, synchronous and stateless generator of values.
<ide> * <p>
<ide> * <dl>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> public static <T> Observable<T> generate(final Consumer<Emitter<T>> generator) {
<ide> }
<ide>
<ide> /**
<del> * Returns a cold, synchronous, stateful and backpressure-aware generator of values.
<add> * Returns a cold, synchronous and stateful generator of values.
<ide> * <p>
<ide> * <dl>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> public static <T, S> Observable<T> generate(Callable<S> initialState, final BiCo
<ide> }
<ide>
<ide> /**
<del> * Returns a cold, synchronous, stateful and backpressure-aware generator of values.
<add> * Returns a cold, synchronous and stateful generator of values.
<ide> * <p>
<ide> * <dl>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> public static <T, S> Observable<T> generate(
<ide> }
<ide>
<ide> /**
<del> * Returns a cold, synchronous, stateful and backpressure-aware generator of values.
<add> * Returns a cold, synchronous and stateful generator of values.
<ide> * <p>
<ide> * <dl>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> public static <T, S> Observable<T> generate(Callable<S> initialState, BiFunction
<ide> }
<ide>
<ide> /**
<del> * Returns a cold, synchronous, stateful and backpressure-aware generator of values.
<add> * Returns a cold, synchronous and stateful generator of values.
<ide> * <p>
<ide> * <dl>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> public static <T, S> Observable<T> generate(Callable<S> initialState, BiFunction
<ide> ObjectHelper.requireNonNull(initialState, "initialState is null");
<ide> ObjectHelper.requireNonNull(generator, "generator is null");
<ide> ObjectHelper.requireNonNull(disposeState, "diposeState is null");
<del> return new ObservableGenerate<T, S>(initialState, generator, disposeState);
<add> return RxJavaPlugins.onAssembly(new ObservableGenerate<T, S>(initialState, generator, disposeState));
<ide> }
<ide>
<ide> /**
<ide> public static Observable<Long> interval(long initialDelay, long period, TimeUnit
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide>
<del> return new ObservableInterval(initialDelay, period, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new ObservableInterval(initialDelay, period, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public static Observable<Long> intervalRange(long start, long count, long initia
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide>
<del> return new ObservableIntervalRange(start, end, initialDelay, period, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new ObservableIntervalRange(start, end, initialDelay, period, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public static Observable<Long> intervalRange(long start, long count, long initia
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Observable<T> just(T value) {
<ide> ObjectHelper.requireNonNull(value, "The value is null");
<del> return new ObservableJust<T>(value);
<add> return RxJavaPlugins.onAssembly(new ObservableJust<T>(value));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> merge(Iterable<? extends ObservableSource<? exte
<ide> */
<ide> @SuppressWarnings({ "unchecked", "rawtypes" })
<ide> public static <T> Observable<T> merge(ObservableSource<? extends ObservableSource<? extends T>> sources) {
<del> return new ObservableFlatMap(sources, Functions.identity(), false, Integer.MAX_VALUE, bufferSize());
<add> return RxJavaPlugins.onAssembly(new ObservableFlatMap(sources, Functions.identity(), false, Integer.MAX_VALUE, bufferSize()));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> merge(ObservableSource<? extends ObservableSourc
<ide> @SuppressWarnings({ "unchecked", "rawtypes" })
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Observable<T> merge(ObservableSource<? extends ObservableSource<? extends T>> sources, int maxConcurrency) {
<del> return new ObservableFlatMap(sources, Functions.identity(), false, maxConcurrency, bufferSize());
<add> return RxJavaPlugins.onAssembly(new ObservableFlatMap(sources, Functions.identity(), false, maxConcurrency, bufferSize()));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> mergeDelayError(Iterable<? extends ObservableSou
<ide> */
<ide> @SuppressWarnings({ "unchecked", "rawtypes" })
<ide> public static <T> Observable<T> mergeDelayError(ObservableSource<? extends ObservableSource<? extends T>> sources) {
<del> return new ObservableFlatMap(sources, Functions.identity(), true, Integer.MAX_VALUE, bufferSize());
<add> return RxJavaPlugins.onAssembly(new ObservableFlatMap(sources, Functions.identity(), true, Integer.MAX_VALUE, bufferSize()));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> mergeDelayError(ObservableSource<? extends Obser
<ide> @SuppressWarnings({ "unchecked", "rawtypes" })
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Observable<T> mergeDelayError(ObservableSource<? extends ObservableSource<? extends T>> sources, int maxConcurrency) {
<del> return new ObservableFlatMap(sources, Functions.identity(), true, maxConcurrency, bufferSize());
<add> return RxJavaPlugins.onAssembly(new ObservableFlatMap(sources, Functions.identity(), true, maxConcurrency, bufferSize()));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> mergeArrayDelayError(ObservableSource<? extends
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> @SuppressWarnings("unchecked")
<ide> public static <T> Observable<T> never() {
<del> return (Observable<T>) ObservableNever.INSTANCE;
<add> return RxJavaPlugins.onAssembly((Observable<T>) ObservableNever.INSTANCE);
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> never() {
<ide> public static Observable<Integer> range(final int start, final int count) {
<ide> if (count < 0) {
<ide> throw new IllegalArgumentException("count >= 0 required but it was " + count);
<del> } else
<add> }
<ide> if (count == 0) {
<ide> return empty();
<del> } else
<add> }
<ide> if (count == 1) {
<ide> return just(start);
<del> } else
<add> }
<ide> if ((long)start + (count - 1) > Integer.MAX_VALUE) {
<ide> throw new IllegalArgumentException("Integer overflow");
<ide> }
<del> return new ObservableRange(start, count);
<add> return RxJavaPlugins.onAssembly(new ObservableRange(start, count));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<Boolean> sequenceEqual(ObservableSource<? extends T
<ide> ObjectHelper.requireNonNull(p2, "p2 is null");
<ide> ObjectHelper.requireNonNull(isEqual, "isEqual is null");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new ObservableSequenceEqual<T>(p1, p2, isEqual, bufferSize);
<add> return RxJavaPlugins.onAssembly(new ObservableSequenceEqual<T>(p1, p2, isEqual, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<Boolean> sequenceEqual(ObservableSource<? extends T
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public static <T> Observable<T> switchOnNext(ObservableSource<? extends ObservableSource<? extends T>> sources, int bufferSize) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<del> return new ObservableSwitchMap(sources, Functions.identity(), bufferSize, false);
<add> return RxJavaPlugins.onAssembly(new ObservableSwitchMap(sources, Functions.identity(), bufferSize, false));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Observable<T> switchOnNextDelayError(ObservableSource<? extend
<ide> public static <T> Observable<T> switchOnNextDelayError(ObservableSource<? extends ObservableSource<? extends T>> sources, int prefetch) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<ide> verifyPositive(prefetch, "prefetch");
<del> return new ObservableSwitchMap(sources, Functions.identity(), prefetch, true);
<add> return RxJavaPlugins.onAssembly(new ObservableSwitchMap(sources, Functions.identity(), prefetch, true));
<ide> }
<ide>
<ide> /**
<ide> public static Observable<Long> timer(long delay, TimeUnit unit, Scheduler schedu
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide>
<del> return new ObservableTimer(delay, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new ObservableTimer(delay, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> * Create a Observable by wrapping a ObservableSource <em>which has to be implemented according
<del> * to the Reactive-Streams specification by handling backpressure and
<add> * to the Reactive-Streams-based Observable specification by handling
<ide> * cancellation correctly; no safeguards are provided by the Observable itself</em>.
<ide> * <dl>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> public static <T> Observable<T> unsafeCreate(ObservableSource<T> onSubscribe) {
<ide> if (onSubscribe instanceof Observable) {
<ide> throw new IllegalArgumentException("unsafeCreate(Observable) should be upgraded");
<ide> }
<del> return new ObservableFromUnsafeSource<T>(onSubscribe);
<add> return RxJavaPlugins.onAssembly(new ObservableFromUnsafeSource<T>(onSubscribe));
<ide> }
<ide>
<ide> /**
<ide> public static <T, D> Observable<T> using(Callable<? extends D> resourceSupplier,
<ide> ObjectHelper.requireNonNull(resourceSupplier, "resourceSupplier is null");
<ide> ObjectHelper.requireNonNull(sourceSupplier, "sourceSupplier is null");
<ide> ObjectHelper.requireNonNull(disposer, "disposer is null");
<del> return new ObservableUsing<T, D>(resourceSupplier, sourceSupplier, disposer, eager);
<add> return RxJavaPlugins.onAssembly(new ObservableUsing<T, D>(resourceSupplier, sourceSupplier, disposer, eager));
<ide> }
<ide>
<ide> /**
<ide> * Validate that the given value is positive or report an IllegalArgumentException with
<ide> * the parameter name.
<del> * @param bufferSize the value to validate
<add> * @param value the value to validate
<ide> * @param paramName the parameter name of the value
<ide> * @throws IllegalArgumentException if bufferSize <= 0
<ide> */
<del> private static void verifyPositive(int bufferSize, String paramName) {
<del> if (bufferSize <= 0) {
<del> throw new IllegalArgumentException(paramName + " > 0 required but it was " + bufferSize);
<add> private static void verifyPositive(int value, String paramName) {
<add> if (value <= 0) {
<add> throw new IllegalArgumentException(paramName + " > 0 required but it was " + value);
<add> }
<add> }
<add>
<add> /**
<add> * Validate that the given value is positive or report an IllegalArgumentException with
<add> * the parameter name.
<add> * @param value the value to validate
<add> * @param paramName the parameter name of the value
<add> * @throws IllegalArgumentException if bufferSize <= 0
<add> */
<add> private static void verifyPositive(long value, String paramName) {
<add> if (value <= 0L) {
<add> throw new IllegalArgumentException(paramName + " > 0 required but it was " + value);
<ide> }
<ide> }
<ide>
<ide> private static void verifyPositive(int bufferSize, String paramName) {
<ide> public static <T> Observable<T> wrap(ObservableSource<T> source) {
<ide> ObjectHelper.requireNonNull(source, "source is null");
<ide> if (source instanceof Observable) {
<del> return (Observable<T>)source;
<add> return RxJavaPlugins.onAssembly((Observable<T>)source);
<ide> }
<ide> return RxJavaPlugins.onAssembly(new ObservableFromUnsafeSource<T>(source));
<ide> }
<ide> public static <T> Observable<T> wrap(ObservableSource<T> source) {
<ide> public static <T, R> Observable<R> zip(Iterable<? extends ObservableSource<? extends T>> sources, Function<? super T[], ? extends R> zipper) {
<ide> ObjectHelper.requireNonNull(zipper, "zipper is null");
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<del> return new ObservableZip<T, R>(null, sources, zipper, bufferSize(), false);
<add> return RxJavaPlugins.onAssembly(new ObservableZip<T, R>(null, sources, zipper, bufferSize(), false));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Observable<R> zip(Iterable<? extends ObservableSource<? ext
<ide> public static <T, R> Observable<R> zip(ObservableSource<? extends ObservableSource<? extends T>> sources, final Function<? super T[], ? extends R> zipper) {
<ide> ObjectHelper.requireNonNull(zipper, "zipper is null");
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<del> return new ObservableToList(sources, 16)
<del> .flatMap(ObservableInternalHelper.zipIterable(zipper));
<add> return RxJavaPlugins.onAssembly(new ObservableToList(sources, 16)
<add> .flatMap(ObservableInternalHelper.zipIterable(zipper)));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Observable<R> zipArray(Function<? super T[], ? extends R> z
<ide> }
<ide> ObjectHelper.requireNonNull(zipper, "zipper is null");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new ObservableZip<T, R>(sources, null, zipper, bufferSize, delayError);
<add> return RxJavaPlugins.onAssembly(new ObservableZip<T, R>(sources, null, zipper, bufferSize, delayError));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Observable<R> zipIterable(Iterable<? extends ObservableSour
<ide> ObjectHelper.requireNonNull(zipper, "zipper is null");
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new ObservableZip<T, R>(null, sources, zipper, bufferSize, delayError);
<add> return RxJavaPlugins.onAssembly(new ObservableZip<T, R>(null, sources, zipper, bufferSize, delayError));
<ide> }
<ide>
<ide> // ***************************************************************************************************
<ide> public static <T, R> Observable<R> zipIterable(Iterable<? extends ObservableSour
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<Boolean> all(Predicate<? super T> predicate) {
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<del> return new ObservableAll<T>(this, predicate);
<add> return RxJavaPlugins.onAssembly(new ObservableAll<T>(this, predicate));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<Boolean> all(Predicate<? super T> predicate) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> ambWith(ObservableSource<? extends T> other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return amb(this, other);
<add> return ambArray(this, other);
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> ambWith(ObservableSource<? extends T> other) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<Boolean> any(Predicate<? super T> predicate) {
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<del> return new ObservableAny<T>(this, predicate);
<add> return RxJavaPlugins.onAssembly(new ObservableAny<T>(this, predicate));
<ide> }
<ide>
<ide> /**
<del> * Returns the first item emitted by this {@code BlockingObservable}, or throws
<add> * Returns the first item emitted by this {@code Observable}, or throws
<ide> * {@code NoSuchElementException} if it emits no items.
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Flowable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingFirst} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return the first item emitted by this {@code BlockingObservable}
<add> * @return the first item emitted by this {@code Observable}
<ide> * @throws NoSuchElementException
<del> * if this {@code BlockingObservable} emits no items
<add> * if this {@code Observable} emits no items
<ide> * @see <a href="http://reactivex.io/documentation/operators/first.html">ReactiveX documentation: First</a>
<ide> */
<ide> public final T blockingFirst() {
<ide> public final T blockingFirst() {
<ide> }
<ide>
<ide> /**
<del> * Returns the first item emitted by this {@code BlockingObservable}, or a default value if it emits no
<add> * Returns the first item emitted by this {@code Observable}, or a default value if it emits no
<ide> * items.
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Flowable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingFirst} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<ide> * @param defaultValue
<del> * a default value to return if this {@code BlockingObservable} emits no items
<del> * @return the first item emitted by this {@code BlockingObservable}, or the default value if it emits no
<add> * a default value to return if this {@code Observable} emits no items
<add> * @return the first item emitted by this {@code Observable}, or the default value if it emits no
<ide> * items
<ide> * @see <a href="http://reactivex.io/documentation/operators/first.html">ReactiveX documentation: First</a>
<ide> */
<ide> public final T blockingFirst(T defaultValue) {
<ide> }
<ide>
<ide> /**
<del> * Invokes a method on each item emitted by this {@code BlockingObservable} and blocks until the Observable
<add> * Invokes a method on each item emitted by this {@code Observable} and blocks until the Observable
<ide> * completes.
<ide> * <p>
<ide> * <em>Note:</em> This will block even if the underlying Observable is asynchronous.
<ide> public final T blockingFirst(T defaultValue) {
<ide> * <p>The difference between this method and {@link #subscribe(Consumer)} is that the {@code onNext} action
<ide> * is executed on the emission thread instead of the current thread.
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Flowable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingForEach} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<ide> * @param onNext
<del> * the {@link Consumer} to invoke for each item emitted by the {@code BlockingObservable}
<add> * the {@link Consumer} to invoke for each item emitted by the {@code Observable}
<ide> * @throws RuntimeException
<ide> * if an error occurs
<ide> * @see <a href="http://reactivex.io/documentation/operators/subscribe.html">ReactiveX documentation: Subscribe</a>
<ide> public final void blockingForEach(Consumer<? super T> onNext) {
<ide> }
<ide>
<ide> /**
<del> * Converts this {@code BlockingObservable} into an {@link Iterable}.
<add> * Converts this {@code Observable} into an {@link Iterable}.
<ide> * <p>
<ide> * <img width="640" height="315" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.toIterable.png" alt="">
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Flowable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<del> * <dd>{@code blockingITerable} does not operate by default on a particular {@link Scheduler}.</dd>
<add> * <dd>{@code blockingIterable} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return an {@link Iterable} version of this {@code BlockingObservable}
<add> * @return an {@link Iterable} version of this {@code Observable}
<ide> * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX documentation: To</a>
<ide> */
<ide> public final Iterable<T> blockingIterable() {
<ide> return blockingIterable(bufferSize());
<ide> }
<ide>
<ide> /**
<del> * Converts this {@code BlockingObservable} into an {@link Iterable}.
<add> * Converts this {@code Observable} into an {@link Iterable}.
<ide> * <p>
<ide> * <img width="640" height="315" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.toIterable.png" alt="">
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Flowable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<del> * <dd>{@code blockingFlowable} does not operate by default on a particular {@link Scheduler}.</dd>
<add> * <dd>{@code blockingIterable} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @param bufferSize the number of items to prefetch from the current Flowable
<del> * @return an {@link Iterable} version of this {@code BlockingObservable}
<add> * @param bufferSize the number of items to prefetch from the current Observable
<add> * @return an {@link Iterable} version of this {@code Observable}
<ide> * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX documentation: To</a>
<ide> */
<ide> public final Iterable<T> blockingIterable(int bufferSize) {
<ide> public final Iterable<T> blockingIterable(int bufferSize) {
<ide> }
<ide>
<ide> /**
<del> * Returns the last item emitted by this {@code BlockingObservable}, or throws
<del> * {@code NoSuchElementException} if this {@code BlockingObservable} emits no items.
<add> * Returns the last item emitted by this {@code Observable}, or throws
<add> * {@code NoSuchElementException} if this {@code Observable} emits no items.
<ide> * <p>
<ide> * <img width="640" height="315" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.last.png" alt="">
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Observable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingLast} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return the last item emitted by this {@code BlockingObservable}
<add> * @return the last item emitted by this {@code Observable}
<ide> * @throws NoSuchElementException
<del> * if this {@code BlockingObservable} emits no items
<add> * if this {@code Observable} emits no items
<ide> * @see <a href="http://reactivex.io/documentation/operators/last.html">ReactiveX documentation: Last</a>
<ide> */
<ide> public final T blockingLast() {
<ide> public final T blockingLast() {
<ide> }
<ide>
<ide> /**
<del> * Returns the last item emitted by this {@code BlockingObservable}, or a default value if it emits no
<add> * Returns the last item emitted by this {@code Observable}, or a default value if it emits no
<ide> * items.
<ide> * <p>
<ide> * <img width="640" height="310" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.lastOrDefault.png" alt="">
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Observable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingLast} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<ide> * @param defaultValue
<del> * a default value to return if this {@code BlockingObservable} emits no items
<del> * @return the last item emitted by the {@code BlockingObservable}, or the default value if it emits no
<add> * a default value to return if this {@code Observable} emits no items
<add> * @return the last item emitted by the {@code Observable}, or the default value if it emits no
<ide> * items
<ide> * @see <a href="http://reactivex.io/documentation/operators/last.html">ReactiveX documentation: Last</a>
<ide> */
<ide> public final T blockingLast(T defaultValue) {
<ide> }
<ide>
<ide> /**
<del> * Returns an {@link Iterable} that returns the latest item emitted by this {@code BlockingObservable},
<add> * Returns an {@link Iterable} that returns the latest item emitted by this {@code Observable},
<ide> * waiting if necessary for one to become available.
<ide> * <p>
<del> * If this {@code BlockingObservable} produces items faster than {@code Iterator.next} takes them,
<add> * If this {@code Observable} produces items faster than {@code Iterator.next} takes them,
<ide> * {@code onNext} events might be skipped, but {@code onError} or {@code onCompleted} events are not.
<ide> * <p>
<ide> * Note also that an {@code onNext} directly followed by {@code onCompleted} might hide the {@code onNext}
<ide> * event.
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Observable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingLatest} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return an Iterable that always returns the latest item emitted by this {@code BlockingObservable}
<add> * @return an Iterable that always returns the latest item emitted by this {@code Observable}
<ide> * @see <a href="http://reactivex.io/documentation/operators/first.html">ReactiveX documentation: First</a>
<ide> */
<ide> public final Iterable<T> blockingLatest() {
<ide> public final Iterable<T> blockingLatest() {
<ide>
<ide> /**
<ide> * Returns an {@link Iterable} that always returns the item most recently emitted by this
<del> * {@code BlockingObservable}.
<add> * {@code Observable}.
<ide> * <p>
<ide> * <img width="640" height="490" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.mostRecent.png" alt="">
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Observable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingMostRecent} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<ide> * @param initialValue
<ide> * the initial value that the {@link Iterable} sequence will yield if this
<del> * {@code BlockingObservable} has not yet emitted an item
<del> * @return an {@link Iterable} that on each iteration returns the item that this {@code BlockingObservable}
<add> * {@code Observable} has not yet emitted an item
<add> * @return an {@link Iterable} that on each iteration returns the item that this {@code Observable}
<ide> * has most recently emitted
<ide> * @see <a href="http://reactivex.io/documentation/operators/first.html">ReactiveX documentation: First</a>
<ide> */
<ide> public final Iterable<T> blockingMostRecent(T initialValue) {
<ide> }
<ide>
<ide> /**
<del> * Returns an {@link Iterable} that blocks until this {@code BlockingObservable} emits another item, then
<add> * Returns an {@link Iterable} that blocks until this {@code Observable} emits another item, then
<ide> * returns that item.
<ide> * <p>
<ide> * <img width="640" height="490" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.next.png" alt="">
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Observable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingNext} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return an {@link Iterable} that blocks upon each iteration until this {@code BlockingObservable} emits
<add> * @return an {@link Iterable} that blocks upon each iteration until this {@code Observable} emits
<ide> * a new item, whereupon the Iterable returns that item
<ide> * @see <a href="http://reactivex.io/documentation/operators/takelast.html">ReactiveX documentation: TakeLast</a>
<ide> */
<ide> public final Iterable<T> blockingNext() {
<ide> }
<ide>
<ide> /**
<del> * If this {@code BlockingObservable} completes after emitting a single item, return that item, otherwise
<add> * If this {@code Observable} completes after emitting a single item, return that item, otherwise
<ide> * throw a {@code NoSuchElementException}.
<ide> * <p>
<ide> * <img width="640" height="315" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.single.png" alt="">
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Observable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingSingle} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return the single item emitted by this {@code BlockingObservable}
<add> * @return the single item emitted by this {@code Observable}
<ide> * @see <a href="http://reactivex.io/documentation/operators/first.html">ReactiveX documentation: First</a>
<ide> */
<ide> public final T blockingSingle() {
<ide> return single().blockingFirst();
<ide> }
<ide>
<ide> /**
<del> * If this {@code BlockingObservable} completes after emitting a single item, return that item; if it emits
<add> * If this {@code Observable} completes after emitting a single item, return that item; if it emits
<ide> * more than one item, throw an {@code IllegalArgumentException}; if it emits no items, return a default
<ide> * value.
<ide> * <p>
<ide> * <img width="640" height="315" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.singleOrDefault.png" alt="">
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Observable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingSingle} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<ide> * @param defaultValue
<del> * a default value to return if this {@code BlockingObservable} emits no items
<del> * @return the single item emitted by this {@code BlockingObservable}, or the default value if it emits no
<add> * a default value to return if this {@code Observable} emits no items
<add> * @return the single item emitted by this {@code Observable}, or the default value if it emits no
<ide> * items
<ide> * @see <a href="http://reactivex.io/documentation/operators/first.html">ReactiveX documentation: First</a>
<ide> */
<ide> public final T blockingSingle(T defaultValue) {
<ide> }
<ide>
<ide> /**
<del> * Returns a {@link Future} representing the single value emitted by this {@code BlockingObservable}.
<add> * Returns a {@link Future} representing the single value emitted by this {@code Observable}.
<ide> * <p>
<ide> * If the {@link Observable} emits more than one item, {@link java.util.concurrent.Future} will receive an
<ide> * {@link java.lang.IllegalArgumentException}. If the {@link Observable} is empty, {@link java.util.concurrent.Future}
<ide> * will receive an {@link java.util.NoSuchElementException}.
<ide> * <p>
<del> * If the {@code BlockingObservable} may emit more than one item, use {@code Observable.toList().toBlocking().toFuture()}.
<add> * If the {@code Observable} may emit more than one item, use {@code Observable.toList().toBlocking().toFuture()}.
<ide> * <p>
<ide> * <img width="640" height="395" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/B.toFuture.png" alt="">
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Observable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code toFuture} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> *
<del> * @return a {@link Future} that expects a single item to be emitted by this {@code BlockingObservable}
<add> * @return a {@link Future} that expects a single item to be emitted by this {@code Observable}
<ide> * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX documentation: To</a>
<ide> */
<ide> public final Future<T> toFuture() {
<ide> public final Future<T> toFuture() {
<ide> /**
<ide> * Runs the source observable to a terminal event, ignoring any values and rethrowing any exception.
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Observable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingSubscribe} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> public final void blockingSubscribe() {
<ide> /**
<ide> * Subscribes to the source and calls the given callbacks <strong>on the current thread</strong>.
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Observable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingSubscribe} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> public final void blockingSubscribe(Consumer<? super T> onNext) {
<ide> /**
<ide> * Subscribes to the source and calls the given callbacks <strong>on the current thread</strong>.
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Observable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingSubscribe} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> public final void blockingSubscribe(Consumer<? super T> onNext, Consumer<? super
<ide> /**
<ide> * Subscribes to the source and calls the given callbacks <strong>on the current thread</strong>.
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source {@code Observable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingSubscribe} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> public final void blockingSubscribe(Consumer<? super T> onNext, Consumer<? super
<ide> * Subscribes to the source and calls the Observer methods <strong>on the current thread</strong>.
<ide> * <p>
<ide> * <dl>
<del> * <dt><b>Backpressure:</b></dt>
<del> * <dd>The operator consumes the source
<del> * {@code Observable} in an unbounded manner
<del> * (i.e., no backpressure applied to it).</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code blockingSubscribe} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<del> * The unsubscription and backpressure is composed through.
<add> * The unsubscription is composed through.
<ide> * @param subscriber the subscriber to forward events and calls to in the current thread
<ide> * @since 2.0
<ide> */
<ide> public final <U extends Collection<? super T>> Observable<U> buffer(int count, i
<ide> throw new IllegalArgumentException("skip > 0 required but it was " + count);
<ide> }
<ide> ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null");
<del> return new ObservableBuffer<T, U>(this, count, skip, bufferSupplier);
<add> return RxJavaPlugins.onAssembly(new ObservableBuffer<T, U>(this, count, skip, bufferSupplier));
<ide> }
<ide>
<ide> /**
<ide> public final <U extends Collection<? super T>> Observable<U> buffer(long timespa
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide> ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null");
<del> return new ObservableBufferTimed<T, U>(this, timespan, timeskip, unit, scheduler, bufferSupplier, Integer.MAX_VALUE, false);
<add> return RxJavaPlugins.onAssembly(new ObservableBufferTimed<T, U>(this, timespan, timeskip, unit, scheduler, bufferSupplier, Integer.MAX_VALUE, false));
<ide> }
<ide>
<ide> /**
<ide> public final <U extends Collection<? super T>> Observable<U> buffer(
<ide> if (count <= 0) {
<ide> throw new IllegalArgumentException("count > 0 required but it was " + count);
<ide> }
<del> return new ObservableBufferTimed<T, U>(this, timespan, timespan, unit, scheduler, bufferSupplier, count, restartTimerOnMaxSize);
<add> return RxJavaPlugins.onAssembly(new ObservableBufferTimed<T, U>(this, timespan, timespan, unit, scheduler, bufferSupplier, count, restartTimerOnMaxSize));
<ide> }
<ide>
<ide> /**
<ide> public final <TOpening, TClosing, U extends Collection<? super T>> Observable<U>
<ide> ObjectHelper.requireNonNull(bufferOpenings, "bufferOpenings is null");
<ide> ObjectHelper.requireNonNull(bufferClosingSelector, "bufferClosingSelector is null");
<ide> ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null");
<del> return new ObservableBufferBoundary<T, U, TOpening, TClosing>(this, bufferOpenings, bufferClosingSelector, bufferSupplier);
<add> return RxJavaPlugins.onAssembly(new ObservableBufferBoundary<T, U, TOpening, TClosing>(this, bufferOpenings, bufferClosingSelector, bufferSupplier));
<ide> }
<ide>
<ide> /**
<ide> public final <B> Observable<List<T>> buffer(ObservableSource<B> boundary, final
<ide> public final <B, U extends Collection<? super T>> Observable<U> buffer(ObservableSource<B> boundary, Callable<U> bufferSupplier) {
<ide> ObjectHelper.requireNonNull(boundary, "boundary is null");
<ide> ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null");
<del> return new ObservableBufferExactBoundary<T, U, B>(this, boundary, bufferSupplier);
<add> return RxJavaPlugins.onAssembly(new ObservableBufferExactBoundary<T, U, B>(this, boundary, bufferSupplier));
<ide> }
<ide>
<ide> /**
<ide> public final <B> Observable<List<T>> buffer(Callable<? extends ObservableSource<
<ide> public final <B, U extends Collection<? super T>> Observable<U> buffer(Callable<? extends ObservableSource<B>> boundarySupplier, Callable<U> bufferSupplier) {
<ide> ObjectHelper.requireNonNull(boundarySupplier, "boundarySupplier is null");
<ide> ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null");
<del> return new ObservableBufferBoundarySupplier<T, U, B>(this, boundarySupplier, bufferSupplier);
<add> return RxJavaPlugins.onAssembly(new ObservableBufferBoundarySupplier<T, U, B>(this, boundarySupplier, bufferSupplier));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Observable<U> cast(final Class<U> clazz) {
<ide> public final <U> Observable<U> collect(Callable<? extends U> initialValueSupplier, BiConsumer<? super U, ? super T> collector) {
<ide> ObjectHelper.requireNonNull(initialValueSupplier, "initialValueSupplier is null");
<ide> ObjectHelper.requireNonNull(collector, "collector is null");
<del> return new ObservableCollect<T, U>(this, initialValueSupplier, collector);
<add> return RxJavaPlugins.onAssembly(new ObservableCollect<T, U>(this, initialValueSupplier, collector));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> concatMap(Function<? super T, ? extends Observabl
<ide> }
<ide> return ObservableScalarXMap.scalarXMap(v, mapper);
<ide> }
<del> return new ObservableConcatMap<T, R>(this, mapper, prefetch, ErrorMode.IMMEDIATE);
<add> return RxJavaPlugins.onAssembly(new ObservableConcatMap<T, R>(this, mapper, prefetch, ErrorMode.IMMEDIATE));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> concatMapDelayError(Function<? super T, ? extends
<ide> }
<ide> return ObservableScalarXMap.scalarXMap(v, mapper);
<ide> }
<del> return new ObservableConcatMap<T, R>(this, mapper, prefetch, tillTheEnd ? ErrorMode.END : ErrorMode.BOUNDARY);
<add> return RxJavaPlugins.onAssembly(new ObservableConcatMap<T, R>(this, mapper, prefetch, tillTheEnd ? ErrorMode.END : ErrorMode.BOUNDARY));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> concatMapEager(Function<? super T, ? extends Obse
<ide> ObjectHelper.requireNonNull(mapper, "mapper is null");
<ide> verifyPositive(maxConcurrency, "maxConcurrency");
<ide> verifyPositive(prefetch, "prefetch");
<del> return new ObservableConcatMapEager<T, R>(this, mapper, ErrorMode.IMMEDIATE, maxConcurrency, prefetch);
<add> return RxJavaPlugins.onAssembly(new ObservableConcatMapEager<T, R>(this, mapper, ErrorMode.IMMEDIATE, maxConcurrency, prefetch));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> concatMapEagerDelayError(Function<? super T, ? ex
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <R> Observable<R> concatMapEagerDelayError(Function<? super T, ? extends ObservableSource<? extends R>> mapper,
<ide> int maxConcurrency, int prefetch, boolean tillTheEnd) {
<del> return new ObservableConcatMapEager<T, R>(this, mapper, tillTheEnd ? ErrorMode.END : ErrorMode.BOUNDARY, maxConcurrency, prefetch);
<add> return RxJavaPlugins.onAssembly(new ObservableConcatMapEager<T, R>(this, mapper, tillTheEnd ? ErrorMode.END : ErrorMode.BOUNDARY, maxConcurrency, prefetch));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<Boolean> contains(final Object element) {
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<Long> count() {
<del> return new ObservableCount<T>(this);
<add> return RxJavaPlugins.onAssembly(new ObservableCount<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<Long> count() {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <U> Observable<T> debounce(Function<? super T, ? extends ObservableSource<U>> debounceSelector) {
<ide> ObjectHelper.requireNonNull(debounceSelector, "debounceSelector is null");
<del> return new ObservableDebounce<T, U>(this, debounceSelector);
<add> return RxJavaPlugins.onAssembly(new ObservableDebounce<T, U>(this, debounceSelector));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> debounce(long timeout, TimeUnit unit) {
<ide> public final Observable<T> debounce(long timeout, TimeUnit unit, Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new ObservableDebounceTimed<T>(this, timeout, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new ObservableDebounceTimed<T>(this, timeout, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> delay(long delay, TimeUnit unit, Scheduler scheduler,
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide>
<del> return new ObservableDelay<T>(this, delay, unit, scheduler, delayError);
<add> return RxJavaPlugins.onAssembly(new ObservableDelay<T>(this, delay, unit, scheduler, delayError));
<ide> }
<ide>
<ide> /**
<ide> public final <U, V> Observable<T> delay(ObservableSource<U> subscriptionDelay,
<ide> */
<ide> public final <U> Observable<T> delaySubscription(ObservableSource<U> other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return new ObservableDelaySubscriptionOther<T, U>(this, other);
<add> return RxJavaPlugins.onAssembly(new ObservableDelaySubscriptionOther<T, U>(this, other));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> delaySubscription(long delay, TimeUnit unit, Schedule
<ide> public final <T2> Observable<T2> dematerialize() {
<ide> @SuppressWarnings("unchecked")
<ide> Observable<Notification<T2>> m = (Observable<Notification<T2>>)this;
<del> return new ObservableDematerialize<T2>(m);
<add> return RxJavaPlugins.onAssembly(new ObservableDematerialize<T2>(m));
<ide> }
<ide>
<ide> /**
<ide> public final <K> Observable<T> distinctUntilChanged(Function<? super T, K> keySe
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> distinctUntilChanged(BiPredicate<? super T, ? super T> comparer) {
<ide> ObjectHelper.requireNonNull(comparer, "comparer is null");
<del> return new ObservableDistinctUntilChanged<T>(this, comparer);
<add> return RxJavaPlugins.onAssembly(new ObservableDistinctUntilChanged<T>(this, comparer));
<ide> }
<ide>
<ide> /**
<ide> private Observable<T> doOnEach(Consumer<? super T> onNext, Consumer<? super Thro
<ide> ObjectHelper.requireNonNull(onError, "onError is null");
<ide> ObjectHelper.requireNonNull(onComplete, "onComplete is null");
<ide> ObjectHelper.requireNonNull(onAfterTerminate, "onAfterTerminate is null");
<del> return new ObservableDoOnEach<T>(this, onNext, onError, onComplete, onAfterTerminate);
<add> return RxJavaPlugins.onAssembly(new ObservableDoOnEach<T>(this, onNext, onError, onComplete, onAfterTerminate));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> doOnError(Consumer<? super Throwable> onError) {
<ide> public final Observable<T> doOnLifecycle(final Consumer<? super Disposable> onSubscribe, final Action onCancel) {
<ide> ObjectHelper.requireNonNull(onSubscribe, "onSubscribe is null");
<ide> ObjectHelper.requireNonNull(onCancel, "onCancel is null");
<del> return new ObservableDoOnLifecycle<T>(this, onSubscribe, onCancel);
<add> return RxJavaPlugins.onAssembly(new ObservableDoOnLifecycle<T>(this, onSubscribe, onCancel));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> elementAt(long index) {
<ide> if (index < 0) {
<ide> throw new IndexOutOfBoundsException("index >= 0 required but it was " + index);
<ide> }
<del> return new ObservableElementAt<T>(this, index, null);
<add> return RxJavaPlugins.onAssembly(new ObservableElementAt<T>(this, index, null));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> elementAt(long index, T defaultValue) {
<ide> throw new IndexOutOfBoundsException("index >= 0 required but it was " + index);
<ide> }
<ide> ObjectHelper.requireNonNull(defaultValue, "defaultValue is null");
<del> return new ObservableElementAt<T>(this, index, defaultValue);
<add> return RxJavaPlugins.onAssembly(new ObservableElementAt<T>(this, index, defaultValue));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> elementAt(long index, T defaultValue) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> filter(Predicate<? super T> predicate) {
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<del> return new ObservableFilter<T>(this, predicate);
<add> return RxJavaPlugins.onAssembly(new ObservableFilter<T>(this, predicate));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> flatMap(Function<? super T, ? extends ObservableS
<ide> }
<ide> return ObservableScalarXMap.scalarXMap(v, mapper);
<ide> }
<del> return new ObservableFlatMap<T, R>(this, mapper, delayErrors, maxConcurrency, bufferSize);
<add> return RxJavaPlugins.onAssembly(new ObservableFlatMap<T, R>(this, mapper, delayErrors, maxConcurrency, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> flatMap(Function<? super T, ? extends ObservableS
<ide> * <p>
<ide> * <img width="640" height="390" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/mergeMap.r.png" alt="">
<ide> * <dl>
<del> * <dd>The operator honors backpressure from downstream. The outer {@code ObservableSource} is consumed
<del> * in unbounded mode (i.e., no backpressure is applied to it). The inner {@code ObservableSource}s are expected to honor
<del> * backpressure; if violated, the operator <em>may</em> signal {@code MissingBackpressureException}.</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code flatMap} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> public final <U, R> Observable<R> flatMap(Function<? super T, ? extends Observab
<ide> * <p>
<ide> * <img width="640" height="390" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/mergeMap.r.png" alt="">
<ide> * <dl>
<del> * <dd>The operator honors backpressure from downstream. The outer {@code ObservableSource} is consumed
<del> * in unbounded mode (i.e., no backpressure is applied to it). The inner {@code ObservableSource}s are expected to honor
<del> * backpressure; if violated, the operator <em>may</em> signal {@code MissingBackpressureException}.</dd>
<ide> * <dt><b>Scheduler:</b></dt>
<ide> * <dd>{@code flatMap} does not operate by default on a particular {@link Scheduler}.</dd>
<ide> * </dl>
<ide> public final <K, V> Observable<GroupedObservable<K, V>> groupBy(Function<? super
<ide> ObjectHelper.requireNonNull(valueSelector, "valueSelector is null");
<ide> verifyPositive(bufferSize, "bufferSize");
<ide>
<del> return new ObservableGroupBy<T, K, V>(this, keySelector, valueSelector, bufferSize, delayError);
<add> return RxJavaPlugins.onAssembly(new ObservableGroupBy<T, K, V>(this, keySelector, valueSelector, bufferSize, delayError));
<ide> }
<ide>
<ide> /**
<ide> public final <TRight, TLeftEnd, TRightEnd, R> Observable<R> groupJoin(
<ide> Function<? super TRight, ? extends ObservableSource<TRightEnd>> rightEnd,
<ide> BiFunction<? super T, ? super Observable<TRight>, ? extends R> resultSelector
<ide> ) {
<del> return new ObservableGroupJoin<T, TRight, TLeftEnd, TRightEnd, R>(
<del> this, other, leftEnd, rightEnd, resultSelector);
<add> return RxJavaPlugins.onAssembly(new ObservableGroupJoin<T, TRight, TLeftEnd, TRightEnd, R>(
<add> this, other, leftEnd, rightEnd, resultSelector));
<ide> }
<ide>
<ide> /**
<ide> public final <TRight, TLeftEnd, TRightEnd, R> Observable<R> groupJoin(
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> hide() {
<del> return new ObservableHide<T>(this);
<add> return RxJavaPlugins.onAssembly(new ObservableHide<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> hide() {
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> ignoreElements() {
<del> return new ObservableIgnoreElements<T>(this);
<add> return RxJavaPlugins.onAssembly(new ObservableIgnoreElements<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final <TRight, TLeftEnd, TRightEnd, R> Observable<R> join(
<ide> Function<? super TRight, ? extends ObservableSource<TRightEnd>> rightEnd,
<ide> BiFunction<? super T, ? super TRight, ? extends R> resultSelector
<ide> ) {
<del> return new ObservableJoin<T, TRight, TLeftEnd, TRightEnd, R>(
<del> this, other, leftEnd, rightEnd, resultSelector);
<add> return RxJavaPlugins.onAssembly(new ObservableJoin<T, TRight, TLeftEnd, TRightEnd, R>(
<add> this, other, leftEnd, rightEnd, resultSelector));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> last(T defaultValue) {
<ide> */
<ide> public final <R> Observable<R> lift(ObservableOperator<? extends R, ? super T> lifter) {
<ide> ObjectHelper.requireNonNull(lifter, "onLift is null");
<del> return new ObservableLift<R, T>(this, lifter);
<add> return RxJavaPlugins.onAssembly(new ObservableLift<R, T>(this, lifter));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> lift(ObservableOperator<? extends R, ? super T> l
<ide> */
<ide> public final <R> Observable<R> map(Function<? super T, ? extends R> mapper) {
<ide> ObjectHelper.requireNonNull(mapper, "mapper is null");
<del> return new ObservableMap<T, R>(this, mapper);
<add> return RxJavaPlugins.onAssembly(new ObservableMap<T, R>(this, mapper));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> map(Function<? super T, ? extends R> mapper) {
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<Notification<T>> materialize() {
<del> return new ObservableMaterialize<T>(this);
<add> return RxJavaPlugins.onAssembly(new ObservableMaterialize<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> observeOn(Scheduler scheduler, boolean delayError) {
<ide> public final Observable<T> observeOn(Scheduler scheduler, boolean delayError, int bufferSize) {
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new ObservableObserveOn<T>(this, scheduler, delayError, bufferSize);
<add> return RxJavaPlugins.onAssembly(new ObservableObserveOn<T>(this, scheduler, delayError, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Observable<U> ofType(final Class<U> clazz) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> onErrorResumeNext(Function<? super Throwable, ? extends ObservableSource<? extends T>> resumeFunction) {
<ide> ObjectHelper.requireNonNull(resumeFunction, "resumeFunction is null");
<del> return new ObservableOnErrorNext<T>(this, resumeFunction, false);
<add> return RxJavaPlugins.onAssembly(new ObservableOnErrorNext<T>(this, resumeFunction, false));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> onErrorResumeNext(final ObservableSource<? extends T>
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> onErrorReturn(Function<? super Throwable, ? extends T> valueSupplier) {
<ide> ObjectHelper.requireNonNull(valueSupplier, "valueSupplier is null");
<del> return new ObservableOnErrorReturn<T>(this, valueSupplier);
<add> return RxJavaPlugins.onAssembly(new ObservableOnErrorReturn<T>(this, valueSupplier));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> onErrorReturnValue(final T value) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> onExceptionResumeNext(final ObservableSource<? extends T> next) {
<ide> ObjectHelper.requireNonNull(next, "next is null");
<del> return new ObservableOnErrorNext<T>(this, Functions.justFunction(next), true);
<add> return RxJavaPlugins.onAssembly(new ObservableOnErrorNext<T>(this, Functions.justFunction(next), true));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> onExceptionResumeNext(final ObservableSource<? extend
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> onTerminateDetach() {
<del> return new ObservableDetach<T>(this);
<add> return RxJavaPlugins.onAssembly(new ObservableDetach<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> repeat(long count) {
<ide> if (count == 0) {
<ide> return empty();
<ide> }
<del> return new ObservableRepeat<T>(this, count);
<add> return RxJavaPlugins.onAssembly(new ObservableRepeat<T>(this, count));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> repeat(long count) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> repeatUntil(BooleanSupplier stop) {
<ide> ObjectHelper.requireNonNull(stop, "stop is null");
<del> return new ObservableRepeatUntil<T>(this, stop);
<add> return RxJavaPlugins.onAssembly(new ObservableRepeatUntil<T>(this, stop));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> repeatUntil(BooleanSupplier stop) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> repeatWhen(final Function<? super Observable<Object>, ? extends ObservableSource<?>> handler) {
<ide> ObjectHelper.requireNonNull(handler, "handler is null");
<del> return new ObservableRedo<T>(this, ObservableInternalHelper.repeatWhenHandler(handler));
<add> return RxJavaPlugins.onAssembly(new ObservableRedo<T>(this, ObservableInternalHelper.repeatWhenHandler(handler)));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> retry() {
<ide> public final Observable<T> retry(BiPredicate<? super Integer, ? super Throwable> predicate) {
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<ide>
<del> return new ObservableRetryBiPredicate<T>(this, predicate);
<add> return RxJavaPlugins.onAssembly(new ObservableRetryBiPredicate<T>(this, predicate));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> retry(long times, Predicate<? super Throwable> predic
<ide> }
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<ide>
<del> return new ObservableRetryPredicate<T>(this, times, predicate);
<add> return RxJavaPlugins.onAssembly(new ObservableRetryPredicate<T>(this, times, predicate));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> retryUntil(final BooleanSupplier stop) {
<ide> public final Observable<T> retryWhen(
<ide> final Function<? super Observable<? extends Throwable>, ? extends ObservableSource<?>> handler) {
<ide> ObjectHelper.requireNonNull(handler, "handler is null");
<del> return new ObservableRedo<T>(this, ObservableInternalHelper.retryWhenHandler(handler));
<add> return RxJavaPlugins.onAssembly(new ObservableRedo<T>(this, ObservableInternalHelper.retryWhenHandler(handler)));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> sample(long period, TimeUnit unit) {
<ide> public final Observable<T> sample(long period, TimeUnit unit, Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new ObservableSampleTimed<T>(this, period, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new ObservableSampleTimed<T>(this, period, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> sample(long period, TimeUnit unit, Scheduler schedule
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <U> Observable<T> sample(ObservableSource<U> sampler) {
<ide> ObjectHelper.requireNonNull(sampler, "sampler is null");
<del> return new ObservableSampleWithObservable<T>(this, sampler);
<add> return RxJavaPlugins.onAssembly(new ObservableSampleWithObservable<T>(this, sampler));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Observable<T> sample(ObservableSource<U> sampler) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> scan(BiFunction<T, T, T> accumulator) {
<ide> ObjectHelper.requireNonNull(accumulator, "accumulator is null");
<del> return new ObservableScan<T>(this, accumulator);
<add> return RxJavaPlugins.onAssembly(new ObservableScan<T>(this, accumulator));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> scan(final R initialValue, BiFunction<R, ? super
<ide> public final <R> Observable<R> scanWith(Callable<R> seedSupplier, BiFunction<R, ? super T, R> accumulator) {
<ide> ObjectHelper.requireNonNull(seedSupplier, "seedSupplier is null");
<ide> ObjectHelper.requireNonNull(accumulator, "accumulator is null");
<del> return new ObservableScanSeed<T, R>(this, seedSupplier, accumulator);
<add> return RxJavaPlugins.onAssembly(new ObservableScanSeed<T, R>(this, seedSupplier, accumulator));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> scanWith(Callable<R> seedSupplier, BiFunction<R,
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> serialize() {
<del> return new ObservableSerialized<T>(this);
<add> return RxJavaPlugins.onAssembly(new ObservableSerialized<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> share() {
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> single() {
<del> return new ObservableSingle<T>(this, null);
<add> return RxJavaPlugins.onAssembly(new ObservableSingle<T>(this, null));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> single() {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> single(T defaultValue) {
<ide> ObjectHelper.requireNonNull(defaultValue, "defaultValue is null");
<del> return new ObservableSingle<T>(this, defaultValue);
<add> return RxJavaPlugins.onAssembly(new ObservableSingle<T>(this, defaultValue));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> single(T defaultValue) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> skip(long count) {
<ide> if (count <= 0) {
<del> return this;
<add> return RxJavaPlugins.onAssembly(this);
<ide> }
<del> return new ObservableSkip<T>(this, count);
<add> return RxJavaPlugins.onAssembly(new ObservableSkip<T>(this, count));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> skip(long time, TimeUnit unit, Scheduler scheduler) {
<ide> public final Observable<T> skipLast(int count) {
<ide> if (count < 0) {
<ide> throw new IndexOutOfBoundsException("count >= 0 required but it was " + count);
<del> } else
<del> if (count == 0) {
<del> return this;
<del> }
<del> return new ObservableSkipLast<T>(this, count);
<add> }
<add> if (count == 0) {
<add> return RxJavaPlugins.onAssembly(this);
<add> }
<add> return RxJavaPlugins.onAssembly(new ObservableSkipLast<T>(this, count));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> skipLast(long time, TimeUnit unit, Scheduler schedule
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> // the internal buffer holds pairs of (timestamp, value) so double the default buffer size
<add> // the internal buffer holds pairs of (timestamp, value) so double the default buffer size
<ide> int s = bufferSize << 1;
<del> return new ObservableSkipLastTimed<T>(this, time, unit, scheduler, s, delayError);
<add> return RxJavaPlugins.onAssembly(new ObservableSkipLastTimed<T>(this, time, unit, scheduler, s, delayError));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> skipLast(long time, TimeUnit unit, Scheduler schedule
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <U> Observable<T> skipUntil(ObservableSource<U> other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return new ObservableSkipUntil<T, U>(this, other);
<add> return RxJavaPlugins.onAssembly(new ObservableSkipUntil<T, U>(this, other));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Observable<T> skipUntil(ObservableSource<U> other) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> skipWhile(Predicate<? super T> predicate) {
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<del> return new ObservableSkipWhile<T>(this, predicate);
<add> return RxJavaPlugins.onAssembly(new ObservableSkipWhile<T>(this, predicate));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> startWith(T value) {
<ide> public final Observable<T> startWithArray(T... values) {
<ide> Observable<T> fromArray = fromArray(values);
<ide> if (fromArray == empty()) {
<del> return this;
<add> return RxJavaPlugins.onAssembly(this);
<ide> }
<ide> return concatArray(fromArray, this);
<ide> }
<ide> public final void subscribe(Observer<? super T> observer) {
<ide> @SchedulerSupport(SchedulerSupport.CUSTOM)
<ide> public final Observable<T> subscribeOn(Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new ObservableSubscribeOn<T>(this, scheduler);
<add> return RxJavaPlugins.onAssembly(new ObservableSubscribeOn<T>(this, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> subscribeOn(Scheduler scheduler) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> switchIfEmpty(ObservableSource<? extends T> other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return new ObservableSwitchIfEmpty<T>(this, other);
<add> return RxJavaPlugins.onAssembly(new ObservableSwitchIfEmpty<T>(this, other));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> switchMap(Function<? super T, ? extends Observabl
<ide> }
<ide> return ObservableScalarXMap.scalarXMap(v, mapper);
<ide> }
<del> return new ObservableSwitchMap<T, R>(this, mapper, bufferSize, false);
<add> return RxJavaPlugins.onAssembly(new ObservableSwitchMap<T, R>(this, mapper, bufferSize, false));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> switchMapDelayError(Function<? super T, ? extends
<ide> }
<ide> return ObservableScalarXMap.scalarXMap(v, mapper);
<ide> }
<del> return new ObservableSwitchMap<T, R>(this, mapper, bufferSize, true);
<add> return RxJavaPlugins.onAssembly(new ObservableSwitchMap<T, R>(this, mapper, bufferSize, true));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> take(long count) {
<ide> if (count < 0) {
<ide> throw new IllegalArgumentException("count >= required but it was " + count);
<ide> }
<del> return new ObservableTake<T>(this, count);
<add> return RxJavaPlugins.onAssembly(new ObservableTake<T>(this, count));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> takeLast(int count) {
<ide> return ignoreElements();
<ide> } else
<ide> if (count == 1) {
<del> return new ObservableTakeLastOne<T>(this);
<add> return RxJavaPlugins.onAssembly(new ObservableTakeLastOne<T>(this));
<ide> }
<del> return new ObservableTakeLast<T>(this, count);
<add> return RxJavaPlugins.onAssembly(new ObservableTakeLast<T>(this, count));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> takeLast(long count, long time, TimeUnit unit, Schedu
<ide> if (count < 0) {
<ide> throw new IndexOutOfBoundsException("count >= 0 required but it was " + count);
<ide> }
<del> return new ObservableTakeLastTimed<T>(this, count, time, unit, scheduler, bufferSize, delayError);
<add> return RxJavaPlugins.onAssembly(new ObservableTakeLastTimed<T>(this, count, time, unit, scheduler, bufferSize, delayError));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> takeLast(long time, TimeUnit unit, Scheduler schedule
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <U> Observable<T> takeUntil(ObservableSource<U> other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return new ObservableTakeUntil<T, U>(this, other);
<add> return RxJavaPlugins.onAssembly(new ObservableTakeUntil<T, U>(this, other));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Observable<T> takeUntil(ObservableSource<U> other) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> takeUntil(Predicate<? super T> stopPredicate) {
<ide> ObjectHelper.requireNonNull(stopPredicate, "predicate is null");
<del> return new ObservableTakeUntilPredicate<T>(this, stopPredicate);
<add> return RxJavaPlugins.onAssembly(new ObservableTakeUntilPredicate<T>(this, stopPredicate));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> takeUntil(Predicate<? super T> stopPredicate) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<T> takeWhile(Predicate<? super T> predicate) {
<ide> ObjectHelper.requireNonNull(predicate, "predicate is null");
<del> return new ObservableTakeWhile<T>(this, predicate);
<add> return RxJavaPlugins.onAssembly(new ObservableTakeWhile<T>(this, predicate));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<T> throttleFirst(long windowDuration, TimeUnit unit) {
<ide> public final Observable<T> throttleFirst(long skipDuration, TimeUnit unit, Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new ObservableThrottleFirstTimed<T>(this, skipDuration, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new ObservableThrottleFirstTimed<T>(this, skipDuration, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<Timed<T>> timeInterval(TimeUnit unit) {
<ide> public final Observable<Timed<T>> timeInterval(TimeUnit unit, Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new ObservableTimeInterval<T>(this, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new ObservableTimeInterval<T>(this, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> private Observable<T> timeout0(long timeout, TimeUnit timeUnit, ObservableSource
<ide> Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(timeUnit, "timeUnit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new ObservableTimeoutTimed<T>(this, timeout, timeUnit, scheduler, other);
<add> return RxJavaPlugins.onAssembly(new ObservableTimeoutTimed<T>(this, timeout, timeUnit, scheduler, other));
<ide> }
<ide>
<ide> private <U, V> Observable<T> timeout0(
<ide> Callable<? extends ObservableSource<U>> firstTimeoutSelector,
<ide> Function<? super T, ? extends ObservableSource<V>> timeoutSelector,
<ide> ObservableSource<? extends T> other) {
<ide> ObjectHelper.requireNonNull(timeoutSelector, "timeoutSelector is null");
<del> return new ObservableTimeout<T, U, V>(this, firstTimeoutSelector, timeoutSelector, other);
<add> return RxJavaPlugins.onAssembly(new ObservableTimeout<T, U, V>(this, firstTimeoutSelector, timeoutSelector, other));
<ide> }
<ide>
<ide> /**
<ide> public final <R> R to(Function<? super Observable<T>, R> converter) {
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Completable toCompletable() {
<del> return new CompletableFromObservable<T>(this);
<add> return RxJavaPlugins.onAssembly(new CompletableFromObservable<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<List<T>> toList(final int capacityHint) {
<ide> if (capacityHint <= 0) {
<ide> throw new IllegalArgumentException("capacityHint > 0 required but it was " + capacityHint);
<ide> }
<del> return new ObservableToList<T, List<T>>(this, capacityHint);
<add> return RxJavaPlugins.onAssembly(new ObservableToList<T, List<T>>(this, capacityHint));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<List<T>> toList(final int capacityHint) {
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <U extends Collection<? super T>> Observable<U> toList(Callable<U> collectionSupplier) {
<ide> ObjectHelper.requireNonNull(collectionSupplier, "collectionSupplier is null");
<del> return new ObservableToList<T, U>(this, collectionSupplier);
<add> return RxJavaPlugins.onAssembly(new ObservableToList<T, U>(this, collectionSupplier));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> toFlowable(BackpressureStrategy strategy) {
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Single<T> toSingle() {
<del> return new SingleFromObservable<T>(this);
<add> return RxJavaPlugins.onAssembly(new SingleFromObservable<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<List<T>> toSortedList(int capacityHint) {
<ide> @SchedulerSupport(SchedulerSupport.CUSTOM)
<ide> public final Observable<T> unsubscribeOn(Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new ObservableUnsubscribeOn<T>(this, scheduler);
<add> return RxJavaPlugins.onAssembly(new ObservableUnsubscribeOn<T>(this, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<Observable<T>> window(long count, long skip) {
<ide> */
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final Observable<Observable<T>> window(long count, long skip, int bufferSize) {
<del> if (skip <= 0) {
<del> throw new IllegalArgumentException("skip > 0 required but it was " + skip);
<del> }
<del> if (count <= 0) {
<del> throw new IllegalArgumentException("count > 0 required but it was " + count);
<del> }
<add> verifyPositive(count, "count");
<add> verifyPositive(skip, "skip");
<ide> verifyPositive(bufferSize, "bufferSize");
<del> return new ObservableWindow<T>(this, count, skip, bufferSize);
<add> return RxJavaPlugins.onAssembly(new ObservableWindow<T>(this, count, skip, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<Observable<T>> window(long timespan, long timeskip, Time
<ide> verifyPositive(bufferSize, "bufferSize");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<del> return new ObservableWindowTimed<T>(this, timespan, timeskip, unit, scheduler, Long.MAX_VALUE, bufferSize, false);
<add> return RxJavaPlugins.onAssembly(new ObservableWindowTimed<T>(this, timespan, timeskip, unit, scheduler, Long.MAX_VALUE, bufferSize, false));
<ide> }
<ide>
<ide> /**
<ide> public final Observable<Observable<T>> window(
<ide> if (count <= 0) {
<ide> throw new IllegalArgumentException("count > 0 required but it was " + count);
<ide> }
<del> return new ObservableWindowTimed<T>(this, timespan, timespan, unit, scheduler, count, bufferSize, restart);
<add> return RxJavaPlugins.onAssembly(new ObservableWindowTimed<T>(this, timespan, timespan, unit, scheduler, count, bufferSize, restart));
<ide> }
<ide>
<ide> /**
<ide> public final <B> Observable<Observable<T>> window(ObservableSource<B> boundary)
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <B> Observable<Observable<T>> window(ObservableSource<B> boundary, int bufferSize) {
<ide> ObjectHelper.requireNonNull(boundary, "boundary is null");
<del> return new ObservableWindowBoundary<T, B>(this, boundary, bufferSize);
<add> return RxJavaPlugins.onAssembly(new ObservableWindowBoundary<T, B>(this, boundary, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public final <U, V> Observable<Observable<T>> window(
<ide> Function<? super U, ? extends ObservableSource<V>> windowClose, int bufferSize) {
<ide> ObjectHelper.requireNonNull(windowOpen, "windowOpen is null");
<ide> ObjectHelper.requireNonNull(windowClose, "windowClose is null");
<del> return new ObservableWindowBoundarySelector<T, U, V>(this, windowOpen, windowClose, bufferSize);
<add> return RxJavaPlugins.onAssembly(new ObservableWindowBoundarySelector<T, U, V>(this, windowOpen, windowClose, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public final <B> Observable<Observable<T>> window(Callable<? extends ObservableS
<ide> @SchedulerSupport(SchedulerSupport.NONE)
<ide> public final <B> Observable<Observable<T>> window(Callable<? extends ObservableSource<B>> boundary, int bufferSize) {
<ide> ObjectHelper.requireNonNull(boundary, "boundary is null");
<del> return new ObservableWindowBoundarySupplier<T, B>(this, boundary, bufferSize);
<add> return RxJavaPlugins.onAssembly(new ObservableWindowBoundarySupplier<T, B>(this, boundary, bufferSize));
<ide> }
<ide>
<ide> /**
<ide> public final <U, R> Observable<R> withLatestFrom(ObservableSource<? extends U> o
<ide> ObjectHelper.requireNonNull(other, "other is null");
<ide> ObjectHelper.requireNonNull(combiner, "combiner is null");
<ide>
<del> return new ObservableWithLatestFrom<T, U, R>(this, combiner, other);
<add> return RxJavaPlugins.onAssembly(new ObservableWithLatestFrom<T, U, R>(this, combiner, other));
<ide> }
<ide>
<ide> /**
<ide> public final <T1, T2, T3, T4, R> Observable<R> withLatestFrom(
<ide> public final <R> Observable<R> withLatestFrom(ObservableSource<?>[] others, Function<? super Object[], R> combiner) {
<ide> ObjectHelper.requireNonNull(others, "others is null");
<ide> ObjectHelper.requireNonNull(combiner, "combiner is null");
<del> return new ObservableWithLatestFromMany<T, R>(this, others, combiner);
<add> return RxJavaPlugins.onAssembly(new ObservableWithLatestFromMany<T, R>(this, others, combiner));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> withLatestFrom(ObservableSource<?>[] others, Func
<ide> public final <R> Observable<R> withLatestFrom(Iterable<? extends ObservableSource<?>> others, Function<? super Object[], R> combiner) {
<ide> ObjectHelper.requireNonNull(others, "others is null");
<ide> ObjectHelper.requireNonNull(combiner, "combiner is null");
<del> return new ObservableWithLatestFromMany<T, R>(this, others, combiner);
<add> return RxJavaPlugins.onAssembly(new ObservableWithLatestFromMany<T, R>(this, others, combiner));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Observable<R> withLatestFrom(Iterable<? extends ObservableSourc
<ide> public final <U, R> Observable<R> zipWith(Iterable<U> other, BiFunction<? super T, ? super U, ? extends R> zipper) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<ide> ObjectHelper.requireNonNull(zipper, "zipper is null");
<del> return new ObservableZipIterable<T, U, R>(this, other, zipper);
<add> return RxJavaPlugins.onAssembly(new ObservableZipIterable<T, U, R>(this, other, zipper));
<ide> }
<ide>
<ide> /**
<ide> public final TestObserver<T> test() { // NoPMD
<ide> subscribe(ts);
<ide> return ts;
<ide> }
<add>
<add> /**
<add> * Creates a TestObserver, optionally disposes it and then subscribes
<add> * it to this Observable.
<add> * @param dispose dispose the TestObserver before it is subscribed to this Observable?
<add> * @return the new TestObserver instance
<add> * @since 2.0
<add> */
<add> public final TestObserver<T> test(boolean dispose) { // NoPMD
<add> TestObserver<T> ts = new TestObserver<T>();
<add> if (dispose) {
<add> ts.dispose();
<add> }
<add> subscribe(ts);
<add> return ts;
<add> }
<ide> }
<ide><path>src/main/java/io/reactivex/Single.java
<ide> */
<ide> public static <T> Single<T> amb(final Iterable<? extends SingleSource<? extends T>> sources) {
<ide> ObjectHelper.requireNonNull(sources, "sources is null");
<del> return new SingleAmbIterable<T>(sources);
<add> return RxJavaPlugins.onAssembly(new SingleAmbIterable<T>(sources));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Single<T> amb(final Iterable<? extends SingleSource<? extends
<ide> * @since 2.0
<ide> */
<ide> @SuppressWarnings("unchecked")
<del> public static <T> Single<T> amb(final SingleSource<? extends T>... sources) {
<add> public static <T> Single<T> ambArray(final SingleSource<? extends T>... sources) {
<ide> if (sources.length == 0) {
<ide> return error(SingleInternalHelper.<T>emptyThrower());
<ide> }
<ide> if (sources.length == 1) {
<ide> return wrap((SingleSource<T>)sources[0]);
<ide> }
<del> return new SingleAmbArray<T>(sources);
<add> return RxJavaPlugins.onAssembly(new SingleAmbArray<T>(sources));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> concat(Iterable<? extends SingleSource<? extends T
<ide> */
<ide> @SuppressWarnings({ "unchecked", "rawtypes" })
<ide> public static <T> Flowable<T> concat(Publisher<? extends SingleSource<? extends T>> sources) {
<del> return new FlowableConcatMap(sources, SingleInternalHelper.toFlowable(), 2, ErrorMode.IMMEDIATE);
<add> return RxJavaPlugins.onAssembly(new FlowableConcatMap(sources, SingleInternalHelper.toFlowable(), 2, ErrorMode.IMMEDIATE));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Single<T> create(SingleOnSubscribe<T> source) {
<ide> */
<ide> public static <T> Single<T> defer(final Callable<? extends SingleSource<? extends T>> singleSupplier) {
<ide> ObjectHelper.requireNonNull(singleSupplier, "singleSupplier is null");
<del> return new SingleDefer<T>(singleSupplier);
<add> return RxJavaPlugins.onAssembly(new SingleDefer<T>(singleSupplier));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Single<T> defer(final Callable<? extends SingleSource<? extend
<ide> */
<ide> public static <T> Single<T> error(final Callable<? extends Throwable> errorSupplier) {
<ide> ObjectHelper.requireNonNull(errorSupplier, "errorSupplier is null");
<del> return new SingleError<T>(errorSupplier);
<add> return RxJavaPlugins.onAssembly(new SingleError<T>(errorSupplier));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Single<T> error(final Throwable exception) {
<ide> */
<ide> public static <T> Single<T> fromCallable(final Callable<? extends T> callable) {
<ide> ObjectHelper.requireNonNull(callable, "callable is null");
<del> return new SingleFromCallable<T>(callable);
<add> return RxJavaPlugins.onAssembly(new SingleFromCallable<T>(callable));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Single<T> fromFuture(Future<? extends T> future, Scheduler sch
<ide> */
<ide> public static <T> Single<T> fromPublisher(final Publisher<? extends T> publisher) {
<ide> ObjectHelper.requireNonNull(publisher, "publisher is null");
<del> return new SingleFromPublisher<T>(publisher);
<add> return RxJavaPlugins.onAssembly(new SingleFromPublisher<T>(publisher));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Single<T> fromPublisher(final Publisher<? extends T> publisher
<ide> */
<ide> public static <T> Single<T> just(final T value) {
<ide> ObjectHelper.requireNonNull(value, "value is null");
<del> return new SingleJust<T>(value);
<add> return RxJavaPlugins.onAssembly(new SingleJust<T>(value));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> merge(Iterable<? extends SingleSource<? extends T>
<ide> */
<ide> @SuppressWarnings({ "unchecked", "rawtypes" })
<ide> public static <T> Flowable<T> merge(Publisher<? extends SingleSource<? extends T>> sources) {
<del> return new FlowableFlatMap(sources, SingleInternalHelper.toFlowable(), false, Integer.MAX_VALUE, Flowable.bufferSize());
<add> return RxJavaPlugins.onAssembly(new FlowableFlatMap(sources, SingleInternalHelper.toFlowable(), false, Integer.MAX_VALUE, Flowable.bufferSize()));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> merge(Publisher<? extends SingleSource<? extends T
<ide> @SuppressWarnings({ "unchecked", "rawtypes" })
<ide> public static <T> Single<T> merge(SingleSource<? extends SingleSource<? extends T>> source) {
<ide> ObjectHelper.requireNonNull(source, "source is null");
<del> return new SingleFlatMap<SingleSource<? extends T>, T>(source, (Function)Functions.identity());
<add> return RxJavaPlugins.onAssembly(new SingleFlatMap<SingleSource<? extends T>, T>(source, (Function)Functions.identity()));
<ide> }
<ide>
<ide> /**
<ide> public static <T> Flowable<T> merge(
<ide> */
<ide> @SuppressWarnings("unchecked")
<ide> public static <T> Single<T> never() {
<del> return (Single<T>) SingleNever.INSTANCE;
<add> return RxJavaPlugins.onAssembly((Single<T>) SingleNever.INSTANCE);
<ide> }
<ide>
<ide> /**
<ide> public static Single<Long> timer(long delay, TimeUnit unit) {
<ide> public static Single<Long> timer(final long delay, final TimeUnit unit, final Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new SingleTimer(delay, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new SingleTimer(delay, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public static Single<Long> timer(final long delay, final TimeUnit unit, final Sc
<ide> public static <T> Single<Boolean> equals(final SingleSource<? extends T> first, final SingleSource<? extends T> second) { // NOPMD
<ide> ObjectHelper.requireNonNull(first, "first is null");
<ide> ObjectHelper.requireNonNull(second, "second is null");
<del> return new SingleEquals<T>(first, second);
<add> return RxJavaPlugins.onAssembly(new SingleEquals<T>(first, second));
<ide> }
<ide>
<ide> /**
<ide> public static <T, U> Single<T> using(
<ide> ObjectHelper.requireNonNull(singleFunction, "singleFunction is null");
<ide> ObjectHelper.requireNonNull(disposer, "disposer is null");
<ide>
<del> return new SingleUsing<T, U>(resourceSupplier, singleFunction, disposer, eager);
<add> return RxJavaPlugins.onAssembly(new SingleUsing<T, U>(resourceSupplier, singleFunction, disposer, eager));
<ide> }
<ide>
<ide> /**
<ide> public static <T, U> Single<T> using(
<ide> static <T> Single<T> wrap(SingleSource<T> source) {
<ide> ObjectHelper.requireNonNull(source, "source is null");
<ide> if (source instanceof Single) {
<del> return (Single<T>)source;
<add> return RxJavaPlugins.onAssembly((Single<T>)source);
<ide> }
<del> return new SingleFromUnsafeSource<T>(source);
<add> return RxJavaPlugins.onAssembly(new SingleFromUnsafeSource<T>(source));
<ide> }
<ide>
<ide> /**
<ide> public static <T, R> Single<R> zipArray(Function<? super Object[], ? extends R>
<ide> int i = 0;
<ide> for (SingleSource<? extends T> s : sources) {
<ide> ObjectHelper.requireNonNull(s, "The " + i + "th source is null");
<del> sourcePublishers[i] = new SingleToFlowable<T>(s);
<add> sourcePublishers[i] = RxJavaPlugins.onAssembly(new SingleToFlowable<T>(s));
<ide> i++;
<ide> }
<ide> return Flowable.zipArray(zipper, false, 1, sourcePublishers).toSingle();
<ide> public static <T, R> Single<R> zipArray(Function<? super Object[], ? extends R>
<ide> @SuppressWarnings("unchecked")
<ide> public final Single<T> ambWith(SingleSource<? extends T> other) {
<ide> ObjectHelper.requireNonNull(other, "other is null");
<del> return amb(this, other);
<add> return ambArray(this, other);
<ide> }
<ide>
<ide> /**
<ide> public final Single<T> ambWith(SingleSource<? extends T> other) {
<ide> * @since 2.0
<ide> */
<ide> public final Single<T> hide() {
<del> return new SingleHide<T>(this);
<add> return RxJavaPlugins.onAssembly(new SingleHide<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Single<R> compose(Function<? super Single<T>, ? extends SingleS
<ide> * @since 2.0
<ide> */
<ide> public final Single<T> cache() {
<del> return new SingleCache<T>(this);
<add> return RxJavaPlugins.onAssembly(new SingleCache<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Single<T> delay(long time, TimeUnit unit) {
<ide> public final Single<T> delay(final long time, final TimeUnit unit, final Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new SingleDelay<T>(this, time, unit, scheduler);
<add> return RxJavaPlugins.onAssembly(new SingleDelay<T>(this, time, unit, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Single<T> delay(final long time, final TimeUnit unit, final Schedul
<ide> * @since 2.0
<ide> */
<ide> public final Single<T> delaySubscription(CompletableSource other) {
<del> return new SingleDelayWithCompletable<T>(this, other);
<add> return RxJavaPlugins.onAssembly(new SingleDelayWithCompletable<T>(this, other));
<ide> }
<ide>
<ide> /**
<ide> public final Single<T> delaySubscription(CompletableSource other) {
<ide> * @since 2.0
<ide> */
<ide> public final <U> Single<T> delaySubscription(SingleSource<U> other) {
<del> return new SingleDelayWithSingle<T, U>(this, other);
<add> return RxJavaPlugins.onAssembly(new SingleDelayWithSingle<T, U>(this, other));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Single<T> delaySubscription(SingleSource<U> other) {
<ide> * @since 2.0
<ide> */
<ide> public final <U> Single<T> delaySubscription(ObservableSource<U> other) {
<del> return new SingleDelayWithObservable<T, U>(this, other);
<add> return RxJavaPlugins.onAssembly(new SingleDelayWithObservable<T, U>(this, other));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Single<T> delaySubscription(ObservableSource<U> other) {
<ide> * @since 2.0
<ide> */
<ide> public final <U> Single<T> delaySubscription(Publisher<U> other) {
<del> return new SingleDelayWithPublisher<T, U>(this, other);
<add> return RxJavaPlugins.onAssembly(new SingleDelayWithPublisher<T, U>(this, other));
<ide> }
<ide>
<ide> /**
<ide> public final <U> Single<T> delaySubscription(long time, TimeUnit unit, Scheduler
<ide> */
<ide> public final Single<T> doOnSubscribe(final Consumer<? super Disposable> onSubscribe) {
<ide> ObjectHelper.requireNonNull(onSubscribe, "onSubscribe is null");
<del> return new SingleDoOnSubscribe<T>(this, onSubscribe);
<add> return RxJavaPlugins.onAssembly(new SingleDoOnSubscribe<T>(this, onSubscribe));
<ide> }
<ide>
<ide> /**
<ide> public final Single<T> doOnSubscribe(final Consumer<? super Disposable> onSubscr
<ide> */
<ide> public final Single<T> doOnSuccess(final Consumer<? super T> onSuccess) {
<ide> ObjectHelper.requireNonNull(onSuccess, "onSuccess is null");
<del> return new SingleDoOnSuccess<T>(this, onSuccess);
<add> return RxJavaPlugins.onAssembly(new SingleDoOnSuccess<T>(this, onSuccess));
<ide> }
<ide>
<ide> /**
<ide> public final Single<T> doOnSuccess(final Consumer<? super T> onSuccess) {
<ide> */
<ide> public final Single<T> doOnError(final Consumer<? super Throwable> onError) {
<ide> ObjectHelper.requireNonNull(onError, "onError is null");
<del> return new SingleDoOnError<T>(this, onError);
<add> return RxJavaPlugins.onAssembly(new SingleDoOnError<T>(this, onError));
<ide> }
<ide>
<ide> /**
<ide> public final Single<T> doOnError(final Consumer<? super Throwable> onError) {
<ide> */
<ide> public final Single<T> doOnCancel(final Action onCancel) {
<ide> ObjectHelper.requireNonNull(onCancel, "onCancel is null");
<del> return new SingleDoOnCancel<T>(this, onCancel);
<add> return RxJavaPlugins.onAssembly(new SingleDoOnCancel<T>(this, onCancel));
<ide> }
<ide>
<ide> /**
<ide> public final Single<T> doOnCancel(final Action onCancel) {
<ide> */
<ide> public final <R> Single<R> flatMap(Function<? super T, ? extends SingleSource<? extends R>> mapper) {
<ide> ObjectHelper.requireNonNull(mapper, "mapper is null");
<del> return new SingleFlatMap<T, R>(this, mapper);
<add> return RxJavaPlugins.onAssembly(new SingleFlatMap<T, R>(this, mapper));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Flowable<R> flatMapPublisher(Function<? super T, ? extends Publ
<ide> */
<ide> public final Completable flatMapCompletable(final Function<? super T, ? extends Completable> mapper) {
<ide> ObjectHelper.requireNonNull(mapper, "mapper is null");
<del> return new SingleFlatMapCompletable<T>(this, mapper);
<add> return RxJavaPlugins.onAssembly(new SingleFlatMapCompletable<T>(this, mapper));
<ide> }
<ide>
<ide> /**
<ide> public final T blockingGet() {
<ide> */
<ide> public final <R> Single<R> lift(final SingleOperator<? extends R, ? super T> lift) {
<ide> ObjectHelper.requireNonNull(lift, "onLift is null");
<del> return new SingleLift<T, R>(this, lift);
<add> return RxJavaPlugins.onAssembly(new SingleLift<T, R>(this, lift));
<ide> }
<ide>
<ide> /**
<ide> public final <R> Single<R> lift(final SingleOperator<? extends R, ? super T> lif
<ide> * @see <a href="http://reactivex.io/documentation/operators/map.html">ReactiveX operators documentation: Map</a>
<ide> */
<ide> public final <R> Single<R> map(Function<? super T, ? extends R> mapper) {
<del> return new SingleMap<T, R>(this, mapper);
<add> return RxJavaPlugins.onAssembly(new SingleMap<T, R>(this, mapper));
<ide> }
<ide>
<ide> /**
<ide> public final Single<Boolean> contains(Object value) {
<ide> public final Single<Boolean> contains(final Object value, final BiPredicate<Object, Object> comparer) {
<ide> ObjectHelper.requireNonNull(value, "value is null");
<ide> ObjectHelper.requireNonNull(comparer, "comparer is null");
<del> return new SingleContains<T>(this, value, comparer);
<add> return RxJavaPlugins.onAssembly(new SingleContains<T>(this, value, comparer));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> mergeWith(SingleSource<? extends T> other) {
<ide> */
<ide> public final Single<T> observeOn(final Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new SingleObserveOn<T>(this, scheduler);
<add> return RxJavaPlugins.onAssembly(new SingleObserveOn<T>(this, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Single<T> observeOn(final Scheduler scheduler) {
<ide> */
<ide> public final Single<T> onErrorReturn(final Function<Throwable, ? extends T> resumeFunction) {
<ide> ObjectHelper.requireNonNull(resumeFunction, "resumeFunction is null");
<del> return new SingleOnErrorReturn<T>(this, resumeFunction, null);
<add> return RxJavaPlugins.onAssembly(new SingleOnErrorReturn<T>(this, resumeFunction, null));
<ide> }
<ide>
<ide> /**
<ide> public final Single<T> onErrorReturn(final Function<Throwable, ? extends T> resu
<ide> */
<ide> public final Single<T> onErrorReturnValue(final T value) {
<ide> ObjectHelper.requireNonNull(value, "value is null");
<del> return new SingleOnErrorReturn<T>(this, null, value);
<add> return RxJavaPlugins.onAssembly(new SingleOnErrorReturn<T>(this, null, value));
<ide> }
<ide>
<ide> /**
<ide> public final Single<T> onErrorResumeNext(final Single<? extends T> resumeSingleI
<ide> public final Single<T> onErrorResumeNext(
<ide> final Function<? super Throwable, ? extends SingleSource<? extends T>> resumeFunctionInCaseOfError) {
<ide> ObjectHelper.requireNonNull(resumeFunctionInCaseOfError, "resumeFunctionInCaseOfError is null");
<del> return new SingleResumeNext<T>(this, resumeFunctionInCaseOfError);
<add> return RxJavaPlugins.onAssembly(new SingleResumeNext<T>(this, resumeFunctionInCaseOfError));
<ide> }
<ide>
<ide> /**
<ide> public final void subscribe(SingleObserver<? super T> subscriber) {
<ide> */
<ide> public final Single<T> subscribeOn(final Scheduler scheduler) {
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new SingleSubscribeOn<T>(this, scheduler);
<add> return RxJavaPlugins.onAssembly(new SingleSubscribeOn<T>(this, scheduler));
<ide> }
<ide>
<ide> /**
<ide> public final Single<T> takeUntil(final CompletableSource other) {
<ide> * @see <a href="http://reactivex.io/documentation/operators/takeuntil.html">ReactiveX operators documentation: TakeUntil</a>
<ide> */
<ide> public final <E> Single<T> takeUntil(final Publisher<E> other) {
<del> return new SingleTakeUntil<T, E>(this, other);
<add> return RxJavaPlugins.onAssembly(new SingleTakeUntil<T, E>(this, other));
<ide> }
<ide>
<ide> /**
<ide> public final Single<T> timeout(long timeout, TimeUnit unit, SingleSource<? exten
<ide> private Single<T> timeout0(final long timeout, final TimeUnit unit, final Scheduler scheduler, final SingleSource<? extends T> other) {
<ide> ObjectHelper.requireNonNull(unit, "unit is null");
<ide> ObjectHelper.requireNonNull(scheduler, "scheduler is null");
<del> return new SingleTimeout<T>(this, timeout, unit, scheduler, other);
<add> return RxJavaPlugins.onAssembly(new SingleTimeout<T>(this, timeout, unit, scheduler, other));
<ide> }
<ide>
<ide> /**
<ide> public final <R> R to(Function<? super Single<T>, R> convert) {
<ide> * @since 2.0
<ide> */
<ide> public final Completable toCompletable() {
<del> return new CompletableFromSingle<T>(this);
<add> return RxJavaPlugins.onAssembly(new CompletableFromSingle<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Completable toCompletable() {
<ide> * @return an {@link Observable} that emits a single item T.
<ide> */
<ide> public final Flowable<T> toFlowable() {
<del> return new SingleToFlowable<T>(this);
<add> return RxJavaPlugins.onAssembly(new SingleToFlowable<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public final Flowable<T> toFlowable() {
<ide> * @return an {@link Observable} that emits a single item T.
<ide> */
<ide> public final Observable<T> toObservable() {
<del> return new SingleToObservable<T>(this);
<add> return RxJavaPlugins.onAssembly(new SingleToObservable<T>(this));
<ide> }
<ide>
<ide> /**
<ide><path>src/main/java/io/reactivex/flowables/ConnectableFlowable.java
<ide> import io.reactivex.functions.Consumer;
<ide> import io.reactivex.internal.functions.Functions;
<ide> import io.reactivex.internal.operators.flowable.*;
<add>import io.reactivex.plugins.RxJavaPlugins;
<ide>
<ide> /**
<ide> * A {@code ConnectableObservable} resembles an ordinary {@link Flowable}, except that it does not begin
<ide> public void accept(Disposable d) {
<ide> * @see <a href="http://reactivex.io/documentation/operators/refcount.html">ReactiveX documentation: RefCount</a>
<ide> */
<ide> public Flowable<T> refCount() {
<del> return new FlowableRefCount<T>(this);
<add> return RxJavaPlugins.onAssembly(new FlowableRefCount<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public Flowable<T> autoConnect(int numberOfSubscribers) {
<ide> public Flowable<T> autoConnect(int numberOfSubscribers, Consumer<? super Disposable> connection) {
<ide> if (numberOfSubscribers <= 0) {
<ide> this.connect(connection);
<del> return this;
<add> return RxJavaPlugins.onAssembly(this);
<ide> }
<del> return new FlowableAutoConnect<T>(this, numberOfSubscribers, connection);
<add> return RxJavaPlugins.onAssembly(new FlowableAutoConnect<T>(this, numberOfSubscribers, connection));
<ide> }
<ide> }
<ide><path>src/main/java/io/reactivex/internal/operators/flowable/FlowableCache.java
<ide> import io.reactivex.exceptions.Exceptions;
<ide> import io.reactivex.internal.subscriptions.SubscriptionHelper;
<ide> import io.reactivex.internal.util.*;
<add>import io.reactivex.plugins.RxJavaPlugins;
<ide>
<ide> /**
<ide> * An observable which auto-connects to another observable, caches the elements
<ide>
<ide> final AtomicBoolean once;
<ide> /**
<del> * Creates a cached Observable with a default capacity hint of 16.
<add> * Creates a cached Flowable with a default capacity hint of 16.
<ide> * @param <T> the value type
<ide> * @param source the source Observable to cache
<ide> * @return the CachedObservable instance
<ide> */
<del> public static <T> FlowableCache<T> from(Flowable<T> source) {
<add> public static <T> Flowable<T> from(Flowable<T> source) {
<ide> return from(source, 16);
<ide> }
<ide>
<ide> /**
<del> * Creates a cached Observable with the given capacity hint.
<add> * Creates a cached Flowable with the given capacity hint.
<ide> * @param <T> the value type
<ide> * @param source the source Observable to cache
<ide> * @param capacityHint the hint for the internal buffer size
<ide> * @return the CachedObservable instance
<ide> */
<del> public static <T> FlowableCache<T> from(Flowable<T> source, int capacityHint) {
<add> public static <T> Flowable<T> from(Flowable<T> source, int capacityHint) {
<ide> if (capacityHint < 1) {
<ide> throw new IllegalArgumentException("capacityHint > 0 required");
<ide> }
<ide> CacheState<T> state = new CacheState<T>(source, capacityHint);
<del> return new FlowableCache<T>(source, state);
<add> return RxJavaPlugins.onAssembly(new FlowableCache<T>(source, state));
<ide> }
<ide>
<ide> /**
<ide><path>src/main/java/io/reactivex/internal/operators/flowable/FlowableDistinct.java
<ide>
<ide> import org.reactivestreams.*;
<ide>
<add>import io.reactivex.Flowable;
<ide> import io.reactivex.exceptions.*;
<ide> import io.reactivex.functions.*;
<ide> import io.reactivex.internal.functions.*;
<ide> import io.reactivex.internal.subscriptions.*;
<add>import io.reactivex.plugins.RxJavaPlugins;
<ide>
<ide> public final class FlowableDistinct<T, K> extends AbstractFlowableWithUpstream<T, T> {
<ide> final Function<? super T, K> keySelector;
<ide> public FlowableDistinct(Publisher<T> source, Function<? super T, K> keySelector,
<ide> this.keySelector = keySelector;
<ide> }
<ide>
<del> public static <T, K> FlowableDistinct<T, K> withCollection(Publisher<T> source, Function<? super T, K> keySelector, final Callable<? extends Collection<? super K>> collectionSupplier) {
<add> public static <T, K> Flowable<T> withCollection(Publisher<T> source, Function<? super T, K> keySelector, final Callable<? extends Collection<? super K>> collectionSupplier) {
<ide> Callable<? extends Predicate<? super K>> p = new Callable<Predicate<K>>() {
<ide> @Override
<ide> public Predicate<K> call() throws Exception {
<ide> public boolean test(K t) {
<ide> }
<ide> };
<ide>
<del> return new FlowableDistinct<T, K>(source, keySelector, p);
<add> return RxJavaPlugins.onAssembly(new FlowableDistinct<T, K>(source, keySelector, p));
<ide> }
<ide>
<del> public static <T> FlowableDistinct<T, T> untilChanged(Publisher<T> source) {
<add> public static <T> Flowable<T> untilChanged(Publisher<T> source) {
<ide> Callable<? extends Predicate<? super T>> p = new Callable<Predicate<T>>() {
<ide> Object last;
<ide> @Override
<ide> public boolean test(T t) {
<ide> };
<ide> }
<ide> };
<del> return new FlowableDistinct<T, T>(source, Functions.<T>identity(), p);
<add> return RxJavaPlugins.onAssembly(new FlowableDistinct<T, T>(source, Functions.<T>identity(), p));
<ide> }
<ide>
<del> public static <T, K> FlowableDistinct<T, K> untilChanged(Publisher<T> source, Function<? super T, K> keySelector) {
<add> public static <T, K> Flowable<T> untilChanged(Publisher<T> source, Function<? super T, K> keySelector) {
<ide> Callable<? extends Predicate<? super K>> p = new Callable<Predicate<K>>() {
<ide> Object last;
<ide> @Override
<ide> public boolean test(K t) {
<ide> };
<ide> }
<ide> };
<del> return new FlowableDistinct<T, K>(source, keySelector, p);
<add> return RxJavaPlugins.onAssembly(new FlowableDistinct<T, K>(source, keySelector, p));
<ide> }
<ide>
<ide> @Override
<ide><path>src/main/java/io/reactivex/internal/operators/flowable/FlowablePublish.java
<ide> public void subscribe(Subscriber<? super T> child) {
<ide> }
<ide> }
<ide> };
<del> return new FlowablePublish<T>(onSubscribe, source, curr, bufferSize);
<add> return RxJavaPlugins.onAssembly(new FlowablePublish<T>(onSubscribe, source, curr, bufferSize));
<ide> }
<ide>
<ide> private FlowablePublish(Publisher<T> onSubscribe, Publisher<T> source,
<ide><path>src/main/java/io/reactivex/internal/operators/flowable/FlowableRepeatWhen.java
<ide> public void subscribeActual(Subscriber<? super T> s) {
<ide>
<ide> SerializedSubscriber<T> z = new SerializedSubscriber<T>(s);
<ide>
<del> FlowProcessor<Object> processor = new UnicastProcessor<Object>(8).toSerialized();
<add> FlowableProcessor<Object> processor = new UnicastProcessor<Object>(8).toSerialized();
<ide>
<ide> Publisher<?> when;
<ide>
<ide> public void cancel() {
<ide>
<ide> protected final Subscriber<? super T> actual;
<ide>
<del> protected final FlowProcessor<U> processor;
<add> protected final FlowableProcessor<U> processor;
<ide>
<ide> protected final Subscription receiver;
<ide>
<ide> private long produced;
<ide>
<del> public WhenSourceSubscriber(Subscriber<? super T> actual, FlowProcessor<U> processor,
<add> public WhenSourceSubscriber(Subscriber<? super T> actual, FlowableProcessor<U> processor,
<ide> Subscription receiver) {
<ide> this.actual = actual;
<ide> this.processor = processor;
<ide> public final void cancel() {
<ide> /** */
<ide> private static final long serialVersionUID = -2680129890138081029L;
<ide>
<del> public RepeatWhenSubscriber(Subscriber<? super T> actual, FlowProcessor<Object> processor,
<add> public RepeatWhenSubscriber(Subscriber<? super T> actual, FlowableProcessor<Object> processor,
<ide> Subscription receiver) {
<ide> super(actual, processor, receiver);
<ide> }
<ide><path>src/main/java/io/reactivex/internal/operators/flowable/FlowableReplay.java
<ide> public void accept(Disposable r) {
<ide> */
<ide> public static <T> ConnectableFlowable<T> observeOn(final ConnectableFlowable<T> co, final Scheduler scheduler) {
<ide> final Flowable<T> observable = co.observeOn(scheduler);
<del> return new ConnectableFlowable<T>() {
<add> return RxJavaPlugins.onAssembly(new ConnectableFlowable<T>() {
<ide> @Override
<ide> public void connect(Consumer<? super Disposable> connection) {
<ide> co.connect(connection);
<ide> public void connect(Consumer<? super Disposable> connection) {
<ide> protected void subscribeActual(Subscriber<? super T> s) {
<ide> observable.subscribe(s);
<ide> }
<del> };
<add> });
<ide> }
<ide>
<ide> /**
<ide> public void subscribe(Subscriber<? super T> child) {
<ide> }
<ide> }
<ide> };
<del> return new FlowableReplay<T>(onSubscribe, source, curr, bufferFactory);
<add> return RxJavaPlugins.onAssembly(new FlowableReplay<T>(onSubscribe, source, curr, bufferFactory));
<ide> }
<ide>
<ide> private FlowableReplay(Publisher<T> onSubscribe, Flowable<T> source,
<ide><path>src/main/java/io/reactivex/internal/operators/flowable/FlowableRetryWhen.java
<ide> public FlowableRetryWhen(Publisher<T> source,
<ide> public void subscribeActual(Subscriber<? super T> s) {
<ide> SerializedSubscriber<T> z = new SerializedSubscriber<T>(s);
<ide>
<del> FlowProcessor<Throwable> processor = new UnicastProcessor<Throwable>(8).toSerialized();
<add> FlowableProcessor<Throwable> processor = new UnicastProcessor<Throwable>(8).toSerialized();
<ide>
<ide> Publisher<?> when;
<ide>
<ide> public void subscribeActual(Subscriber<? super T> s) {
<ide> /** */
<ide> private static final long serialVersionUID = -2680129890138081029L;
<ide>
<del> public RetryWhenSubscriber(Subscriber<? super T> actual, FlowProcessor<Throwable> processor,
<add> public RetryWhenSubscriber(Subscriber<? super T> actual, FlowableProcessor<Throwable> processor,
<ide> Subscription receiver) {
<ide> super(actual, processor, receiver);
<ide> }
<ide><path>src/main/java/io/reactivex/internal/operators/flowable/FlowableScalarXMap.java
<ide> import io.reactivex.functions.Function;
<ide> import io.reactivex.internal.functions.ObjectHelper;
<ide> import io.reactivex.internal.subscriptions.*;
<add>import io.reactivex.plugins.RxJavaPlugins;
<ide>
<ide> /**
<ide> * Utility classes to work with scalar-sourced XMap operators (where X == { flat, concat, switch }).
<ide> public static <T, R> boolean tryScalarXMapSubscribe(Publisher<T> source,
<ide> * @return the new Flowable instance
<ide> */
<ide> public static <T, U> Flowable<U> scalarXMap(final T value, final Function<? super T, ? extends Publisher<? extends U>> mapper) {
<del> return new ScalarXMapFlowable<T, U>(value, mapper);
<add> return RxJavaPlugins.onAssembly(new ScalarXMapFlowable<T, U>(value, mapper));
<ide> }
<ide>
<ide> /**
<ide><path>src/main/java/io/reactivex/internal/operators/observable/ObservableCache.java
<ide> import io.reactivex.exceptions.Exceptions;
<ide> import io.reactivex.internal.disposables.SequentialDisposable;
<ide> import io.reactivex.internal.util.*;
<add>import io.reactivex.plugins.RxJavaPlugins;
<ide>
<ide> /**
<ide> * An observable which auto-connects to another observable, caches the elements
<ide> * @param source the source Observable to cache
<ide> * @return the CachedObservable instance
<ide> */
<del> public static <T> ObservableCache<T> from(Observable<T> source) {
<add> public static <T> Observable<T> from(Observable<T> source) {
<ide> return from(source, 16);
<ide> }
<ide>
<ide> public static <T> ObservableCache<T> from(Observable<T> source) {
<ide> * @param capacityHint the hint for the internal buffer size
<ide> * @return the CachedObservable instance
<ide> */
<del> public static <T> ObservableCache<T> from(Observable<T> source, int capacityHint) {
<add> public static <T> Observable<T> from(Observable<T> source, int capacityHint) {
<ide> if (capacityHint < 1) {
<ide> throw new IllegalArgumentException("capacityHint > 0 required");
<ide> }
<ide> CacheState<T> state = new CacheState<T>(source, capacityHint);
<del> return new ObservableCache<T>(source, state);
<add> return RxJavaPlugins.onAssembly(new ObservableCache<T>(source, state));
<ide> }
<ide>
<ide> /**
<ide><path>src/main/java/io/reactivex/internal/operators/observable/ObservablePublish.java
<ide> import io.reactivex.internal.queue.SpscLinkedArrayQueue;
<ide> import io.reactivex.internal.util.NotificationLite;
<ide> import io.reactivex.observables.ConnectableObservable;
<add>import io.reactivex.plugins.RxJavaPlugins;
<ide>
<ide> /**
<ide> * A connectable observable which shares an underlying source and dispatches source values to subscribers in a backpressure-aware
<ide> public void subscribe(Observer<? super T> child) {
<ide> }
<ide> }
<ide> };
<del> return new ObservablePublish<T>(onSubscribe, source, curr, bufferSize);
<add> return RxJavaPlugins.onAssembly(new ObservablePublish<T>(onSubscribe, source, curr, bufferSize));
<ide> }
<ide>
<ide> public static <T, R> Observable<R> create(final ObservableSource<T> source,
<ide> final Function<? super Observable<T>, ? extends ObservableSource<R>> selector, final int bufferSize) {
<del> return new Observable<R>() {
<add> return RxJavaPlugins.onAssembly(new Observable<R>() {
<ide> @Override
<ide> protected void subscribeActual(Observer<? super R> o) {
<ide> ConnectableObservable<T> op = ObservablePublish.create(source, bufferSize);
<ide> public void accept(Disposable r) {
<ide> }
<ide> });
<ide> }
<del> };
<add> });
<ide> }
<ide>
<ide> private ObservablePublish(ObservableSource<T> onSubscribe, ObservableSource<T> source,
<ide><path>src/main/java/io/reactivex/internal/operators/observable/ObservableReplay.java
<ide> import io.reactivex.internal.disposables.*;
<ide> import io.reactivex.internal.util.NotificationLite;
<ide> import io.reactivex.observables.ConnectableObservable;
<add>import io.reactivex.plugins.RxJavaPlugins;
<ide> import io.reactivex.schedulers.Timed;
<ide>
<ide> public final class ObservableReplay<T> extends ConnectableObservable<T> implements ObservableWithUpstream<T> {
<ide> public Object call() {
<ide> public static <U, R> Observable<R> multicastSelector(
<ide> final Callable<? extends ConnectableObservable<U>> connectableFactory,
<ide> final Function<? super Observable<U>, ? extends ObservableSource<R>> selector) {
<del> return new Observable<R>() {
<add> return RxJavaPlugins.onAssembly(new Observable<R>() {
<ide> @Override
<ide> protected void subscribeActual(Observer<? super R> child) {
<ide> ConnectableObservable<U> co;
<ide> public void accept(Disposable r) {
<ide> }
<ide> });
<ide> }
<del> };
<add> });
<ide> }
<ide>
<ide> /**
<ide> public void accept(Disposable r) {
<ide> */
<ide> public static <T> ConnectableObservable<T> observeOn(final ConnectableObservable<T> co, final Scheduler scheduler) {
<ide> final Observable<T> observable = co.observeOn(scheduler);
<del> return new ConnectableObservable<T>() {
<add> return RxJavaPlugins.onAssembly(new ConnectableObservable<T>() {
<ide> @Override
<ide> public void connect(Consumer<? super Disposable> connection) {
<ide> co.connect(connection);
<ide> public void connect(Consumer<? super Disposable> connection) {
<ide> protected void subscribeActual(Observer<? super T> observer) {
<ide> observable.subscribe(observer);
<ide> }
<del> };
<add> });
<ide> }
<ide>
<ide> /**
<ide> public void subscribe(Observer<? super T> child) {
<ide> }
<ide> }
<ide> };
<del> return new ObservableReplay<T>(onSubscribe, source, curr, bufferFactory);
<add> return RxJavaPlugins.onAssembly(new ObservableReplay<T>(onSubscribe, source, curr, bufferFactory));
<ide> }
<ide>
<ide> private ObservableReplay(ObservableSource<T> onSubscribe, Observable<T> source,
<ide><path>src/main/java/io/reactivex/internal/operators/observable/ObservableScalarXMap.java
<ide> import io.reactivex.internal.disposables.EmptyDisposable;
<ide> import io.reactivex.internal.functions.ObjectHelper;
<ide> import io.reactivex.internal.fuseable.QueueDisposable;
<add>import io.reactivex.plugins.RxJavaPlugins;
<ide>
<ide> /**
<ide> * Utility classes to work with scalar-sourced XMap operators (where X == { flat, concat, switch }).
<ide> public static <T, R> boolean tryScalarXMapSubscribe(ObservableSource<T> source,
<ide> */
<ide> public static <T, U> Observable<U> scalarXMap(T value,
<ide> Function<? super T, ? extends ObservableSource<? extends U>> mapper) {
<del> return new ScalarXMapObservable<T, U>(value, mapper);
<add> return RxJavaPlugins.onAssembly(new ScalarXMapObservable<T, U>(value, mapper));
<ide> }
<ide>
<ide> /**
<ide><path>src/main/java/io/reactivex/observables/ConnectableObservable.java
<ide> import io.reactivex.functions.Consumer;
<ide> import io.reactivex.internal.functions.Functions;
<ide> import io.reactivex.internal.operators.observable.*;
<add>import io.reactivex.plugins.RxJavaPlugins;
<ide>
<ide> /**
<ide> * A {@code ConnectableObservable} resembles an ordinary {@link Flowable}, except that it does not begin
<ide> public void accept(Disposable d) {
<ide> * @see <a href="http://reactivex.io/documentation/operators/refcount.html">ReactiveX documentation: RefCount</a>
<ide> */
<ide> public Observable<T> refCount() {
<del> return new ObservableRefCount<T>(this);
<add> return RxJavaPlugins.onAssembly(new ObservableRefCount<T>(this));
<ide> }
<ide>
<ide> /**
<ide> public Observable<T> autoConnect(int numberOfSubscribers) {
<ide> public Observable<T> autoConnect(int numberOfSubscribers, Consumer<? super Disposable> connection) {
<ide> if (numberOfSubscribers <= 0) {
<ide> this.connect(connection);
<del> return this;
<add> return RxJavaPlugins.onAssembly(this);
<ide> }
<del> return new ObservableAutoConnect<T>(this, numberOfSubscribers, connection);
<add> return RxJavaPlugins.onAssembly(new ObservableAutoConnect<T>(this, numberOfSubscribers, connection));
<ide> }
<ide> }
<ide><path>src/main/java/io/reactivex/plugins/RxJavaPlugins.java
<ide>
<ide> import io.reactivex.*;
<ide> import io.reactivex.exceptions.Exceptions;
<add>import io.reactivex.flowables.ConnectableFlowable;
<ide> import io.reactivex.functions.*;
<add>import io.reactivex.observables.ConnectableObservable;
<ide>
<ide> /**
<ide> * Utility class to inject handlers to certain standard RxJava operations.
<ide> public final class RxJavaPlugins {
<ide>
<ide> @SuppressWarnings("rawtypes")
<ide> static volatile Function<Flowable, Flowable> onFlowableAssembly;
<del>
<add>
<add> @SuppressWarnings("rawtypes")
<add> static volatile Function<ConnectableFlowable, ConnectableFlowable> onConnectableFlowableAssembly;
<add>
<ide> @SuppressWarnings("rawtypes")
<ide> static volatile Function<Observable, Observable> onObservableAssembly;
<del>
<add>
<add> @SuppressWarnings("rawtypes")
<add> static volatile Function<ConnectableObservable, ConnectableObservable> onConnectableObservableAssembly;
<add>
<ide> @SuppressWarnings("rawtypes")
<ide> static volatile Function<Single, Single> onSingleAssembly;
<ide>
<ide> public static BiFunction<Completable, CompletableObserver, CompletableObserver>
<ide> public static Function<Flowable, Flowable> getOnFlowableAssembly() {
<ide> return onFlowableAssembly;
<ide> }
<del>
<add>
<add> /**
<add> * Returns the current hook function.
<add> * @return the hook function, may be null
<add> */
<add> @SuppressWarnings("rawtypes")
<add> public static Function<ConnectableFlowable, ConnectableFlowable> getOnConnectableFlowableAssembly() {
<add> return onConnectableFlowableAssembly;
<add> }
<add>
<ide> /**
<ide> * Returns the current hook function.
<ide> * @return the hook function, may be null
<ide> public static Function<Observable, Observable> getOnObservableAssembly() {
<ide> return onObservableAssembly;
<ide> }
<ide>
<add> /**
<add> * Returns the current hook function.
<add> * @return the hook function, may be null
<add> */
<add> @SuppressWarnings("rawtypes")
<add> public static Function<ConnectableObservable, ConnectableObservable> getOnConnectableObservableAssembly() {
<add> return onConnectableObservableAssembly;
<add> }
<add>
<ide> /**
<ide> * Returns the current hook function.
<ide> * @return the hook function, may be null
<ide> public static void setOnFlowableAssembly(Function<Flowable, Flowable> onFlowable
<ide> RxJavaPlugins.onFlowableAssembly = onFlowableAssembly;
<ide> }
<ide>
<add> /**
<add> * Sets the specific hook function.
<add> * @param onConnectableFlowableAssembly the hook function to set, null allowed
<add> */
<add> @SuppressWarnings("rawtypes")
<add> public static void setOnConnectableFlowableAssembly(Function<ConnectableFlowable, ConnectableFlowable> onConnectableFlowableAssembly) {
<add> if (lockdown) {
<add> throw new IllegalStateException("Plugins can't be changed anymore");
<add> }
<add> RxJavaPlugins.onConnectableFlowableAssembly = onConnectableFlowableAssembly;
<add> }
<add>
<ide> /**
<ide> * Sets the specific hook function.
<ide> * @param onFlowableSubscribe the hook function to set, null allowed
<ide> public static void setOnObservableAssembly(Function<Observable, Observable> onOb
<ide> RxJavaPlugins.onObservableAssembly = onObservableAssembly;
<ide> }
<ide>
<add> /**
<add> * Sets the specific hook function.
<add> * @param onObservableAssembly the hook function to set, null allowed
<add> */
<add> @SuppressWarnings("rawtypes")
<add> public static void setOnConnectableObservableAssembly(Function<ConnectableObservable, ConnectableObservable> onObservableAssembly) {
<add> if (lockdown) {
<add> throw new IllegalStateException("Plugins can't be changed anymore");
<add> }
<add> RxJavaPlugins.onConnectableObservableAssembly = onConnectableObservableAssembly;
<add> }
<add>
<ide> /**
<ide> * Sets the specific hook function.
<ide> * @param onObservableSubscribe the hook function to set, null allowed
<ide> public static <T> Flowable<T> onAssembly(Flowable<T> source) {
<ide> return source;
<ide> }
<ide>
<add> /**
<add> * Calls the associated hook function.
<add> * @param <T> the value type
<add> * @param source the hook's input value
<add> * @return the value returned by the hook
<add> */
<add> @SuppressWarnings({ "rawtypes", "unchecked" })
<add> public static <T> ConnectableFlowable<T> onAssembly(ConnectableFlowable<T> source) {
<add> Function<ConnectableFlowable, ConnectableFlowable> f = onConnectableFlowableAssembly;
<add> if (f != null) {
<add> return apply(f, source);
<add> }
<add> return source;
<add> }
<add>
<ide> /**
<ide> * Calls the associated hook function.
<ide> * @param <T> the value type
<ide> public static <T> Observable<T> onAssembly(Observable<T> source) {
<ide> return source;
<ide> }
<ide>
<add> /**
<add> * Calls the associated hook function.
<add> * @param <T> the value type
<add> * @param source the hook's input value
<add> * @return the value returned by the hook
<add> */
<add> @SuppressWarnings({ "rawtypes", "unchecked" })
<add> public static <T> ConnectableObservable<T> onAssembly(ConnectableObservable<T> source) {
<add> Function<ConnectableObservable, ConnectableObservable> f = onConnectableObservableAssembly;
<add> if (f != null) {
<add> return apply(f, source);
<add> }
<add> return source;
<add> }
<add>
<ide> /**
<ide> * Calls the associated hook function.
<ide> * @param <T> the value type
<ide><path>src/main/java/io/reactivex/processors/AsyncProcessor.java
<ide> *
<ide> * @param <T> the value type
<ide> */
<del>public final class AsyncProcessor<T> extends FlowProcessor<T> {
<add>public final class AsyncProcessor<T> extends FlowableProcessor<T> {
<ide> /** The state holding onto the latest value or error and the array of subscribers. */
<ide> final State<T> state;
<ide> /**
<ide> public boolean hasSubscribers() {
<ide> return state.subscribers().length != 0;
<ide> }
<ide>
<del> @Override
<add> /**
<add> * Returns true if the subject has any value.
<add> * <p>The method is thread-safe.
<add> * @return true if the subject has any value
<add> */
<ide> public boolean hasValue() {
<ide> Object o = state.get();
<ide> return o != null && !NotificationLite.isError(o);
<ide> public Throwable getThrowable() {
<ide> return null;
<ide> }
<ide>
<del> @Override
<add> /**
<add> * Returns a single value the Subject currently has or null if no such value exists.
<add> * <p>The method is thread-safe.
<add> * @return a single value the Subject currently has or null if no such value exists
<add> */
<ide> @SuppressWarnings("unchecked")
<ide> public T getValue() {
<ide> Object o = state.get();
<ide> public T getValue() {
<ide> return null;
<ide> }
<ide>
<del> @Override
<add> /** An empty array to avoid allocation in getValues(). */
<add> private static final Object[] EMPTY = new Object[0];
<add>
<add> /**
<add> * Returns an Object array containing snapshot all values of the Subject.
<add> * <p>The method is thread-safe.
<add> * @return the array containing the snapshot of all values of the Subject
<add> */
<add> public Object[] getValues() {
<add> @SuppressWarnings("unchecked")
<add> T[] a = (T[])EMPTY;
<add> T[] b = getValues(a);
<add> if (b == EMPTY) {
<add> return new Object[0];
<add> }
<add> return b;
<add>
<add> }
<add>
<add> /**
<add> * Returns a typed array containing a snapshot of all values of the Subject.
<add> * <p>The method follows the conventions of Collection.toArray by setting the array element
<add> * after the last value to null (if the capacity permits).
<add> * <p>The method is thread-safe.
<add> * @param array the target array to copy values into if it fits
<add> * @return the given array if the values fit into it or a new array containing all values
<add> */
<ide> @SuppressWarnings("unchecked")
<ide> public T[] getValues(T[] array) {
<ide> Object o = state.get();
<ide><path>src/main/java/io/reactivex/processors/BehaviorProcessor.java
<ide> * @param <T>
<ide> * the type of item expected to be observed by the Subject
<ide> */
<del>public final class BehaviorProcessor<T> extends FlowProcessor<T> {
<add>public final class BehaviorProcessor<T> extends FlowableProcessor<T> {
<ide> final State<T> state;
<ide>
<ide> /**
<ide> public Throwable getThrowable() {
<ide> return null;
<ide> }
<ide>
<del> @Override
<add> /**
<add> * Returns a single value the Subject currently has or null if no such value exists.
<add> * <p>The method is thread-safe.
<add> * @return a single value the Subject currently has or null if no such value exists
<add> */
<ide> public T getValue() {
<ide> Object o = state.get();
<ide> if (NotificationLite.isComplete(o) || NotificationLite.isError(o)) {
<ide> public T getValue() {
<ide> return NotificationLite.getValue(o);
<ide> }
<ide>
<del> @Override
<add> /** An empty array to avoid allocation in getValues(). */
<add> private static final Object[] EMPTY = new Object[0];
<add>
<add> /**
<add> * Returns an Object array containing snapshot all values of the Subject.
<add> * <p>The method is thread-safe.
<add> * @return the array containing the snapshot of all values of the Subject
<add> */
<add> public Object[] getValues() {
<add> @SuppressWarnings("unchecked")
<add> T[] a = (T[])EMPTY;
<add> T[] b = getValues(a);
<add> if (b == EMPTY) {
<add> return new Object[0];
<add> }
<add> return b;
<add>
<add> }
<add>
<add> /**
<add> * Returns a typed array containing a snapshot of all values of the Subject.
<add> * <p>The method follows the conventions of Collection.toArray by setting the array element
<add> * after the last value to null (if the capacity permits).
<add> * <p>The method is thread-safe.
<add> * @param array the target array to copy values into if it fits
<add> * @return the given array if the values fit into it or a new array containing all values
<add> */
<ide> @SuppressWarnings("unchecked")
<ide> public T[] getValues(T[] array) {
<ide> Object o = state.get();
<ide> public boolean hasThrowable() {
<ide> return NotificationLite.isError(o);
<ide> }
<ide>
<del> @Override
<add> /**
<add> * Returns true if the subject has any value.
<add> * <p>The method is thread-safe.
<add> * @return true if the subject has any value
<add> */
<ide> public boolean hasValue() {
<ide> Object o = state.get();
<ide> return o != null && !NotificationLite.isComplete(o) && !NotificationLite.isError(o);
<add><path>src/main/java/io/reactivex/processors/FlowableProcessor.java
<del><path>src/main/java/io/reactivex/processors/FlowProcessor.java
<ide> *
<ide> * @param <T> the item value type
<ide> */
<del>public abstract class FlowProcessor<T> extends Flowable<T> implements Processor<T, T> {
<del> /** An empty array to avoid allocation in getValues(). */
<del> private static final Object[] EMPTY = new Object[0];
<del>
<add>public abstract class FlowableProcessor<T> extends Flowable<T> implements Processor<T, T> {
<ide>
<ide> /**
<ide> * Returns true if the subject has subscribers.
<ide> * @see #getThrowable()
<ide> * @see #hasComplete()
<ide> */
<del> public boolean hasThrowable() {
<del> throw new UnsupportedOperationException();
<del> }
<add> public abstract boolean hasThrowable();
<ide>
<ide> /**
<ide> * Returns true if the subject has reached a terminal state through a complete event.
<ide> * <p>The method is thread-safe.
<ide> * @return true if the subject has reached a terminal state through a complete event
<ide> * @see #hasThrowable()
<ide> */
<del> public boolean hasComplete() {
<del> throw new UnsupportedOperationException();
<del> }
<del>
<del> /**
<del> * Returns true if the subject has any value.
<del> * <p>The method is thread-safe.
<del> * @return true if the subject has any value
<del> */
<del> public boolean hasValue() {
<del> throw new UnsupportedOperationException();
<del> }
<add> public abstract boolean hasComplete();
<ide>
<ide> /**
<ide> * Returns the error that caused the Subject to terminate or null if the Subject
<ide> public boolean hasValue() {
<ide> * @return the error that caused the Subject to terminate or null if the Subject
<ide> * hasn't terminated yet
<ide> */
<del> public Throwable getThrowable() {
<del> throw new UnsupportedOperationException();
<del> }
<del>
<del> /**
<del> * Returns a single value the Subject currently has or null if no such value exists.
<del> * <p>The method is thread-safe.
<del> * @return a single value the Subject currently has or null if no such value exists
<del> */
<del> public T getValue() {
<del> throw new UnsupportedOperationException();
<del> }
<del>
<add> public abstract Throwable getThrowable();
<add>
<ide> /**
<ide> * Wraps this Subject and serializes the calls to the onSubscribe, onNext, onError and
<ide> * onComplete methods, making them thread-safe.
<ide> * <p>The method is thread-safe.
<ide> * @return the wrapped and serialized subject
<ide> */
<del> public final FlowProcessor<T> toSerialized() {
<add> public final FlowableProcessor<T> toSerialized() {
<ide> if (this instanceof SerializedProcessor) {
<ide> return this;
<ide> }
<ide> return new SerializedProcessor<T>(this);
<ide> }
<del>
<del> /**
<del> * Returns an Object array containing snapshot all values of the Subject.
<del> * <p>The method is thread-safe.
<del> * @return the array containing the snapshot of all values of the Subject
<del> */
<del> public Object[] getValues() {
<del> @SuppressWarnings("unchecked")
<del> T[] a = (T[])EMPTY;
<del> T[] b = getValues(a);
<del> if (b == EMPTY) {
<del> return new Object[0];
<del> }
<del> return b;
<del>
<del> }
<del>
<del> /**
<del> * Returns a typed array containing a snapshot of all values of the Subject.
<del> * <p>The method follows the conventions of Collection.toArray by setting the array element
<del> * after the last value to null (if the capacity permits).
<del> * <p>The method is thread-safe.
<del> * @param array the target array to copy values into if it fits
<del> * @return the given array if the values fit into it or a new array containing all values
<del> */
<del> public T[] getValues(T[] array) {
<del> throw new UnsupportedOperationException();
<del> }
<ide> }
<ide><path>src/main/java/io/reactivex/processors/PublishProcessor.java
<ide> } </pre>
<ide> * @param <T> the value type multicast to Subscribers.
<ide> */
<del>public final class PublishProcessor<T> extends FlowProcessor<T> {
<add>public final class PublishProcessor<T> extends FlowableProcessor<T> {
<ide>
<ide> /** Holds the terminal event and manages the array of subscribers. */
<ide> final State<T> state;
<ide> public boolean hasSubscribers() {
<ide> return state.subscribers().length != 0;
<ide> }
<ide>
<del> @Override
<del> public boolean hasValue() {
<del> return false;
<del> }
<del>
<del> @Override
<del> public T getValue() {
<del> return null;
<del> }
<del>
<del> @Override
<del> public T[] getValues(T[] array) {
<del> if (array.length != 0) {
<del> array[0] = null;
<del> }
<del> return array;
<del> }
<del>
<ide> @Override
<ide> public Throwable getThrowable() {
<ide> Object o = state.get();
<ide><path>src/main/java/io/reactivex/processors/ReplayProcessor.java
<ide> *
<ide> * @param <T> the value type
<ide> */
<del>public final class ReplayProcessor<T> extends FlowProcessor<T> {
<add>public final class ReplayProcessor<T> extends FlowableProcessor<T> {
<ide> final State<T> state;
<ide>
<ide> /**
<ide> public Throwable getThrowable() {
<ide> return null;
<ide> }
<ide>
<del> @Override
<add> /**
<add> * Returns a single value the Subject currently has or null if no such value exists.
<add> * <p>The method is thread-safe.
<add> * @return a single value the Subject currently has or null if no such value exists
<add> */
<ide> public T getValue() {
<ide> return state.buffer.getValue();
<ide> }
<ide>
<del> @Override
<add> /** An empty array to avoid allocation in getValues(). */
<add> private static final Object[] EMPTY = new Object[0];
<add>
<add> /**
<add> * Returns an Object array containing snapshot all values of the Subject.
<add> * <p>The method is thread-safe.
<add> * @return the array containing the snapshot of all values of the Subject
<add> */
<add> public Object[] getValues() {
<add> @SuppressWarnings("unchecked")
<add> T[] a = (T[])EMPTY;
<add> T[] b = getValues(a);
<add> if (b == EMPTY) {
<add> return new Object[0];
<add> }
<add> return b;
<add>
<add> }
<add>
<add> /**
<add> * Returns a typed array containing a snapshot of all values of the Subject.
<add> * <p>The method follows the conventions of Collection.toArray by setting the array element
<add> * after the last value to null (if the capacity permits).
<add> * <p>The method is thread-safe.
<add> * @param array the target array to copy values into if it fits
<add> * @return the given array if the values fit into it or a new array containing all values
<add> */
<ide> public T[] getValues(T[] array) {
<ide> return state.buffer.getValues(array);
<ide> }
<ide> public boolean hasThrowable() {
<ide> return NotificationLite.isError(o);
<ide> }
<ide>
<del> @Override
<add> /**
<add> * Returns true if the subject has any value.
<add> * <p>The method is thread-safe.
<add> * @return true if the subject has any value
<add> */
<ide> public boolean hasValue() {
<ide> return state.buffer.size() != 0; // NOPMD
<ide> }
<ide><path>src/main/java/io/reactivex/processors/SerializedProcessor.java
<ide> *
<ide> * @param <T> the item value type
<ide> */
<del>/* public */ final class SerializedProcessor<T> extends FlowProcessor<T> {
<add>/* public */ final class SerializedProcessor<T> extends FlowableProcessor<T> {
<ide> /** The actual subscriber to serialize Subscriber calls to. */
<del> final FlowProcessor<T> actual;
<add> final FlowableProcessor<T> actual;
<ide> /** Indicates an emission is going on, guarted by this. */
<ide> boolean emitting;
<ide> /** If not null, it holds the missed NotificationLite events. */
<ide> * Constructor that wraps an actual subject.
<ide> * @param actual the subject wrapped
<ide> */
<del> public SerializedProcessor(final FlowProcessor<T> actual) {
<add> public SerializedProcessor(final FlowableProcessor<T> actual) {
<ide> this.actual = actual;
<ide> }
<ide>
<ide> public Throwable getThrowable() {
<ide> return actual.getThrowable();
<ide> }
<ide>
<del> @Override
<del> public boolean hasValue() {
<del> return actual.hasValue();
<del> }
<del>
<del> @Override
<del> public T getValue() {
<del> return actual.getValue();
<del> }
<del>
<del> @Override
<del> public Object[] getValues() {
<del> return actual.getValues();
<del> }
<del>
<del> @Override
<del> public T[] getValues(T[] array) {
<del> return actual.getValues(array);
<del> }
<del>
<ide> @Override
<ide> public boolean hasComplete() {
<ide> return actual.hasComplete();
<ide><path>src/main/java/io/reactivex/processors/UnicastProcessor.java
<ide> *
<ide> * @param <T> the value type unicasted
<ide> */
<del>public final class UnicastProcessor<T> extends FlowProcessor<T> {
<add>public final class UnicastProcessor<T> extends FlowableProcessor<T> {
<ide>
<ide> final SpscLinkedArrayQueue<T> queue;
<ide>
<ide><path>src/main/java/io/reactivex/subjects/AsyncSubject.java
<ide> public Throwable getThrowable() {
<ide> return null;
<ide> }
<ide>
<del> @Override
<add> /**
<add> * Returns a single value the Subject currently has or null if no such value exists.
<add> * <p>The method is thread-safe.
<add> * @return a single value the Subject currently has or null if no such value exists
<add> */
<ide> public T getValue() {
<ide> Object o = state.get();
<ide> if (o != null) {
<ide> public T getValue() {
<ide> return null;
<ide> }
<ide>
<add> /** An empty array to avoid allocation in getValues(). */
<add> private static final Object[] EMPTY = new Object[0];
<add>
<add> /**
<add> * Returns an Object array containing snapshot all values of the Subject.
<add> * <p>The method is thread-safe.
<add> * @return the array containing the snapshot of all values of the Subject
<add> */
<add> public Object[] getValues() {
<add> @SuppressWarnings("unchecked")
<add> T[] a = (T[])EMPTY;
<add> T[] b = getValues(a);
<add> if (b == EMPTY) {
<add> return new Object[0];
<add> }
<add> return b;
<add>
<add> }
<add>
<add> /**
<add> * Returns a typed array containing a snapshot of all values of the Subject.
<add> * <p>The method follows the conventions of Collection.toArray by setting the array element
<add> * after the last value to null (if the capacity permits).
<add> * <p>The method is thread-safe.
<add> * @param array the target array to copy values into if it fits
<add> * @return the given array if the values fit into it or a new array containing all values
<add> */
<ide> @SuppressWarnings("unchecked")
<del> @Override
<ide> public T[] getValues(T[] array) {
<ide> Object o = state.get();
<ide> if (o != null) {
<ide> public boolean hasThrowable() {
<ide> return NotificationLite.isError(state.get());
<ide> }
<ide>
<del> @Override
<add> /**
<add> * Returns true if the subject has any value.
<add> * <p>The method is thread-safe.
<add> * @return true if the subject has any value
<add> */
<ide> public boolean hasValue() {
<ide> Object o = state.get();
<ide> return o != null && !NotificationLite.isComplete(o) && !NotificationLite.isError(o);
<ide><path>src/main/java/io/reactivex/subjects/BehaviorSubject.java
<ide> public Throwable getThrowable() {
<ide> return null;
<ide> }
<ide>
<del> @Override
<add> /**
<add> * Returns a single value the Subject currently has or null if no such value exists.
<add> * <p>The method is thread-safe.
<add> * @return a single value the Subject currently has or null if no such value exists
<add> */
<ide> public T getValue() {
<ide> Object o = state.get();
<ide> if (NotificationLite.isComplete(o) || NotificationLite.isError(o)) {
<ide> public T getValue() {
<ide> return NotificationLite.getValue(o);
<ide> }
<ide>
<del> @Override
<add> /** An empty array to avoid allocation in getValues(). */
<add> private static final Object[] EMPTY = new Object[0];
<add>
<add> /**
<add> * Returns an Object array containing snapshot all values of the Subject.
<add> * <p>The method is thread-safe.
<add> * @return the array containing the snapshot of all values of the Subject
<add> */
<add> public Object[] getValues() {
<add> @SuppressWarnings("unchecked")
<add> T[] a = (T[])EMPTY;
<add> T[] b = getValues(a);
<add> if (b == EMPTY) {
<add> return new Object[0];
<add> }
<add> return b;
<add>
<add> }
<add>
<add> /**
<add> * Returns a typed array containing a snapshot of all values of the Subject.
<add> * <p>The method follows the conventions of Collection.toArray by setting the array element
<add> * after the last value to null (if the capacity permits).
<add> * <p>The method is thread-safe.
<add> * @param array the target array to copy values into if it fits
<add> * @return the given array if the values fit into it or a new array containing all values
<add> */
<ide> @SuppressWarnings("unchecked")
<ide> public T[] getValues(T[] array) {
<ide> Object o = state.get();
<ide> public boolean hasThrowable() {
<ide> return NotificationLite.isError(o);
<ide> }
<ide>
<del> @Override
<add> /**
<add> * Returns true if the subject has any value.
<add> * <p>The method is thread-safe.
<add> * @return true if the subject has any value
<add> */
<ide> public boolean hasValue() {
<ide> Object o = state.get();
<ide> return o != null && !NotificationLite.isComplete(o) && !NotificationLite.isError(o);
<ide><path>src/main/java/io/reactivex/subjects/PublishSubject.java
<ide> public Throwable getThrowable() {
<ide> return null;
<ide> }
<ide>
<del> @Override
<del> public T getValue() {
<del> return null;
<del> }
<del>
<del> @Override
<del> public T[] getValues(T[] array) {
<del> if (array.length != 0) {
<del> array[0] = null;
<del> }
<del> return array;
<del> }
<del>
<ide> @Override
<ide> public boolean hasComplete() {
<ide> Object o = state.get();
<ide> public boolean hasThrowable() {
<ide> return NotificationLite.isError(state.get());
<ide> }
<ide>
<del> @Override
<del> public boolean hasValue() {
<del> return false;
<del> }
<del>
<ide> static final class State<T> extends AtomicReference<Object> implements ObservableSource<T>, Observer<T> {
<ide> /** */
<ide> private static final long serialVersionUID = 4876574210612691772L;
<ide><path>src/main/java/io/reactivex/subjects/ReplaySubject.java
<ide> public Throwable getThrowable() {
<ide> return null;
<ide> }
<ide>
<del> @Override
<add> /**
<add> * Returns a single value the Subject currently has or null if no such value exists.
<add> * <p>The method is thread-safe.
<add> * @return a single value the Subject currently has or null if no such value exists
<add> */
<ide> public T getValue() {
<ide> return state.buffer.getValue();
<ide> }
<ide>
<del> @Override
<add> /** An empty array to avoid allocation in getValues(). */
<add> private static final Object[] EMPTY = new Object[0];
<add>
<add> /**
<add> * Returns an Object array containing snapshot all values of the Subject.
<add> * <p>The method is thread-safe.
<add> * @return the array containing the snapshot of all values of the Subject
<add> */
<add> public Object[] getValues() {
<add> @SuppressWarnings("unchecked")
<add> T[] a = (T[])EMPTY;
<add> T[] b = getValues(a);
<add> if (b == EMPTY) {
<add> return new Object[0];
<add> }
<add> return b;
<add>
<add> }
<add>
<add> /**
<add> * Returns a typed array containing a snapshot of all values of the Subject.
<add> * <p>The method follows the conventions of Collection.toArray by setting the array element
<add> * after the last value to null (if the capacity permits).
<add> * <p>The method is thread-safe.
<add> * @param array the target array to copy values into if it fits
<add> * @return the given array if the values fit into it or a new array containing all values
<add> */
<ide> public T[] getValues(T[] array) {
<ide> return state.buffer.getValues(array);
<ide> }
<ide> public boolean hasThrowable() {
<ide> return NotificationLite.isError(o);
<ide> }
<ide>
<del> @Override
<add> /**
<add> * Returns true if the subject has any value.
<add> * <p>The method is thread-safe.
<add> * @return true if the subject has any value
<add> */
<ide> public boolean hasValue() {
<ide> return state.buffer.size() != 0; // NOPMD
<ide> }
<ide><path>src/main/java/io/reactivex/subjects/SerializedSubject.java
<ide> public Throwable getThrowable() {
<ide> return actual.getThrowable();
<ide> }
<ide>
<del> @Override
<del> public boolean hasValue() {
<del> return actual.hasValue();
<del> }
<del>
<del> @Override
<del> public T getValue() {
<del> return actual.getValue();
<del> }
<del>
<del> @Override
<del> public Object[] getValues() {
<del> return actual.getValues();
<del> }
<del>
<del> @Override
<del> public T[] getValues(T[] array) {
<del> return actual.getValues(array);
<del> }
<del>
<ide> @Override
<ide> public boolean hasComplete() {
<ide> return actual.hasComplete();
<ide><path>src/main/java/io/reactivex/subjects/Subject.java
<ide> * @param <T> the item value type
<ide> */
<ide> public abstract class Subject<T> extends Observable<T> implements Observer<T> {
<del> /** An empty array to avoid allocation in getValues(). */
<del> private static final Object[] EMPTY = new Object[0];
<del>
<ide> /**
<ide> * Returns true if the subject has any Observers.
<ide> * <p>The method is thread-safe.
<ide> * @see #getThrowable()
<ide> * &see {@link #hasComplete()}
<ide> */
<del> public boolean hasThrowable() {
<del> throw new UnsupportedOperationException();
<del> }
<add> public abstract boolean hasThrowable();
<ide>
<ide> /**
<ide> * Returns true if the subject has reached a terminal state through a complete event.
<ide> * <p>The method is thread-safe.
<ide> * @return true if the subject has reached a terminal state through a complete event
<ide> * @see #hasThrowable()
<ide> */
<del> public boolean hasComplete() {
<del> throw new UnsupportedOperationException();
<del> }
<del>
<del> /**
<del> * Returns true if the subject has any value.
<del> * <p>The method is thread-safe.
<del> * @return true if the subject has any value
<del> */
<del> public boolean hasValue() {
<del> throw new UnsupportedOperationException();
<del> }
<add> public abstract boolean hasComplete();
<ide>
<ide> /**
<ide> * Returns the error that caused the Subject to terminate or null if the Subject
<ide> public boolean hasValue() {
<ide> * @return the error that caused the Subject to terminate or null if the Subject
<ide> * hasn't terminated yet
<ide> */
<del> public Throwable getThrowable() {
<del> throw new UnsupportedOperationException();
<del> }
<del>
<del> /**
<del> * Returns a single value the Subject currently has or null if no such value exists.
<del> * <p>The method is thread-safe.
<del> * @return a single value the Subject currently has or null if no such value exists
<del> */
<del> public T getValue() {
<del> throw new UnsupportedOperationException();
<del> }
<add> public abstract Throwable getThrowable();
<ide>
<ide> /**
<ide> * Wraps this Subject and serializes the calls to the onSubscribe, onNext, onError and
<ide> public final Subject<T> toSerialized() {
<ide> }
<ide> return new SerializedSubject<T>(this);
<ide> }
<del>
<del> /**
<del> * Returns an Object array containing snapshot all values of the Subject.
<del> * <p>The method is thread-safe.
<del> * @return the array containing the snapshot of all values of the Subject
<del> */
<del> public Object[] getValues() {
<del> @SuppressWarnings("unchecked")
<del> T[] a = (T[])EMPTY;
<del> T[] b = getValues(a);
<del> if (b == EMPTY) {
<del> return new Object[0];
<del> }
<del> return b;
<del>
<del> }
<del>
<del> /**
<del> * Returns a typed array containing a snapshot of all values of the Subject.
<del> * <p>The method follows the conventions of Collection.toArray by setting the array element
<del> * after the last value to null (if the capacity permits).
<del> * <p>The method is thread-safe.
<del> * @param array the target array to copy values into if it fits
<del> * @return the given array if the values fit into it or a new array containing all values
<del> */
<del> public T[] getValues(T[] array) {
<del> throw new UnsupportedOperationException();
<del> }
<ide> }
<ide><path>src/main/java/io/reactivex/subjects/UnicastSubject.java
<ide> public boolean hasComplete() {
<ide> State<T> s = state;
<ide> return s.done && s.error == null;
<ide> }
<del>
<del> @Override
<del> public boolean hasValue() {
<del> return false;
<del> }
<del>
<del> @Override
<del> public T getValue() {
<del> return null;
<del> }
<del>
<del> @Override
<del> public T[] getValues(T[] array) {
<del> if (array.length != 0) {
<del> array[0] = null;
<del> }
<del> return array;
<del> }
<ide> }
<ide><path>src/test/java/io/reactivex/completable/CompletableTest.java
<ide> public void complete() {
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void concatNull() {
<del> Completable.concat((Completable[])null);
<add> Completable.concatArray((Completable[])null);
<ide> }
<ide>
<ide> @Test(timeout = 1000)
<ide> public void concatEmpty() {
<del> Completable c = Completable.concat();
<add> Completable c = Completable.concatArray();
<ide>
<ide> c.blockingAwait();
<ide> }
<ide>
<ide> @Test(timeout = 1000)
<ide> public void concatSingleSource() {
<del> Completable c = Completable.concat(normal.completable);
<add> Completable c = Completable.concatArray(normal.completable);
<ide>
<ide> c.blockingAwait();
<ide>
<ide> public void concatSingleSource() {
<ide>
<ide> @Test(timeout = 1000, expected = TestException.class)
<ide> public void concatSingleSourceThrows() {
<del> Completable c = Completable.concat(error.completable);
<add> Completable c = Completable.concatArray(error.completable);
<ide>
<ide> c.blockingAwait();
<ide> }
<ide>
<ide> @Test(timeout = 1000)
<ide> public void concatMultipleSources() {
<del> Completable c = Completable.concat(normal.completable, normal.completable, normal.completable);
<add> Completable c = Completable.concatArray(normal.completable, normal.completable, normal.completable);
<ide>
<ide> c.blockingAwait();
<ide>
<ide> public void concatMultipleSources() {
<ide>
<ide> @Test(timeout = 1000, expected = TestException.class)
<ide> public void concatMultipleOneThrows() {
<del> Completable c = Completable.concat(normal.completable, error.completable, normal.completable);
<add> Completable c = Completable.concatArray(normal.completable, error.completable, normal.completable);
<ide>
<ide> c.blockingAwait();
<ide> }
<ide>
<ide> @Test(timeout = 1000, expected = NullPointerException.class)
<ide> public void concatMultipleOneIsNull() {
<del> Completable c = Completable.concat(normal.completable, null);
<add> Completable c = Completable.concatArray(normal.completable, null);
<ide>
<ide> c.blockingAwait();
<ide> }
<ide> public Throwable call() {
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void mergeNull() {
<del> Completable.merge((Completable[])null);
<add> Completable.mergeArray((Completable[])null);
<ide> }
<ide>
<ide> @Test(timeout = 1000)
<ide> public void mergeEmpty() {
<del> Completable c = Completable.merge();
<add> Completable c = Completable.mergeArray();
<ide>
<ide> c.blockingAwait();
<ide> }
<ide>
<ide> @Test(timeout = 1000)
<ide> public void mergeSingleSource() {
<del> Completable c = Completable.merge(normal.completable);
<add> Completable c = Completable.mergeArray(normal.completable);
<ide>
<ide> c.blockingAwait();
<ide>
<ide> public void mergeSingleSource() {
<ide>
<ide> @Test(timeout = 1000, expected = TestException.class)
<ide> public void mergeSingleSourceThrows() {
<del> Completable c = Completable.merge(error.completable);
<add> Completable c = Completable.mergeArray(error.completable);
<ide>
<ide> c.blockingAwait();
<ide> }
<ide>
<ide> @Test(timeout = 1000)
<ide> public void mergeMultipleSources() {
<del> Completable c = Completable.merge(normal.completable, normal.completable, normal.completable);
<add> Completable c = Completable.mergeArray(normal.completable, normal.completable, normal.completable);
<ide>
<ide> c.blockingAwait();
<ide>
<ide> public void mergeMultipleSources() {
<ide>
<ide> @Test(timeout = 1000, expected = TestException.class)
<ide> public void mergeMultipleOneThrows() {
<del> Completable c = Completable.merge(normal.completable, error.completable, normal.completable);
<add> Completable c = Completable.mergeArray(normal.completable, error.completable, normal.completable);
<ide>
<ide> c.blockingAwait();
<ide> }
<ide>
<ide> @Test(timeout = 1000, expected = NullPointerException.class)
<ide> public void mergeMultipleOneIsNull() {
<del> Completable c = Completable.merge(normal.completable, null);
<add> Completable c = Completable.mergeArray(normal.completable, null);
<ide>
<ide> c.blockingAwait();
<ide> }
<ide> public void accept(long v) {
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void mergeDelayErrorNull() {
<del> Completable.mergeDelayError((Completable[])null);
<add> Completable.mergeArrayDelayError((Completable[])null);
<ide> }
<ide>
<ide> @Test(timeout = 1000)
<ide> public void mergeDelayErrorEmpty() {
<del> Completable c = Completable.mergeDelayError();
<add> Completable c = Completable.mergeArrayDelayError();
<ide>
<ide> c.blockingAwait();
<ide> }
<ide>
<ide> @Test(timeout = 1000)
<ide> public void mergeDelayErrorSingleSource() {
<del> Completable c = Completable.mergeDelayError(normal.completable);
<add> Completable c = Completable.mergeArrayDelayError(normal.completable);
<ide>
<ide> c.blockingAwait();
<ide>
<ide> public void mergeDelayErrorSingleSource() {
<ide>
<ide> @Test(timeout = 1000, expected = TestException.class)
<ide> public void mergeDelayErrorSingleSourceThrows() {
<del> Completable c = Completable.mergeDelayError(error.completable);
<add> Completable c = Completable.mergeArrayDelayError(error.completable);
<ide>
<ide> c.blockingAwait();
<ide> }
<ide>
<ide> @Test(timeout = 1000)
<ide> public void mergeDelayErrorMultipleSources() {
<del> Completable c = Completable.mergeDelayError(normal.completable, normal.completable, normal.completable);
<add> Completable c = Completable.mergeArrayDelayError(normal.completable, normal.completable, normal.completable);
<ide>
<ide> c.blockingAwait();
<ide>
<ide> public void mergeDelayErrorMultipleSources() {
<ide>
<ide> @Test(timeout = 1000)
<ide> public void mergeDelayErrorMultipleOneThrows() {
<del> Completable c = Completable.mergeDelayError(normal.completable, error.completable, normal.completable);
<add> Completable c = Completable.mergeArrayDelayError(normal.completable, error.completable, normal.completable);
<ide>
<ide> try {
<ide> c.blockingAwait();
<ide> public void mergeDelayErrorMultipleOneThrows() {
<ide>
<ide> @Test(timeout = 1000, expected = NullPointerException.class)
<ide> public void mergeDelayErrorMultipleOneIsNull() {
<del> Completable c = Completable.mergeDelayError(normal.completable, null);
<add> Completable c = Completable.mergeArrayDelayError(normal.completable, null);
<ide>
<ide> c.blockingAwait();
<ide> }
<ide> public void onComplete() {
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void ambArrayNull() {
<del> Completable.amb((Completable[])null);
<add> Completable.ambArray((Completable[])null);
<ide> }
<ide>
<ide> @Test(timeout = 1000)
<ide> public void ambArrayEmpty() {
<del> Completable c = Completable.amb();
<add> Completable c = Completable.ambArray();
<ide>
<ide> c.blockingAwait();
<ide> }
<ide>
<ide> @Test(timeout = 1000)
<ide> public void ambArraySingleNormal() {
<del> Completable c = Completable.amb(normal.completable);
<add> Completable c = Completable.ambArray(normal.completable);
<ide>
<ide> c.blockingAwait();
<ide> }
<ide>
<ide> @Test(timeout = 1000, expected = TestException.class)
<ide> public void ambArraySingleError() {
<del> Completable c = Completable.amb(error.completable);
<add> Completable c = Completable.ambArray(error.completable);
<ide>
<ide> c.blockingAwait();
<ide> }
<ide> public void ambArrayOneFires() {
<ide>
<ide> Completable c2 = Completable.fromPublisher(ps2);
<ide>
<del> Completable c = Completable.amb(c1, c2);
<add> Completable c = Completable.ambArray(c1, c2);
<ide>
<ide> final AtomicBoolean complete = new AtomicBoolean();
<ide>
<ide> public void ambArrayOneFiresError() {
<ide>
<ide> Completable c2 = Completable.fromPublisher(ps2);
<ide>
<del> Completable c = Completable.amb(c1, c2);
<add> Completable c = Completable.ambArray(c1, c2);
<ide>
<ide> final AtomicReference<Throwable> complete = new AtomicReference<Throwable>();
<ide>
<ide> public void ambArraySecondFires() {
<ide>
<ide> Completable c2 = Completable.fromPublisher(ps2);
<ide>
<del> Completable c = Completable.amb(c1, c2);
<add> Completable c = Completable.ambArray(c1, c2);
<ide>
<ide> final AtomicBoolean complete = new AtomicBoolean();
<ide>
<ide> public void ambArraySecondFiresError() {
<ide>
<ide> Completable c2 = Completable.fromPublisher(ps2);
<ide>
<del> Completable c = Completable.amb(c1, c2);
<add> Completable c = Completable.ambArray(c1, c2);
<ide>
<ide> final AtomicReference<Throwable> complete = new AtomicReference<Throwable>();
<ide>
<ide> public void accept(Throwable v) {
<ide>
<ide> @Test(timeout = 1000, expected = NullPointerException.class)
<ide> public void ambMultipleOneIsNull() {
<del> Completable c = Completable.amb(null, normal.completable);
<add> Completable c = Completable.ambArray(null, normal.completable);
<ide>
<ide> c.blockingAwait();
<ide> }
<ide><path>src/test/java/io/reactivex/flowable/FlowableCollectTest.java
<add>/**
<add> * Copyright 2016 Netflix, Inc.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
<add> * compliance with the License. You may obtain a copy of the License at
<add> *
<add> * http://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software distributed under the License is
<add> * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
<add> * the License for the specific language governing permissions and limitations under the License.
<add> */
<add>
<ide> package io.reactivex.flowable;
<ide>
<ide> import static org.junit.Assert.assertEquals;
<ide><path>src/test/java/io/reactivex/flowable/FlowableNullTests.java
<ide> public class FlowableNullTests {
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void ambVarargsNull() {
<del> Flowable.amb((Publisher<Object>[])null);
<add> Flowable.ambArray((Publisher<Object>[])null);
<ide> }
<ide>
<ide> @SuppressWarnings("unchecked")
<ide> @Test(expected = NullPointerException.class)
<ide> public void ambVarargsOneIsNull() {
<del> Flowable.amb(Flowable.never(), null).blockingLast();
<add> Flowable.ambArray(Flowable.never(), null).blockingLast();
<ide> }
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public Object apply(Integer a, Integer b) {
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void asyncSubjectOnNextNull() {
<del> FlowProcessor<Integer> subject = AsyncProcessor.create();
<add> FlowableProcessor<Integer> subject = AsyncProcessor.create();
<ide> subject.onNext(null);
<ide> subject.blockingSubscribe();
<ide> }
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void asyncSubjectOnErrorNull() {
<del> FlowProcessor<Integer> subject = AsyncProcessor.create();
<add> FlowableProcessor<Integer> subject = AsyncProcessor.create();
<ide> subject.onError(null);
<ide> subject.blockingSubscribe();
<ide> }
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void behaviorSubjectOnNextNull() {
<del> FlowProcessor<Integer> subject = BehaviorProcessor.create();
<add> FlowableProcessor<Integer> subject = BehaviorProcessor.create();
<ide> subject.onNext(null);
<ide> subject.blockingSubscribe();
<ide> }
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void behaviorSubjectOnErrorNull() {
<del> FlowProcessor<Integer> subject = BehaviorProcessor.create();
<add> FlowableProcessor<Integer> subject = BehaviorProcessor.create();
<ide> subject.onError(null);
<ide> subject.blockingSubscribe();
<ide> }
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void publishSubjectOnNextNull() {
<del> FlowProcessor<Integer> subject = PublishProcessor.create();
<add> FlowableProcessor<Integer> subject = PublishProcessor.create();
<ide> subject.onNext(null);
<ide> subject.blockingSubscribe();
<ide> }
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void publishSubjectOnErrorNull() {
<del> FlowProcessor<Integer> subject = PublishProcessor.create();
<add> FlowableProcessor<Integer> subject = PublishProcessor.create();
<ide> subject.onError(null);
<ide> subject.blockingSubscribe();
<ide> }
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void replaycSubjectOnNextNull() {
<del> FlowProcessor<Integer> subject = ReplayProcessor.create();
<add> FlowableProcessor<Integer> subject = ReplayProcessor.create();
<ide> subject.onNext(null);
<ide> subject.blockingSubscribe();
<ide> }
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void replaySubjectOnErrorNull() {
<del> FlowProcessor<Integer> subject = ReplayProcessor.create();
<add> FlowableProcessor<Integer> subject = ReplayProcessor.create();
<ide> subject.onError(null);
<ide> subject.blockingSubscribe();
<ide> }
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void serializedcSubjectOnNextNull() {
<del> FlowProcessor<Integer> subject = PublishProcessor.<Integer>create().toSerialized();
<add> FlowableProcessor<Integer> subject = PublishProcessor.<Integer>create().toSerialized();
<ide> subject.onNext(null);
<ide> subject.blockingSubscribe();
<ide> }
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void serializedSubjectOnErrorNull() {
<del> FlowProcessor<Integer> subject = PublishProcessor.<Integer>create().toSerialized();
<add> FlowableProcessor<Integer> subject = PublishProcessor.<Integer>create().toSerialized();
<ide> subject.onError(null);
<ide> subject.blockingSubscribe();
<ide> }
<ide><path>src/test/java/io/reactivex/flowable/FlowableTests.java
<ide> public String apply(Integer v) {
<ide>
<ide> @Test
<ide> public void testErrorThrownIssue1685() {
<del> FlowProcessor<Object> subject = ReplayProcessor.create();
<add> FlowableProcessor<Object> subject = ReplayProcessor.create();
<ide>
<ide> Flowable.error(new RuntimeException("oops"))
<ide> .materialize()
<ide><path>src/test/java/io/reactivex/internal/operators/flowable/BlockingFlowableMostRecentTest.java
<ide> public void testMostRecentNull() {
<ide>
<ide> @Test
<ide> public void testMostRecent() {
<del> FlowProcessor<String> s = PublishProcessor.create();
<add> FlowableProcessor<String> s = PublishProcessor.create();
<ide>
<ide> Iterator<String> it = s.blockingMostRecent("default").iterator();
<ide>
<ide> public void testMostRecent() {
<ide>
<ide> @Test(expected = TestException.class)
<ide> public void testMostRecentWithException() {
<del> FlowProcessor<String> s = PublishProcessor.create();
<add> FlowableProcessor<String> s = PublishProcessor.create();
<ide>
<ide> Iterator<String> it = s.blockingMostRecent("default").iterator();
<ide>
<ide><path>src/test/java/io/reactivex/internal/operators/flowable/BlockingFlowableNextTest.java
<ide>
<ide> public class BlockingFlowableNextTest {
<ide>
<del> private void fireOnNextInNewThread(final FlowProcessor<String> o, final String value) {
<add> private void fireOnNextInNewThread(final FlowableProcessor<String> o, final String value) {
<ide> new Thread() {
<ide> @Override
<ide> public void run() {
<ide> public void run() {
<ide> }.start();
<ide> }
<ide>
<del> private void fireOnErrorInNewThread(final FlowProcessor<String> o) {
<add> private void fireOnErrorInNewThread(final FlowableProcessor<String> o) {
<ide> new Thread() {
<ide> @Override
<ide> public void run() {
<ide> public void run() {
<ide>
<ide> @Test
<ide> public void testNext() {
<del> FlowProcessor<String> obs = PublishProcessor.create();
<add> FlowableProcessor<String> obs = PublishProcessor.create();
<ide> Iterator<String> it = obs.blockingNext().iterator();
<ide> fireOnNextInNewThread(obs, "one");
<ide> assertTrue(it.hasNext());
<ide> public void testNext() {
<ide>
<ide> @Test
<ide> public void testNextWithError() {
<del> FlowProcessor<String> obs = PublishProcessor.create();
<add> FlowableProcessor<String> obs = PublishProcessor.create();
<ide> Iterator<String> it = obs.blockingNext().iterator();
<ide> fireOnNextInNewThread(obs, "one");
<ide> assertTrue(it.hasNext());
<ide> public void testNextWithEmpty() {
<ide>
<ide> @Test
<ide> public void testOnError() throws Throwable {
<del> FlowProcessor<String> obs = PublishProcessor.create();
<add> FlowableProcessor<String> obs = PublishProcessor.create();
<ide> Iterator<String> it = obs.blockingNext().iterator();
<ide>
<ide> obs.onError(new TestException());
<ide> public void testOnError() throws Throwable {
<ide>
<ide> @Test
<ide> public void testOnErrorInNewThread() {
<del> FlowProcessor<String> obs = PublishProcessor.create();
<add> FlowableProcessor<String> obs = PublishProcessor.create();
<ide> Iterator<String> it = obs.blockingNext().iterator();
<ide>
<ide> fireOnErrorInNewThread(obs);
<ide> private void assertErrorAfterObservableFail(Iterator<String> it) {
<ide>
<ide> @Test
<ide> public void testNextWithOnlyUsingNextMethod() {
<del> FlowProcessor<String> obs = PublishProcessor.create();
<add> FlowableProcessor<String> obs = PublishProcessor.create();
<ide> Iterator<String> it = obs.blockingNext().iterator();
<ide> fireOnNextInNewThread(obs, "one");
<ide> assertEquals("one", it.next());
<ide> public void testNextWithOnlyUsingNextMethod() {
<ide>
<ide> @Test
<ide> public void testNextWithCallingHasNextMultipleTimes() {
<del> FlowProcessor<String> obs = PublishProcessor.create();
<add> FlowableProcessor<String> obs = PublishProcessor.create();
<ide> Iterator<String> it = obs.blockingNext().iterator();
<ide> fireOnNextInNewThread(obs, "one");
<ide> assertTrue(it.hasNext());
<ide> public void run() {
<ide>
<ide> @Test /* (timeout = 8000) */
<ide> public void testSingleSourceManyIterators() throws InterruptedException {
<del> Flowable<Long> o = Flowable.interval(100, TimeUnit.MILLISECONDS);
<add> Flowable<Long> o = Flowable.interval(250, TimeUnit.MILLISECONDS);
<ide> PublishProcessor<Integer> terminal = PublishProcessor.create();
<ide> Flowable<Long> source = o.takeUntil(terminal);
<ide>
<ide><path>src/test/java/io/reactivex/internal/operators/flowable/FlowableAmbTest.java
<ide> public void testAmb() {
<ide> "3", "33", "333", "3333" }, 3000, null);
<ide>
<ide> @SuppressWarnings("unchecked")
<del> Flowable<String> o = Flowable.amb(Flowable1,
<add> Flowable<String> o = Flowable.ambArray(Flowable1,
<ide> Flowable2, Flowable3);
<ide>
<ide> @SuppressWarnings("unchecked")
<ide> public void testAmb2() {
<ide> 3000, new IOException("fake exception"));
<ide>
<ide> @SuppressWarnings("unchecked")
<del> Flowable<String> o = Flowable.amb(Flowable1,
<add> Flowable<String> o = Flowable.ambArray(Flowable1,
<ide> Flowable2, Flowable3);
<ide>
<ide> @SuppressWarnings("unchecked")
<ide> public void testAmb3() {
<ide> "3" }, 3000, null);
<ide>
<ide> @SuppressWarnings("unchecked")
<del> Flowable<String> o = Flowable.amb(Flowable1,
<add> Flowable<String> o = Flowable.ambArray(Flowable1,
<ide> Flowable2, Flowable3);
<ide>
<ide> @SuppressWarnings("unchecked")
<ide> public void cancel() {
<ide> }
<ide>
<ide> });
<del> Flowable.amb(o1, o2).subscribe(ts);
<add> Flowable.ambArray(o1, o2).subscribe(ts);
<ide> assertEquals(3, requested1.get());
<ide> assertEquals(3, requested2.get());
<ide> }
<ide> public void accept(Subscription s) {
<ide> Flowable<Integer> o2 = Flowable.just(1).doOnSubscribe(incrementer)
<ide> .delay(100, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.computation());
<ide> TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
<del> Flowable.amb(o1, o2).subscribe(ts);
<add> Flowable.ambArray(o1, o2).subscribe(ts);
<ide> ts.request(1);
<ide> ts.awaitTerminalEvent(5, TimeUnit.SECONDS);
<ide> ts.assertNoErrors();
<ide> public void testSecondaryRequestsPropagatedToChildren() throws InterruptedExcept
<ide> .delay(200, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.computation());
<ide> TestSubscriber<Integer> ts = new TestSubscriber<Integer>(1L);
<ide>
<del> Flowable.amb(o1, o2).subscribe(ts);
<add> Flowable.ambArray(o1, o2).subscribe(ts);
<ide> // before first emission request 20 more
<ide> // this request should suffice to emit all
<ide> ts.request(20);
<ide> public void testAmbCancelsOthers() {
<ide>
<ide> TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
<ide>
<del> Flowable.amb(source1, source2, source3).subscribe(ts);
<add> Flowable.ambArray(source1, source2, source3).subscribe(ts);
<ide>
<ide> assertTrue("Source 1 doesn't have subscribers!", source1.hasSubscribers());
<ide> assertTrue("Source 2 doesn't have subscribers!", source2.hasSubscribers());
<ide><path>src/test/java/io/reactivex/internal/operators/flowable/FlowableCacheTest.java
<ide> public class FlowableCacheTest {
<ide> @Test
<ide> public void testColdReplayNoBackpressure() {
<del> FlowableCache<Integer> source = FlowableCache.from(Flowable.range(0, 1000));
<add> FlowableCache<Integer> source = (FlowableCache<Integer>)FlowableCache.from(Flowable.range(0, 1000));
<ide>
<ide> assertFalse("Source is connected!", source.isConnected());
<ide>
<ide> public void testColdReplayNoBackpressure() {
<ide> }
<ide> @Test
<ide> public void testColdReplayBackpressure() {
<del> FlowableCache<Integer> source = FlowableCache.from(Flowable.range(0, 1000));
<add> FlowableCache<Integer> source = (FlowableCache<Integer>)FlowableCache.from(Flowable.range(0, 1000));
<ide>
<ide> assertFalse("Source is connected!", source.isConnected());
<ide>
<ide> public void testUnsubscribeSource() throws Exception {
<ide> public void testTake() {
<ide> TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
<ide>
<del> FlowableCache<Integer> cached = FlowableCache.from(Flowable.range(1, 100));
<add> FlowableCache<Integer> cached = (FlowableCache<Integer>)FlowableCache.from(Flowable.range(1, 100));
<ide> cached.take(10).subscribe(ts);
<ide>
<ide> ts.assertNoErrors();
<ide> public void testAsync() {
<ide> for (int i = 0; i < 100; i++) {
<ide> TestSubscriber<Integer> ts1 = new TestSubscriber<Integer>();
<ide>
<del> FlowableCache<Integer> cached = FlowableCache.from(source);
<add> FlowableCache<Integer> cached = (FlowableCache<Integer>)FlowableCache.from(source);
<ide>
<ide> cached.observeOn(Schedulers.computation()).subscribe(ts1);
<ide>
<ide> public void testAsyncComeAndGo() {
<ide> Flowable<Long> source = Flowable.interval(1, 1, TimeUnit.MILLISECONDS)
<ide> .take(1000)
<ide> .subscribeOn(Schedulers.io());
<del> FlowableCache<Long> cached = FlowableCache.from(source);
<add> FlowableCache<Long> cached = (FlowableCache<Long>)FlowableCache.from(source);
<ide>
<ide> Flowable<Long> output = cached.observeOn(Schedulers.computation());
<ide>
<ide><path>src/test/java/io/reactivex/internal/operators/flowable/FlowableConcatTest.java
<ide> public Flowable<Integer> apply(Integer t) {
<ide> Flowable<Integer> observable = Flowable.just(t)
<ide> .subscribeOn(sch)
<ide> ;
<del> FlowProcessor<Integer> subject = new UnicastProcessor<Integer>();
<add> FlowableProcessor<Integer> subject = new UnicastProcessor<Integer>();
<ide> observable.subscribe(subject);
<ide> return subject;
<ide> }
<ide><path>src/test/java/io/reactivex/internal/operators/flowable/FlowableTakeWhileTest.java
<ide> public boolean test(Integer input) {
<ide>
<ide> @Test
<ide> public void testTakeWhileOnSubject1() {
<del> FlowProcessor<Integer> s = PublishProcessor.create();
<add> FlowableProcessor<Integer> s = PublishProcessor.create();
<ide> Flowable<Integer> take = s.takeWhile(new Predicate<Integer>() {
<ide> @Override
<ide> public boolean test(Integer input) {
<ide><path>src/test/java/io/reactivex/internal/operators/observable/BlockingObservableNextTest.java
<ide> public void run() {
<ide>
<ide> @Test /* (timeout = 8000) */
<ide> public void testSingleSourceManyIterators() throws InterruptedException {
<del> Observable<Long> o = Observable.interval(100, TimeUnit.MILLISECONDS);
<add> Observable<Long> o = Observable.interval(250, TimeUnit.MILLISECONDS);
<ide> PublishSubject<Integer> terminal = PublishSubject.create();
<ide> Observable<Long> source = o.takeUntil(terminal);
<ide>
<ide><path>src/test/java/io/reactivex/internal/operators/observable/ObservableAmbTest.java
<ide> public void testAmb() {
<ide> "3", "33", "333", "3333" }, 3000, null);
<ide>
<ide> @SuppressWarnings("unchecked")
<del> Observable<String> o = Observable.amb(observable1,
<add> Observable<String> o = Observable.ambArray(observable1,
<ide> observable2, observable3);
<ide>
<ide> Observer<String> NbpObserver = TestHelper.mockObserver();
<ide> public void testAmb2() {
<ide> 3000, new IOException("fake exception"));
<ide>
<ide> @SuppressWarnings("unchecked")
<del> Observable<String> o = Observable.amb(observable1,
<add> Observable<String> o = Observable.ambArray(observable1,
<ide> observable2, observable3);
<ide>
<ide> Observer<String> NbpObserver = TestHelper.mockObserver();
<ide> public void testAmb3() {
<ide> "3" }, 3000, null);
<ide>
<ide> @SuppressWarnings("unchecked")
<del> Observable<String> o = Observable.amb(observable1,
<add> Observable<String> o = Observable.ambArray(observable1,
<ide> observable2, observable3);
<ide>
<ide> Observer<String> NbpObserver = TestHelper.mockObserver();
<ide> public void accept(Disposable s) {
<ide> Observable<Integer> o2 = Observable.just(1).doOnSubscribe(incrementer)
<ide> .delay(100, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.computation());
<ide> TestObserver<Integer> ts = new TestObserver<Integer>();
<del> Observable.amb(o1, o2).subscribe(ts);
<add> Observable.ambArray(o1, o2).subscribe(ts);
<ide> ts.awaitTerminalEvent(5, TimeUnit.SECONDS);
<ide> ts.assertNoErrors();
<ide> assertEquals(2, count.get());
<ide> public void testAmbCancelsOthers() {
<ide>
<ide> TestObserver<Integer> ts = new TestObserver<Integer>();
<ide>
<del> Observable.amb(source1, source2, source3).subscribe(ts);
<add> Observable.ambArray(source1, source2, source3).subscribe(ts);
<ide>
<ide> assertTrue("Source 1 doesn't have subscribers!", source1.hasObservers());
<ide> assertTrue("Source 2 doesn't have subscribers!", source2.hasObservers());
<ide><path>src/test/java/io/reactivex/internal/operators/observable/ObservableCacheTest.java
<ide> public class ObservableCacheTest {
<ide> @Test
<ide> public void testColdReplayNoBackpressure() {
<del> ObservableCache<Integer> source = ObservableCache.from(Observable.range(0, 1000));
<add> ObservableCache<Integer> source = (ObservableCache<Integer>)ObservableCache.from(Observable.range(0, 1000));
<ide>
<ide> assertFalse("Source is connected!", source.isConnected());
<ide>
<ide> public void testUnsubscribeSource() throws Exception {
<ide> public void testTake() {
<ide> TestObserver<Integer> ts = new TestObserver<Integer>();
<ide>
<del> ObservableCache<Integer> cached = ObservableCache.from(Observable.range(1, 100));
<add> ObservableCache<Integer> cached = (ObservableCache<Integer>)ObservableCache.from(Observable.range(1, 100));
<ide> cached.take(10).subscribe(ts);
<ide>
<ide> ts.assertNoErrors();
<ide> public void testAsync() {
<ide> for (int i = 0; i < 100; i++) {
<ide> TestObserver<Integer> ts1 = new TestObserver<Integer>();
<ide>
<del> ObservableCache<Integer> cached = ObservableCache.from(source);
<add> ObservableCache<Integer> cached = (ObservableCache<Integer>)ObservableCache.from(source);
<ide>
<ide> cached.observeOn(Schedulers.computation()).subscribe(ts1);
<ide>
<ide> public void testAsyncComeAndGo() {
<ide> Observable<Long> source = Observable.interval(1, 1, TimeUnit.MILLISECONDS)
<ide> .take(1000)
<ide> .subscribeOn(Schedulers.io());
<del> ObservableCache<Long> cached = ObservableCache.from(source);
<add> ObservableCache<Long> cached = (ObservableCache<Long>)ObservableCache.from(source);
<ide>
<ide> Observable<Long> output = cached.observeOn(Schedulers.computation());
<ide>
<ide><path>src/test/java/io/reactivex/observable/ObservableNullTests.java
<ide> public class ObservableNullTests {
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void ambVarargsNull() {
<del> Observable.amb((Observable<Object>[])null);
<add> Observable.ambArray((Observable<Object>[])null);
<ide> }
<ide>
<ide> @SuppressWarnings("unchecked")
<ide> @Test(expected = NullPointerException.class)
<ide> public void ambVarargsOneIsNull() {
<del> Observable.amb(Observable.never(), null).blockingLast();
<add> Observable.ambArray(Observable.never(), null).blockingLast();
<ide> }
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide><path>src/test/java/io/reactivex/processors/SerializedProcessorTest.java
<ide> public void testAsyncSubjectValueRelay() {
<ide> AsyncProcessor<Integer> async = AsyncProcessor.create();
<ide> async.onNext(1);
<ide> async.onComplete();
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertEquals((Integer)1, serial.getValue());
<del> assertTrue(serial.hasValue());
<del> assertArrayEquals(new Object[] { 1 }, serial.getValues());
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { 1, null }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertEquals((Integer)1, async.getValue());
<add> assertTrue(async.hasValue());
<add> assertArrayEquals(new Object[] { 1 }, async.getValues());
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testAsyncSubjectValueEmpty() {
<ide> AsyncProcessor<Integer> async = AsyncProcessor.create();
<ide> async.onComplete();
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testAsyncSubjectValueError() {
<ide> AsyncProcessor<Integer> async = AsyncProcessor.create();
<ide> TestException te = new TestException();
<ide> async.onError(te);
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertFalse(serial.hasComplete());
<ide> assertTrue(serial.hasThrowable());
<ide> assertSame(te, serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testPublishSubjectValueRelay() {
<ide> PublishProcessor<Integer> async = PublishProcessor.create();
<ide> async.onNext(1);
<ide> async.onComplete();
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del>
<del> assertArrayEquals(new Object[0], serial.getValues());
<del> assertArrayEquals(new Integer[0], serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide>
<ide> @Test
<ide> public void testPublishSubjectValueEmpty() {
<ide> PublishProcessor<Integer> async = PublishProcessor.create();
<ide> async.onComplete();
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testPublishSubjectValueError() {
<ide> PublishProcessor<Integer> async = PublishProcessor.create();
<ide> TestException te = new TestException();
<ide> async.onError(te);
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertFalse(serial.hasComplete());
<ide> assertTrue(serial.hasThrowable());
<ide> assertSame(te, serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide>
<ide> @Test
<ide> public void testBehaviorSubjectValueRelay() {
<ide> BehaviorProcessor<Integer> async = BehaviorProcessor.create();
<ide> async.onNext(1);
<ide> async.onComplete();
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testBehaviorSubjectValueRelayIncomplete() {
<ide> BehaviorProcessor<Integer> async = BehaviorProcessor.create();
<ide> async.onNext(1);
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertFalse(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertEquals((Integer)1, serial.getValue());
<del> assertTrue(serial.hasValue());
<del> assertArrayEquals(new Object[] { 1 }, serial.getValues());
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { 1, null }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertEquals((Integer)1, async.getValue());
<add> assertTrue(async.hasValue());
<add> assertArrayEquals(new Object[] { 1 }, async.getValues());
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testBehaviorSubjectIncompleteEmpty() {
<ide> BehaviorProcessor<Integer> async = BehaviorProcessor.create();
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertFalse(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testBehaviorSubjectEmpty() {
<ide> BehaviorProcessor<Integer> async = BehaviorProcessor.create();
<ide> async.onComplete();
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testBehaviorSubjectError() {
<ide> BehaviorProcessor<Integer> async = BehaviorProcessor.create();
<ide> TestException te = new TestException();
<ide> async.onError(te);
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertFalse(serial.hasComplete());
<ide> assertTrue(serial.hasThrowable());
<ide> assertSame(te, serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide>
<ide> @Test
<ide> public void testReplaySubjectValueRelay() {
<ide> ReplayProcessor<Integer> async = ReplayProcessor.create();
<ide> async.onNext(1);
<ide> async.onComplete();
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertEquals((Integer)1, serial.getValue());
<del> assertTrue(serial.hasValue());
<del> assertArrayEquals(new Object[] { 1 }, serial.getValues());
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { 1, null }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertEquals((Integer)1, async.getValue());
<add> assertTrue(async.hasValue());
<add> assertArrayEquals(new Object[] { 1 }, async.getValues());
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectValueRelayIncomplete() {
<ide> ReplayProcessor<Integer> async = ReplayProcessor.create();
<ide> async.onNext(1);
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertFalse(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertEquals((Integer)1, serial.getValue());
<del> assertTrue(serial.hasValue());
<del> assertArrayEquals(new Object[] { 1 }, serial.getValues());
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { 1, null }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertEquals((Integer)1, async.getValue());
<add> assertTrue(async.hasValue());
<add> assertArrayEquals(new Object[] { 1 }, async.getValues());
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectValueRelayBounded() {
<ide> ReplayProcessor<Integer> async = ReplayProcessor.createWithSize(1);
<ide> async.onNext(0);
<ide> async.onNext(1);
<ide> async.onComplete();
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertEquals((Integer)1, serial.getValue());
<del> assertTrue(serial.hasValue());
<del> assertArrayEquals(new Object[] { 1 }, serial.getValues());
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { 1, null }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertEquals((Integer)1, async.getValue());
<add> assertTrue(async.hasValue());
<add> assertArrayEquals(new Object[] { 1 }, async.getValues());
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectValueRelayBoundedIncomplete() {
<ide> ReplayProcessor<Integer> async = ReplayProcessor.createWithSize(1);
<ide> async.onNext(0);
<ide> async.onNext(1);
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertFalse(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertEquals((Integer)1, serial.getValue());
<del> assertTrue(serial.hasValue());
<del> assertArrayEquals(new Object[] { 1 }, serial.getValues());
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { 1, null }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertEquals((Integer)1, async.getValue());
<add> assertTrue(async.hasValue());
<add> assertArrayEquals(new Object[] { 1 }, async.getValues());
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectValueRelayBoundedEmptyIncomplete() {
<ide> ReplayProcessor<Integer> async = ReplayProcessor.createWithSize(1);
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertFalse(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectValueRelayEmptyIncomplete() {
<ide> ReplayProcessor<Integer> async = ReplayProcessor.create();
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertFalse(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide>
<ide> @Test
<ide> public void testReplaySubjectEmpty() {
<ide> ReplayProcessor<Integer> async = ReplayProcessor.create();
<ide> async.onComplete();
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectError() {
<ide> ReplayProcessor<Integer> async = ReplayProcessor.create();
<ide> TestException te = new TestException();
<ide> async.onError(te);
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertFalse(serial.hasComplete());
<ide> assertTrue(serial.hasThrowable());
<ide> assertSame(te, serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide>
<ide> @Test
<ide> public void testReplaySubjectBoundedEmpty() {
<ide> ReplayProcessor<Integer> async = ReplayProcessor.createWithSize(1);
<ide> async.onComplete();
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectBoundedError() {
<ide> ReplayProcessor<Integer> async = ReplayProcessor.createWithSize(1);
<ide> TestException te = new TestException();
<ide> async.onError(te);
<del> FlowProcessor<Integer> serial = async.toSerialized();
<add> FlowableProcessor<Integer> serial = async.toSerialized();
<ide>
<ide> assertFalse(serial.hasSubscribers());
<ide> assertFalse(serial.hasComplete());
<ide> assertTrue(serial.hasThrowable());
<ide> assertSame(te, serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide>
<ide> @Test
<ide> public void testDontWrapSerializedSubjectAgain() {
<ide> PublishProcessor<Object> s = PublishProcessor.create();
<del> FlowProcessor<Object> s1 = s.toSerialized();
<del> FlowProcessor<Object> s2 = s1.toSerialized();
<add> FlowableProcessor<Object> s1 = s.toSerialized();
<add> FlowableProcessor<Object> s2 = s1.toSerialized();
<ide> assertSame(s1, s2);
<ide> }
<ide> }
<ide>\ No newline at end of file
<ide><path>src/test/java/io/reactivex/single/SingleNullTests.java
<ide> public void ambIterableOneIsNull() {
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide> public void ambArrayNull() {
<del> Single.amb((Single<Integer>[])null);
<add> Single.ambArray((Single<Integer>[])null);
<ide> }
<ide>
<ide> @SuppressWarnings("unchecked")
<ide> @Test(expected = NullPointerException.class)
<ide> public void ambArrayOneIsNull() {
<del> Single.amb(null, just1).blockingGet();
<add> Single.ambArray(null, just1).blockingGet();
<ide> }
<ide>
<ide> @Test(expected = NullPointerException.class)
<ide><path>src/test/java/io/reactivex/subjects/SerializedSubjectTest.java
<ide> public void testAsyncSubjectValueRelay() {
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertEquals((Integer)1, serial.getValue());
<del> assertTrue(serial.hasValue());
<del> assertArrayEquals(new Object[] { 1 }, serial.getValues());
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { 1, null }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertEquals((Integer)1, async.getValue());
<add> assertTrue(async.hasValue());
<add> assertArrayEquals(new Object[] { 1 }, async.getValues());
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testAsyncSubjectValueEmpty() {
<ide> public void testAsyncSubjectValueEmpty() {
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testAsyncSubjectValueError() {
<ide> public void testAsyncSubjectValueError() {
<ide> assertFalse(serial.hasComplete());
<ide> assertTrue(serial.hasThrowable());
<ide> assertSame(te, serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testPublishSubjectValueRelay() {
<ide> public void testPublishSubjectValueRelay() {
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del>
<del> assertArrayEquals(new Object[0], serial.getValues());
<del> assertArrayEquals(new Integer[0], serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide>
<ide> @Test
<ide> public void testPublishSubjectValueEmpty() {
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testPublishSubjectValueError() {
<ide> public void testPublishSubjectValueError() {
<ide> assertFalse(serial.hasComplete());
<ide> assertTrue(serial.hasThrowable());
<ide> assertSame(te, serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide>
<ide> @Test
<ide> public void testBehaviorSubjectValueRelay() {
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testBehaviorSubjectValueRelayIncomplete() {
<ide> public void testBehaviorSubjectValueRelayIncomplete() {
<ide> assertFalse(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertEquals((Integer)1, serial.getValue());
<del> assertTrue(serial.hasValue());
<del> assertArrayEquals(new Object[] { 1 }, serial.getValues());
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { 1, null }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertEquals((Integer)1, async.getValue());
<add> assertTrue(async.hasValue());
<add> assertArrayEquals(new Object[] { 1 }, async.getValues());
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testBehaviorSubjectIncompleteEmpty() {
<ide> public void testBehaviorSubjectIncompleteEmpty() {
<ide> assertFalse(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testBehaviorSubjectEmpty() {
<ide> public void testBehaviorSubjectEmpty() {
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testBehaviorSubjectError() {
<ide> public void testBehaviorSubjectError() {
<ide> assertFalse(serial.hasComplete());
<ide> assertTrue(serial.hasThrowable());
<ide> assertSame(te, serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide>
<ide> @Test
<ide> public void testReplaySubjectValueRelay() {
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertEquals((Integer)1, serial.getValue());
<del> assertTrue(serial.hasValue());
<del> assertArrayEquals(new Object[] { 1 }, serial.getValues());
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { 1, null }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertEquals((Integer)1, async.getValue());
<add> assertTrue(async.hasValue());
<add> assertArrayEquals(new Object[] { 1 }, async.getValues());
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectValueRelayIncomplete() {
<ide> public void testReplaySubjectValueRelayIncomplete() {
<ide> assertFalse(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertEquals((Integer)1, serial.getValue());
<del> assertTrue(serial.hasValue());
<del> assertArrayEquals(new Object[] { 1 }, serial.getValues());
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { 1, null }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertEquals((Integer)1, async.getValue());
<add> assertTrue(async.hasValue());
<add> assertArrayEquals(new Object[] { 1 }, async.getValues());
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectValueRelayBounded() {
<ide> public void testReplaySubjectValueRelayBounded() {
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertEquals((Integer)1, serial.getValue());
<del> assertTrue(serial.hasValue());
<del> assertArrayEquals(new Object[] { 1 }, serial.getValues());
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { 1, null }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertEquals((Integer)1, async.getValue());
<add> assertTrue(async.hasValue());
<add> assertArrayEquals(new Object[] { 1 }, async.getValues());
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectValueRelayBoundedIncomplete() {
<ide> public void testReplaySubjectValueRelayBoundedIncomplete() {
<ide> assertFalse(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertEquals((Integer)1, serial.getValue());
<del> assertTrue(serial.hasValue());
<del> assertArrayEquals(new Object[] { 1 }, serial.getValues());
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { 1 }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { 1, null }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertEquals((Integer)1, async.getValue());
<add> assertTrue(async.hasValue());
<add> assertArrayEquals(new Object[] { 1 }, async.getValues());
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectValueRelayBoundedEmptyIncomplete() {
<ide> public void testReplaySubjectValueRelayBoundedEmptyIncomplete() {
<ide> assertFalse(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectValueRelayEmptyIncomplete() {
<ide> public void testReplaySubjectValueRelayEmptyIncomplete() {
<ide> assertFalse(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide>
<ide> @Test
<ide> public void testReplaySubjectEmpty() {
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectError() {
<ide> public void testReplaySubjectError() {
<ide> assertFalse(serial.hasComplete());
<ide> assertTrue(serial.hasThrowable());
<ide> assertSame(te, serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide>
<ide> @Test
<ide> public void testReplaySubjectBoundedEmpty() {
<ide> assertTrue(serial.hasComplete());
<ide> assertFalse(serial.hasThrowable());
<ide> assertNull(serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide> @Test
<ide> public void testReplaySubjectBoundedError() {
<ide> public void testReplaySubjectBoundedError() {
<ide> assertFalse(serial.hasComplete());
<ide> assertTrue(serial.hasThrowable());
<ide> assertSame(te, serial.getThrowable());
<del> assertNull(serial.getValue());
<del> assertFalse(serial.hasValue());
<del> assertArrayEquals(new Object[] { }, serial.getValues());
<del> assertArrayEquals(new Integer[] { }, serial.getValues(new Integer[0]));
<del> assertArrayEquals(new Integer[] { null }, serial.getValues(new Integer[] { 0 }));
<del> assertArrayEquals(new Integer[] { null, 0 }, serial.getValues(new Integer[] { 0, 0 }));
<add> assertNull(async.getValue());
<add> assertFalse(async.hasValue());
<add> assertArrayEquals(new Object[] { }, async.getValues());
<add> assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
<add> assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
<add> assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
<ide> }
<ide>
<ide> @Test | 49 |
Javascript | Javascript | replace foreach with for | 5723c4c5f06f1382cc7962c64f31a7f96ca8a668 | <ide><path>lib/_tls_common.js
<ide> exports.createSecureContext = function createSecureContext(options, context) {
<ide>
<ide> var c = new SecureContext(options.secureProtocol, secureOptions, context);
<ide> var i;
<add> var val;
<ide>
<ide> if (context) return c;
<ide>
<ide> // NOTE: It's important to add CA before the cert to be able to load
<ide> // cert's issuer in C++ code.
<del> if (options.ca) {
<del> if (Array.isArray(options.ca)) {
<del> options.ca.forEach((ca) => {
<del> validateKeyCert(ca, 'ca');
<del> c.context.addCACert(ca);
<del> });
<add> var ca = options.ca;
<add> if (ca !== undefined) {
<add> if (Array.isArray(ca)) {
<add> for (i = 0; i < ca.length; ++i) {
<add> val = ca[i];
<add> validateKeyCert(val, 'ca');
<add> c.context.addCACert(val);
<add> }
<ide> } else {
<del> validateKeyCert(options.ca, 'ca');
<del> c.context.addCACert(options.ca);
<add> validateKeyCert(ca, 'ca');
<add> c.context.addCACert(ca);
<ide> }
<ide> } else {
<ide> c.context.addRootCerts();
<ide> }
<ide>
<del> if (options.cert) {
<del> if (Array.isArray(options.cert)) {
<del> options.cert.forEach((cert) => {
<del> validateKeyCert(cert, 'cert');
<del> c.context.setCert(cert);
<del> });
<add> var cert = options.cert;
<add> if (cert !== undefined) {
<add> if (Array.isArray(cert)) {
<add> for (i = 0; i < cert.length; ++i) {
<add> val = cert[i];
<add> validateKeyCert(val, 'cert');
<add> c.context.setCert(val);
<add> }
<ide> } else {
<del> validateKeyCert(options.cert, 'cert');
<del> c.context.setCert(options.cert);
<add> validateKeyCert(cert, 'cert');
<add> c.context.setCert(cert);
<ide> }
<ide> }
<ide>
<ide> // NOTE: It is important to set the key after the cert.
<ide> // `ssl_set_pkey` returns `0` when the key does not match the cert, but
<ide> // `ssl_set_cert` returns `1` and nullifies the key in the SSL structure
<ide> // which leads to the crash later on.
<del> if (options.key) {
<del> if (Array.isArray(options.key)) {
<del> options.key.forEach((k) => {
<del> validateKeyCert(k.pem || k, 'key');
<del> c.context.setKey(k.pem || k, k.passphrase || options.passphrase);
<del> });
<add> var key = options.key;
<add> var passphrase = options.passphrase;
<add> if (key !== undefined) {
<add> if (Array.isArray(key)) {
<add> for (i = 0; i < key.length; ++i) {
<add> val = key[i];
<add> // eslint-disable-next-line eqeqeq
<add> const pem = (val != undefined && val.pem !== undefined ? val.pem : val);
<add> validateKeyCert(pem, 'key');
<add> c.context.setKey(pem, val.passphrase || passphrase);
<add> }
<ide> } else {
<del> validateKeyCert(options.key, 'key');
<del> c.context.setKey(options.key, options.passphrase);
<add> validateKeyCert(key, 'key');
<add> c.context.setKey(key, passphrase);
<ide> }
<ide> }
<ide>
<ide> exports.createSecureContext = function createSecureContext(options, context) {
<ide>
<ide> if (options.pfx) {
<ide> var pfx = options.pfx;
<del> var passphrase = options.passphrase;
<ide>
<ide> if (!crypto)
<ide> crypto = require('crypto'); | 1 |
Ruby | Ruby | overwrite existing files | e3f8939cff48dd59f267792077282110a0616c66 | <ide><path>Library/Homebrew/unpack_strategy/zip.rb
<ide> def contains_extended_attributes?(path)
<ide> def extract_to_dir(unpack_dir, basename:, verbose:)
<ide> quiet_flags = verbose ? [] : ["-qq"]
<ide> result = system_command! "unzip",
<del> args: [*quiet_flags, path, "-d", unpack_dir],
<add> args: [*quiet_flags, "-o", path, "-d", unpack_dir],
<ide> verbose: verbose,
<ide> print_stderr: false
<ide> | 1 |
Text | Text | fix a typo in work-with-networks.md | 414b9dea8a1bf7ef7a4b9584dd887c51b49751d4 | <ide><path>docs/userguide/networking/work-with-networks.md
<ide> examine its networking stack:
<ide> $ docker attach container2
<ide> ```
<ide>
<del>If you look a the container's network stack you should see two Ethernet interfaces, one for the default bridge network and one for the `isolated_nw` network.
<add>If you look at the container's network stack you should see two Ethernet interfaces, one for the default bridge network and one for the `isolated_nw` network.
<ide>
<ide> ```bash
<ide> / # ifconfig | 1 |
PHP | PHP | remove uneeded tests | 062a8d77ea38c67e2205c8cf6e6cde579135532b | <ide><path>tests/TestCase/Console/CommandRunnerTest.php
<ide> public function testSetEventManagerNonEventedApplication()
<ide> $runner->setEventManager($events);
<ide> }
<ide>
<del> /**
<del> * Test that the console hook not returning a command collection
<del> * raises an error.
<del> *
<del> * @return void
<del> */
<del> public function testRunConsoleHookFailure()
<del> {
<del> $this->expectException(\RuntimeException::class);
<del> $this->expectExceptionMessage('The application\'s `console` method did not return a CommandCollection.');
<del> $app = $this->getMockBuilder(BaseApplication::class)
<del> ->setMethods(['console', 'middleware', 'bootstrap'])
<del> ->setConstructorArgs([$this->config])
<del> ->getMock();
<del> $runner = new CommandRunner($app);
<del> $runner->run(['cake', '-h']);
<del> }
<del>
<del> /**
<del> * Test that the console hook not returning a command collection
<del> * raises an error.
<del> *
<del> * @return void
<del> */
<del> public function testRunPluginConsoleHookFailure()
<del> {
<del> $this->expectException(\RuntimeException::class);
<del> $this->expectExceptionMessage('The application\'s `pluginConsole` method did not return a CommandCollection.');
<del> $app = $this->getMockBuilder(BaseApplication::class)
<del> ->setMethods(['pluginConsole', 'middleware', 'bootstrap'])
<del> ->setConstructorArgs([$this->config])
<del> ->getMock();
<del> $runner = new CommandRunner($app);
<del> $runner->run(['cake', '-h']);
<del> }
<del>
<ide> /**
<ide> * Test that running with empty argv fails
<ide> * | 1 |
Javascript | Javascript | add test for pointradius function type coercion | 01a7e187eab5ee5662cd78f6fc5cdf389768a20b | <ide><path>test/geo/path-test.js
<ide> suite.addBatch({
<ide> });
<ide> assert.deepEqual(testContext.buffer(), [
<ide> {type: "moveTo", x: 165, y: 160},
<del> {type: "arc", x: 165, y: 160}
<add> {type: "arc", x: 165, y: 160, r: 4.5}
<ide> ]);
<ide> },
<ide>
<ide> suite.addBatch({
<ide> coordinates: [[-63, 18], [-62, 18], [-62, 17]]
<ide> });
<ide> assert.deepEqual(testContext.buffer(), [
<del> {type: "moveTo", x: 165, y: 160}, {type: "arc", x: 165, y: 160},
<del> {type: "moveTo", x: 170, y: 160}, {type: "arc", x: 170, y: 160},
<del> {type: "moveTo", x: 170, y: 165}, {type: "arc", x: 170, y: 165}
<add> {type: "moveTo", x: 165, y: 160}, {type: "arc", x: 165, y: 160, r: 4.5},
<add> {type: "moveTo", x: 170, y: 160}, {type: "arc", x: 170, y: 160, r: 4.5},
<add> {type: "moveTo", x: 170, y: 165}, {type: "arc", x: 170, y: 165, r: 4.5}
<ide> ]);
<ide> },
<ide>
<ide> suite.addBatch({
<ide> geometries: [{type: "Point", coordinates: [0, 0]}]
<ide> });
<ide> assert.deepEqual(testContext.buffer(), [
<del> {type: "moveTo", x: 480, y: 250}, {type: "arc", x: 480, y: 250}
<add> {type: "moveTo", x: 480, y: 250}, {type: "arc", x: 480, y: 250, r: 4.5}
<ide> ]);
<ide> },
<ide>
<ide> suite.addBatch({
<ide> features: [{type: "Feature", geometry: {type: "Point", coordinates: [0, 0]}}]
<ide> });
<ide> assert.deepEqual(testContext.buffer(), [
<del> {type: "moveTo", x: 480, y: 250}, {type: "arc", x: 480, y: 250}
<add> {type: "moveTo", x: 480, y: 250}, {type: "arc", x: 480, y: 250, r: 4.5}
<ide> ]);
<ide> },
<ide>
<ide> suite.addBatch({
<ide> assert.strictEqual(path.pointRadius(), 4.5);
<ide> assert.strictEqual(path.pointRadius(radius).pointRadius(), radius);
<ide> },
<del> "coerces a constant point radius to a number": function() {
<del> var path = d3.geo.path();
<del> assert.strictEqual(path.pointRadius("5").pointRadius(), 5);
<add> "coerces point radius to a number": {
<add> "constant": function() {
<add> var path = d3.geo.path();
<add> assert.strictEqual(path.pointRadius("6").pointRadius(), 6);
<add> },
<add> "function": function(path) {
<add> var radius = path.pointRadius();
<add> try {
<add> path.pointRadius(function() { return "6"; })({type: "Point", coordinates: [0, 0]});
<add> assert.strictEqual(testContext.buffer().filter(function(d) { return d.type === "arc"; })[0].r, 6);
<add> } finally {
<add> path.pointRadius(radius);
<add> }
<add> }
<ide> }
<ide> },
<ide>
<ide> suite.addBatch({
<ide> coordinates: [-63, 18]
<ide> });
<ide> assert.deepEqual(testContext.buffer(), [
<del> {type: "moveTo", x: 165, y: 160}, {type: "arc", x: 165, y: 160}
<add> {type: "moveTo", x: 165, y: 160}, {type: "arc", x: 165, y: 160, r: 4.5}
<ide> ]);
<ide> },
<ide> "MultiPoint": function(path) {
<ide> suite.addBatch({
<ide> coordinates: [[-63, 18], [-62, 18], [-62, 17]]
<ide> });
<ide> assert.deepEqual(testContext.buffer(), [
<del> {type: "moveTo", x: 165, y: 160}, {type: "arc", x: 165, y: 160},
<del> {type: "moveTo", x: 170, y: 160}, {type: "arc", x: 170, y: 160},
<del> {type: "moveTo", x: 170, y: 165}, {type: "arc", x: 170, y: 165}
<add> {type: "moveTo", x: 165, y: 160}, {type: "arc", x: 165, y: 160, r: 4.5},
<add> {type: "moveTo", x: 170, y: 160}, {type: "arc", x: 170, y: 160, r: 4.5},
<add> {type: "moveTo", x: 170, y: 165}, {type: "arc", x: 170, y: 165, r: 4.5}
<ide> ]);
<ide> },
<ide> "Polygon": {
<ide> suite.addBatch({
<ide> "Point": {
<ide> "visible": function(path) {
<ide> path({type: "Point", coordinates: [0, 0]});
<del> assert.deepEqual(testContext.buffer(), [{type: "moveTo", x: 859, y: 187}, {type: "arc", x: 859, y: 187}]);
<add> assert.deepEqual(testContext.buffer(), [{type: "moveTo", x: 859, y: 187}, {type: "arc", x: 859, y: 187, r: 4.5}]);
<ide> },
<ide> "invisible": function(path) {
<ide> path({type: "Point", coordinates: [-180, 0]});
<ide> suite.addBatch({
<ide> },
<ide> "MultiPoint": function(path) {
<ide> path({type: "MultiPoint", coordinates: [[0, 0], [-180, 0]]});
<del> assert.deepEqual(testContext.buffer(), [{type: "moveTo", x: 859, y: 187}, {type: "arc", x: 859, y: 187}]);
<add> assert.deepEqual(testContext.buffer(), [{type: "moveTo", x: 859, y: 187}, {type: "arc", x: 859, y: 187, r: 4.5}]);
<ide> }
<ide> },
<ide> "rotate(-24, -175.5])": {
<ide> suite.addBatch({
<ide> "rotate([0, 0, 0])": {
<ide> "longitudes wrap at ±180°": function(path) {
<ide> path({type: "Point", coordinates: [180 + 1e-6, 0]});
<del> assert.deepEqual(testContext.buffer(), [{type: "moveTo", x: -420, y: 250}, {type: "arc", x: -420, y: 250}]);
<add> assert.deepEqual(testContext.buffer(), [{type: "moveTo", x: -420, y: 250}, {type: "arc", x: -420, y: 250, r: 4.5}]);
<ide> }
<ide> }
<ide> }
<ide> suite.addBatch({
<ide> var testBuffer = [];
<ide>
<ide> var testContext = {
<del> arc: function(x, y, r, ra, rb) { testBuffer.push({type: "arc", x: Math.round(x), y: Math.round(y)}); },
<add> arc: function(x, y, r, a0, a1) { testBuffer.push({type: "arc", x: Math.round(x), y: Math.round(y), r: r}); },
<ide> moveTo: function(x, y) { testBuffer.push({type: "moveTo", x: Math.round(x), y: Math.round(y)}); },
<ide> lineTo: function(x, y) { testBuffer.push({type: "lineTo", x: Math.round(x), y: Math.round(y)}); },
<ide> closePath: function() { testBuffer.push({type: "closePath"}); }, | 1 |
Go | Go | make volume ls output order | 60ffd6c880024c5ab3ad96dc79b01dccd23dd766 | <ide><path>api/client/volume.go
<ide> package client
<ide>
<ide> import (
<ide> "fmt"
<add> "sort"
<ide> "text/tabwriter"
<ide>
<ide> Cli "github.com/docker/docker/cli"
<ide> func (cli *DockerCli) CmdVolumeLs(args ...string) error {
<ide> fmt.Fprintf(w, "\n")
<ide> }
<ide>
<add> sort.Sort(byVolumeName(volumes.Volumes))
<ide> for _, vol := range volumes.Volumes {
<ide> if *quiet {
<ide> fmt.Fprintln(w, vol.Name)
<ide> func (cli *DockerCli) CmdVolumeLs(args ...string) error {
<ide> return nil
<ide> }
<ide>
<add>type byVolumeName []*types.Volume
<add>
<add>func (r byVolumeName) Len() int { return len(r) }
<add>func (r byVolumeName) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
<add>func (r byVolumeName) Less(i, j int) bool {
<add> return r[i].Name < r[j].Name
<add>}
<add>
<ide> // CmdVolumeInspect displays low-level information on one or more volumes.
<ide> //
<ide> // Usage: docker volume inspect [OPTIONS] VOLUME [VOLUME...]
<ide><path>integration-cli/docker_cli_volume_test.go
<ide> func (s *DockerSuite) TestVolumeCliInspectMulti(c *check.C) {
<ide>
<ide> func (s *DockerSuite) TestVolumeCliLs(c *check.C) {
<ide> prefix, _ := getPrefixAndSlashFromDaemonPlatform()
<del> out, _ := dockerCmd(c, "volume", "create")
<del> id := strings.TrimSpace(out)
<add> out, _ := dockerCmd(c, "volume", "create", "--name", "aaa")
<ide>
<ide> dockerCmd(c, "volume", "create", "--name", "test")
<del> dockerCmd(c, "run", "-v", prefix+"/foo", "busybox", "ls", "/")
<add>
<add> dockerCmd(c, "volume", "create", "--name", "soo")
<add> dockerCmd(c, "run", "-v", "soo:"+prefix+"/foo", "busybox", "ls", "/")
<ide>
<ide> out, _ = dockerCmd(c, "volume", "ls")
<ide> outArr := strings.Split(strings.TrimSpace(out), "\n")
<ide> c.Assert(len(outArr), check.Equals, 4, check.Commentf("\n%s", out))
<ide>
<del> // Since there is no guarantee of ordering of volumes, we just make sure the names are in the output
<del> c.Assert(strings.Contains(out, id+"\n"), check.Equals, true)
<del> c.Assert(strings.Contains(out, "test\n"), check.Equals, true)
<add> assertVolList(c, out, []string{"aaa", "soo", "test"})
<add>}
<add>
<add>// assertVolList checks volume retrieved with ls command
<add>// equals to expected volume list
<add>// note: out should be `volume ls [option]` result
<add>func assertVolList(c *check.C, out string, expectVols []string) {
<add> lines := strings.Split(out, "\n")
<add> var volList []string
<add> for _, line := range lines[1 : len(lines)-1] {
<add> volFields := strings.Fields(line)
<add> // wrap all volume name in volList
<add> volList = append(volList, volFields[1])
<add> }
<add>
<add> // volume ls should contains all expected volumes
<add> c.Assert(volList, checker.DeepEquals, expectVols)
<ide> }
<ide>
<ide> func (s *DockerSuite) TestVolumeCliLsFilterDangling(c *check.C) { | 2 |
Text | Text | remove mess words in installation doc | f8d5b880722bcc87113a08cbb2069b6311b89f39 | <ide><path>docs/installation/linux/ubuntulinux.md
<ide> For Ubuntu Precise, Docker requires the 3.13 kernel version. If your kernel
<ide> version is older than 3.13, you must upgrade it. Refer to this table to see
<ide> which packages are required for your environment:
<ide>
<del><style type="text/css"> .tg {border-collapse:collapse;border-spacing:0;} .tg
<del>td{font-size:14px;padding:10px
<del>5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
<del>.tg-031{width:275px;font-family:monospace} </style> <table class="tg"> <tr> <td
<del>class="tg-031">linux-image-generic-lts-trusty</td> <td class="tg-031e">Generic
<del>Linux kernel image. This kernel has AUFS built in. This is required to run
<del>Docker.</td> </tr> <tr> <td class="tg-031">linux-headers-generic-lts-trusty</td>
<del><td class="tg-031e">Allows packages such as ZFS and VirtualBox guest additions
<del>which depend on them. If you didn't install the headers for your existing
<del>kernel, then you can skip these headers for the"trusty" kernel. If you're
<del>unsure, you should include this package for safety.</td> </tr> <tr> <td
<del>class="tg-031">xserver-xorg-lts-trusty</td> <td class="tg-031e"
<del>rowspan="2">Optional in non-graphical environments without Unity/Xorg.
<del><b>Required</b> when running Docker on machine with a graphical environment.
<del><br>
<del><br>To learn more about the reasons for these packages, read the installation
<del>instructions for backported kernels, specifically the <a
<del>href="https://wiki.ubuntu.com/Kernel/LTSEnablementStack" target="_blank">LTS
<del>Enablement Stack</a> — refer to note 5 under each version.
<del></td> </tr>
<del><tr> <td class="tg-031">libgl1-mesa-glx-lts-trusty</td> </tr> </table>
<add><table>
<add> <thead>
<add> <tr>
<add> <th>Package</th>
<add> <th>Description</th>
<add> </tr>
<add> </thead>
<add> <tbody>
<add> <tr>
<add> <td><b style="white-space: nowrap">linux-image-generic-lts-trusty</b></td>
<add> <td>
<add> Generic Linux kernel image. This kernel has AUFS built in. This is
<add> required to run Docker.
<add> </td>
<add> </tr>
<add> <tr>
<add> <td><b style="white-space: nowrap">linux-headers-generic-lts-trusty</b></td>
<add> <td>
<add> Allows packages such as ZFS and VirtualBox guest additions which depend
<add> on them. If you didn't install the headers for your existing kernel, then
<add> you can skip these headers for the"trusty" kernel. If you're unsure, you
<add> should include this package for safety.
<add> </td>
<add> </tr>
<add> <tr>
<add> <td><b style="white-space: nowrap">xserver-xorg-lts-trusty</b></td>
<add> <td rowspan="2">
<add> Optional in non-graphical environments without Unity/Xorg.
<add> <b>Required</b> when running Docker on machine with a graphical
<add> environment.<br /><br />
<add> To learn more about the reasons for these packages, read the installation
<add> instructions for backported kernels, specifically the <a
<add> href="https://wiki.ubuntu.com/Kernel/LTSEnablementStack"
<add> target="_blank">LTS Enablement Stack</a> — refer to note 5 under each
<add> version.
<add> </td>
<add> </tr>
<add> <tr>
<add> <td><b style="white-space: nowrap">libgl1-mesa-glx-lts-trusty</b></td>
<add> </tr>
<add> </tbody>
<add></table>
<ide>
<ide> To upgrade your kernel and install the additional packages, do the following:
<ide> | 1 |
Python | Python | remove things we do not need in inspect | c8a87fcd0b27ffdd557014c877aeb7b8f6797691 | <ide><path>numpy/lib/inspect.py
<del># -*- coding: iso-8859-1 -*-
<del>"""Get useful information from live Python objects.
<del>
<del>This module encapsulates the interface provided by the internal special
<del>attributes (func_*, co_*, im_*, tb_*, etc.) in a friendlier fashion.
<del>It also provides some help for examining source code and class layout.
<del>
<del>Here are some of the useful functions provided by this module:
<del>
<del> ismodule(), isclass(), ismethod(), isfunction(), istraceback(),
<del> isframe(), iscode(), isbuiltin(), isroutine() - check object types
<del> getmembers() - get members of an object that satisfy a given condition
<del>
<del> getfile(), getsourcefile(), getsource() - find an object's source code
<del> getdoc(), getcomments() - get documentation on an object
<del> getmodule() - determine the module that an object came from
<del> getclasstree() - arrange classes so as to represent their hierarchy
<del>
<del> getargspec(), getargvalues() - get info about function arguments
<del> formatargspec(), formatargvalues() - format an argument spec
<del> getouterframes(), getinnerframes() - get info about frames
<del> currentframe() - get the current stack frame
<del> stack(), trace() - get info about frames on the stack or in a traceback
<del>"""
<del>
<del># This module is in the public domain. No warranties.
<del>
<del>__author__ = 'Ka-Ping Yee <ping@lfw.org>'
<del>__date__ = '1 Jan 2001'
<del>
<del>import sys, os, types, string, re, dis, imp, tokenize, linecache
<add>import types
<ide>
<ide> # ----------------------------------------------------------- type-checking
<del>def ismodule(object):
<del> """Return true if the object is a module.
<del>
<del> Module objects provide these attributes:
<del> __doc__ documentation string
<del> __file__ filename (missing for built-in modules)"""
<del> return isinstance(object, types.ModuleType)
<del>
<del>def isclass(object):
<del> """Return true if the object is a class.
<del>
<del> Class objects provide these attributes:
<del> __doc__ documentation string
<del> __module__ name of module in which this class was defined"""
<del> return isinstance(object, types.ClassType) or hasattr(object, '__bases__')
<del>
<ide> def ismethod(object):
<ide> """Return true if the object is an instance method.
<ide>
<ide> def ismethod(object):
<ide> im_self instance to which this method is bound, or None"""
<ide> return isinstance(object, types.MethodType)
<ide>
<del>def ismethoddescriptor(object):
<del> """Return true if the object is a method descriptor.
<del>
<del> But not if ismethod() or isclass() or isfunction() are true.
<del>
<del> This is new in Python 2.2, and, for example, is true of int.__add__.
<del> An object passing this test has a __get__ attribute but not a __set__
<del> attribute, but beyond that the set of attributes varies. __name__ is
<del> usually sensible, and __doc__ often is.
<del>
<del> Methods implemented via descriptors that also pass one of the other
<del> tests return false from the ismethoddescriptor() test, simply because
<del> the other tests promise more -- you can, e.g., count on having the
<del> im_func attribute (etc) when an object passes ismethod()."""
<del> return (hasattr(object, "__get__")
<del> and not hasattr(object, "__set__") # else it's a data descriptor
<del> and not ismethod(object) # mutual exclusion
<del> and not isfunction(object)
<del> and not isclass(object))
<del>
<del>def isdatadescriptor(object):
<del> """Return true if the object is a data descriptor.
<del>
<del> Data descriptors have both a __get__ and a __set__ attribute. Examples are
<del> properties (defined in Python) and getsets and members (defined in C).
<del> Typically, data descriptors will also have __name__ and __doc__ attributes
<del> (properties, getsets, and members have both of these attributes), but this
<del> is not guaranteed."""
<del> return (hasattr(object, "__set__") and hasattr(object, "__get__"))
<del>
<ide> def isfunction(object):
<ide> """Return true if the object is a user-defined function.
<ide>
<ide> def isfunction(object):
<ide> func_name (same as __name__)"""
<ide> return isinstance(object, types.FunctionType)
<ide>
<del>def istraceback(object):
<del> """Return true if the object is a traceback.
<del>
<del> Traceback objects provide these attributes:
<del> tb_frame frame object at this level
<del> tb_lasti index of last attempted instruction in bytecode
<del> tb_lineno current line number in Python source code
<del> tb_next next inner traceback object (called by this level)"""
<del> return isinstance(object, types.TracebackType)
<del>
<del>def isframe(object):
<del> """Return true if the object is a frame object.
<del>
<del> Frame objects provide these attributes:
<del> f_back next outer frame object (this frame's caller)
<del> f_builtins built-in namespace seen by this frame
<del> f_code code object being executed in this frame
<del> f_exc_traceback traceback if raised in this frame, or None
<del> f_exc_type exception type if raised in this frame, or None
<del> f_exc_value exception value if raised in this frame, or None
<del> f_globals global namespace seen by this frame
<del> f_lasti index of last attempted instruction in bytecode
<del> f_lineno current line number in Python source code
<del> f_locals local namespace seen by this frame
<del> f_restricted 0 or 1 if frame is in restricted execution mode
<del> f_trace tracing function for this frame, or None"""
<del> return isinstance(object, types.FrameType)
<del>
<ide> def iscode(object):
<ide> """Return true if the object is a code object.
<ide>
<ide> def iscode(object):
<ide> co_varnames tuple of names of arguments and local variables"""
<ide> return isinstance(object, types.CodeType)
<ide>
<del>def isbuiltin(object):
<del> """Return true if the object is a built-in function or method.
<del>
<del> Built-in functions and methods provide these attributes:
<del> __doc__ documentation string
<del> __name__ original name of this function or method
<del> __self__ instance to which a method is bound, or None"""
<del> return isinstance(object, types.BuiltinFunctionType)
<del>
<del>def isroutine(object):
<del> """Return true if the object is any kind of function or method."""
<del> return (isbuiltin(object)
<del> or isfunction(object)
<del> or ismethod(object)
<del> or ismethoddescriptor(object))
<del>
<del>def getmembers(object, predicate=None):
<del> """Return all members of an object as (name, value) pairs sorted by name.
<del> Optionally, only return members that satisfy a given predicate."""
<del> results = []
<del> for key in dir(object):
<del> value = getattr(object, key)
<del> if not predicate or predicate(value):
<del> results.append((key, value))
<del> results.sort()
<del> return results
<del>
<del>def classify_class_attrs(cls):
<del> """Return list of attribute-descriptor tuples.
<del>
<del> For each name in dir(cls), the return list contains a 4-tuple
<del> with these elements:
<del>
<del> 0. The name (a string).
<del>
<del> 1. The kind of attribute this is, one of these strings:
<del> 'class method' created via classmethod()
<del> 'static method' created via staticmethod()
<del> 'property' created via property()
<del> 'method' any other flavor of method
<del> 'data' not a method
<del>
<del> 2. The class which defined this attribute (a class).
<del>
<del> 3. The object as obtained directly from the defining class's
<del> __dict__, not via getattr. This is especially important for
<del> data attributes: C.data is just a data object, but
<del> C.__dict__['data'] may be a data descriptor with additional
<del> info, like a __doc__ string.
<del> """
<del>
<del> mro = getmro(cls)
<del> names = dir(cls)
<del> result = []
<del> for name in names:
<del> # Get the object associated with the name.
<del> # Getting an obj from the __dict__ sometimes reveals more than
<del> # using getattr. Static and class methods are dramatic examples.
<del> if name in cls.__dict__:
<del> obj = cls.__dict__[name]
<del> else:
<del> obj = getattr(cls, name)
<del>
<del> # Figure out where it was defined.
<del> homecls = getattr(obj, "__objclass__", None)
<del> if homecls is None:
<del> # search the dicts.
<del> for base in mro:
<del> if name in base.__dict__:
<del> homecls = base
<del> break
<del>
<del> # Get the object again, in order to get it from the defining
<del> # __dict__ instead of via getattr (if possible).
<del> if homecls is not None and name in homecls.__dict__:
<del> obj = homecls.__dict__[name]
<del>
<del> # Also get the object via getattr.
<del> obj_via_getattr = getattr(cls, name)
<del>
<del> # Classify the object.
<del> if isinstance(obj, staticmethod):
<del> kind = "static method"
<del> elif isinstance(obj, classmethod):
<del> kind = "class method"
<del> elif isinstance(obj, property):
<del> kind = "property"
<del> elif (ismethod(obj_via_getattr) or
<del> ismethoddescriptor(obj_via_getattr)):
<del> kind = "method"
<del> else:
<del> kind = "data"
<del>
<del> result.append((name, kind, homecls, obj))
<del>
<del> return result
<del>
<del># ----------------------------------------------------------- class helpers
<del>def _searchbases(cls, accum):
<del> # Simulate the "classic class" search order.
<del> if cls in accum:
<del> return
<del> accum.append(cls)
<del> for base in cls.__bases__:
<del> _searchbases(base, accum)
<del>
<del>def getmro(cls):
<del> "Return tuple of base classes (including cls) in method resolution order."
<del> if hasattr(cls, "__mro__"):
<del> return cls.__mro__
<del> else:
<del> result = []
<del> _searchbases(cls, result)
<del> return tuple(result)
<del>
<del># -------------------------------------------------- source code extraction
<del>def indentsize(line):
<del> """Return the indent size, in spaces, at the start of a line of text."""
<del> expline = string.expandtabs(line)
<del> return len(expline) - len(string.lstrip(expline))
<del>
<del>def getdoc(object):
<del> """Get the documentation string for an object.
<del>
<del> All tabs are expanded to spaces. To clean up docstrings that are
<del> indented to line up with blocks of code, any whitespace than can be
<del> uniformly removed from the second line onwards is removed."""
<del> try:
<del> doc = object.__doc__
<del> except AttributeError:
<del> return None
<del> if not isinstance(doc, types.StringTypes):
<del> return None
<del> try:
<del> lines = string.split(string.expandtabs(doc), '\n')
<del> except UnicodeError:
<del> return None
<del> else:
<del> # Find minimum indentation of any non-blank lines after first line.
<del> margin = sys.maxint
<del> for line in lines[1:]:
<del> content = len(string.lstrip(line))
<del> if content:
<del> indent = len(line) - content
<del> margin = min(margin, indent)
<del> # Remove indentation.
<del> if lines:
<del> lines[0] = lines[0].lstrip()
<del> if margin < sys.maxint:
<del> for i in range(1, len(lines)): lines[i] = lines[i][margin:]
<del> # Remove any trailing or leading blank lines.
<del> while lines and not lines[-1]:
<del> lines.pop()
<del> while lines and not lines[0]:
<del> lines.pop(0)
<del> return string.join(lines, '\n')
<del>
<del>def getfile(object):
<del> """Work out which source or compiled file an object was defined in."""
<del> if ismodule(object):
<del> if hasattr(object, '__file__'):
<del> return object.__file__
<del> raise TypeError('arg is a built-in module')
<del> if isclass(object):
<del> object = sys.modules.get(object.__module__)
<del> if hasattr(object, '__file__'):
<del> return object.__file__
<del> raise TypeError('arg is a built-in class')
<del> if ismethod(object):
<del> object = object.im_func
<del> if isfunction(object):
<del> object = object.func_code
<del> if istraceback(object):
<del> object = object.tb_frame
<del> if isframe(object):
<del> object = object.f_code
<del> if iscode(object):
<del> return object.co_filename
<del> raise TypeError('arg is not a module, class, method, '
<del> 'function, traceback, frame, or code object')
<del>
<del>def getmoduleinfo(path):
<del> """Get the module name, suffix, mode, and module type for a given file."""
<del> filename = os.path.basename(path)
<del> suffixes = map(lambda (suffix, mode, mtype):
<del> (-len(suffix), suffix, mode, mtype), imp.get_suffixes())
<del> suffixes.sort() # try longest suffixes first, in case they overlap
<del> for neglen, suffix, mode, mtype in suffixes:
<del> if filename[neglen:] == suffix:
<del> return filename[:neglen], suffix, mode, mtype
<del>
<del>def getmodulename(path):
<del> """Return the module name for a given file, or None."""
<del> info = getmoduleinfo(path)
<del> if info: return info[0]
<del>
<del>def getsourcefile(object):
<del> """Return the Python source file an object was defined in, if it exists."""
<del> filename = getfile(object)
<del> if string.lower(filename[-4:]) in ['.pyc', '.pyo']:
<del> filename = filename[:-4] + '.py'
<del> for suffix, mode, kind in imp.get_suffixes():
<del> if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix:
<del> # Looks like a binary file. We want to only return a text file.
<del> return None
<del> if os.path.exists(filename):
<del> return filename
<del>
<del>def getabsfile(object):
<del> """Return an absolute path to the source or compiled file for an object.
<del>
<del> The idea is for each object to have a unique origin, so this routine
<del> normalizes the result as much as possible."""
<del> return os.path.normcase(
<del> os.path.abspath(getsourcefile(object) or getfile(object)))
<del>
<del>modulesbyfile = {}
<del>
<del>def getmodule(object):
<del> """Return the module an object was defined in, or None if not found."""
<del> if ismodule(object):
<del> return object
<del> if hasattr(object, '__module__'):
<del> return sys.modules.get(object.__module__)
<del> try:
<del> file = getabsfile(object)
<del> except TypeError:
<del> return None
<del> if file in modulesbyfile:
<del> return sys.modules.get(modulesbyfile[file])
<del> for module in sys.modules.values():
<del> if hasattr(module, '__file__'):
<del> modulesbyfile[
<del> os.path.realpath(
<del> getabsfile(module))] = module.__name__
<del> if file in modulesbyfile:
<del> return sys.modules.get(modulesbyfile[file])
<del> main = sys.modules['__main__']
<del> if not hasattr(object, '__name__'):
<del> return None
<del> if hasattr(main, object.__name__):
<del> mainobject = getattr(main, object.__name__)
<del> if mainobject is object:
<del> return main
<del> builtin = sys.modules['__builtin__']
<del> if hasattr(builtin, object.__name__):
<del> builtinobject = getattr(builtin, object.__name__)
<del> if builtinobject is object:
<del> return builtin
<del>
<del>def findsource(object):
<del> """Return the entire source file and starting line number for an object.
<del>
<del> The argument may be a module, class, method, function, traceback, frame,
<del> or code object. The source code is returned as a list of all the lines
<del> in the file and the line number indexes a line in that list. An IOError
<del> is raised if the source code cannot be retrieved."""
<del> file = getsourcefile(object) or getfile(object)
<del> lines = linecache.getlines(file)
<del> if not lines:
<del> raise IOError('could not get source code')
<del>
<del> if ismodule(object):
<del> return lines, 0
<del>
<del> if isclass(object):
<del> name = object.__name__
<del> pat = re.compile(r'^\s*class\s*' + name + r'\b')
<del> for i in range(len(lines)):
<del> if pat.match(lines[i]): return lines, i
<del> else:
<del> raise IOError('could not find class definition')
<del>
<del> if ismethod(object):
<del> object = object.im_func
<del> if isfunction(object):
<del> object = object.func_code
<del> if istraceback(object):
<del> object = object.tb_frame
<del> if isframe(object):
<del> object = object.f_code
<del> if iscode(object):
<del> if not hasattr(object, 'co_firstlineno'):
<del> raise IOError('could not find function definition')
<del> lnum = object.co_firstlineno - 1
<del> pat = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)')
<del> while lnum > 0:
<del> if pat.match(lines[lnum]): break
<del> lnum = lnum - 1
<del> return lines, lnum
<del> raise IOError('could not find code object')
<del>
<del>def getcomments(object):
<del> """Get lines of comments immediately preceding an object's source code.
<del>
<del> Returns None when source can't be found.
<del> """
<del> try:
<del> lines, lnum = findsource(object)
<del> except (IOError, TypeError):
<del> return None
<del>
<del> if ismodule(object):
<del> # Look for a comment block at the top of the file.
<del> start = 0
<del> if lines and lines[0][:2] == '#!': start = 1
<del> while start < len(lines) and string.strip(lines[start]) in ['', '#']:
<del> start = start + 1
<del> if start < len(lines) and lines[start][:1] == '#':
<del> comments = []
<del> end = start
<del> while end < len(lines) and lines[end][:1] == '#':
<del> comments.append(string.expandtabs(lines[end]))
<del> end = end + 1
<del> return string.join(comments, '')
<del>
<del> # Look for a preceding block of comments at the same indentation.
<del> elif lnum > 0:
<del> indent = indentsize(lines[lnum])
<del> end = lnum - 1
<del> if end >= 0 and string.lstrip(lines[end])[:1] == '#' and \
<del> indentsize(lines[end]) == indent:
<del> comments = [string.lstrip(string.expandtabs(lines[end]))]
<del> if end > 0:
<del> end = end - 1
<del> comment = string.lstrip(string.expandtabs(lines[end]))
<del> while comment[:1] == '#' and indentsize(lines[end]) == indent:
<del> comments[:0] = [comment]
<del> end = end - 1
<del> if end < 0: break
<del> comment = string.lstrip(string.expandtabs(lines[end]))
<del> while comments and string.strip(comments[0]) == '#':
<del> comments[:1] = []
<del> while comments and string.strip(comments[-1]) == '#':
<del> comments[-1:] = []
<del> return string.join(comments, '')
<del>
<del>class EndOfBlock(Exception): pass
<del>
<del>class BlockFinder:
<del> """Provide a tokeneater() method to detect the end of a code block."""
<del> def __init__(self):
<del> self.indent = 0
<del> self.islambda = False
<del> self.started = False
<del> self.passline = False
<del> self.last = 1
<del>
<del> def tokeneater(self, type, token, (srow, scol), (erow, ecol), line):
<del> if not self.started:
<del> # look for the first "def", "class" or "lambda"
<del> if token in ("def", "class", "lambda"):
<del> if token == "lambda":
<del> self.islambda = True
<del> self.started = True
<del> self.passline = True # skip to the end of the line
<del> elif type == tokenize.NEWLINE:
<del> self.passline = False # stop skipping when a NEWLINE is seen
<del> self.last = srow
<del> if self.islambda: # lambdas always end at the first NEWLINE
<del> raise EndOfBlock
<del> elif self.passline:
<del> pass
<del> elif type == tokenize.INDENT:
<del> self.indent = self.indent + 1
<del> self.passline = True
<del> elif type == tokenize.DEDENT:
<del> self.indent = self.indent - 1
<del> # the end of matching indent/dedent pairs end a block
<del> # (note that this only works for "def"/"class" blocks,
<del> # not e.g. for "if: else:" or "try: finally:" blocks)
<del> if self.indent <= 0:
<del> raise EndOfBlock
<del> elif self.indent == 0 and type not in (tokenize.COMMENT, tokenize.NL):
<del> # any other token on the same indentation level end the previous
<del> # block as well, except the pseudo-tokens COMMENT and NL.
<del> raise EndOfBlock
<del>
<del>def getblock(lines):
<del> """Extract the block of code at the top of the given list of lines."""
<del> blockfinder = BlockFinder()
<del> try:
<del> tokenize.tokenize(iter(lines).next, blockfinder.tokeneater)
<del> except (EndOfBlock, IndentationError):
<del> pass
<del> return lines[:blockfinder.last]
<del>
<del>def getsourcelines(object):
<del> """Return a list of source lines and starting line number for an object.
<del>
<del> The argument may be a module, class, method, function, traceback, frame,
<del> or code object. The source code is returned as a list of the lines
<del> corresponding to the object and the line number indicates where in the
<del> original source file the first line of code was found. An IOError is
<del> raised if the source code cannot be retrieved."""
<del> lines, lnum = findsource(object)
<del>
<del> if ismodule(object): return lines, 0
<del> else: return getblock(lines[lnum:]), lnum + 1
<del>
<del>def getsource(object):
<del> """Return the text of the source code for an object.
<del>
<del> The argument may be a module, class, method, function, traceback, frame,
<del> or code object. The source code is returned as a single string. An
<del> IOError is raised if the source code cannot be retrieved."""
<del> lines, lnum = getsourcelines(object)
<del> return string.join(lines, '')
<del>
<del># --------------------------------------------------- class tree extraction
<del>def walktree(classes, children, parent):
<del> """Recursive helper function for getclasstree()."""
<del> results = []
<del> classes.sort(key=lambda c: (c.__module__, c.__name__))
<del> for c in classes:
<del> results.append((c, c.__bases__))
<del> if c in children:
<del> results.append(walktree(children[c], children, c))
<del> return results
<del>
<del>def getclasstree(classes, unique=0):
<del> """Arrange the given list of classes into a hierarchy of nested lists.
<del>
<del> Where a nested list appears, it contains classes derived from the class
<del> whose entry immediately precedes the list. Each entry is a 2-tuple
<del> containing a class and a tuple of its base classes. If the 'unique'
<del> argument is true, exactly one entry appears in the returned structure
<del> for each class in the given list. Otherwise, classes using multiple
<del> inheritance and their descendants will appear multiple times."""
<del> children = {}
<del> roots = []
<del> for c in classes:
<del> if c.__bases__:
<del> for parent in c.__bases__:
<del> if not parent in children:
<del> children[parent] = []
<del> children[parent].append(c)
<del> if unique and parent in classes: break
<del> elif c not in roots:
<del> roots.append(c)
<del> for parent in children:
<del> if parent not in classes:
<del> roots.append(parent)
<del> return walktree(roots, children, None)
<del>
<ide> # ------------------------------------------------ argument list extraction
<ide> # These constants are from Python's compile.h.
<ide> CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS = 1, 2, 4, 8
<ide> def convert(name, locals=locals,
<ide> specs.append(formatvarkw(varkw) + formatvalue(locals[varkw]))
<ide> return '(' + string.join(specs, ', ') + ')'
<ide>
<del># -------------------------------------------------- stack frame extraction
<del>def getframeinfo(frame, context=1):
<del> """Get information about a frame or traceback object.
<del>
<del> A tuple of five things is returned: the filename, the line number of
<del> the current line, the function name, a list of lines of context from
<del> the source code, and the index of the current line within that list.
<del> The optional second argument specifies the number of lines of context
<del> to return, which are centered around the current line."""
<del> if istraceback(frame):
<del> lineno = frame.tb_lineno
<del> frame = frame.tb_frame
<del> else:
<del> lineno = frame.f_lineno
<del> if not isframe(frame):
<del> raise TypeError('arg is not a frame or traceback object')
<del>
<del> filename = getsourcefile(frame) or getfile(frame)
<del> if context > 0:
<del> start = lineno - 1 - context//2
<del> try:
<del> lines, lnum = findsource(frame)
<del> except IOError:
<del> lines = index = None
<del> else:
<del> start = max(start, 1)
<del> start = max(0, min(start, len(lines) - context))
<del> lines = lines[start:start+context]
<del> index = lineno - 1 - start
<del> else:
<del> lines = index = None
<del>
<del> return (filename, lineno, frame.f_code.co_name, lines, index)
<del>
<del>def getlineno(frame):
<del> """Get the line number from a frame object, allowing for optimization."""
<del> # FrameType.f_lineno is now a descriptor that grovels co_lnotab
<del> return frame.f_lineno
<del>
<del>def getouterframes(frame, context=1):
<del> """Get a list of records for a frame and all higher (calling) frames.
<del>
<del> Each record contains a frame object, filename, line number, function
<del> name, a list of lines of context, and index within the context."""
<del> framelist = []
<del> while frame:
<del> framelist.append((frame,) + getframeinfo(frame, context))
<del> frame = frame.f_back
<del> return framelist
<del>
<del>def getinnerframes(tb, context=1):
<del> """Get a list of records for a traceback's frame and all lower frames.
<del>
<del> Each record contains a frame object, filename, line number, function
<del> name, a list of lines of context, and index within the context."""
<del> framelist = []
<del> while tb:
<del> framelist.append((tb.tb_frame,) + getframeinfo(tb, context))
<del> tb = tb.tb_next
<del> return framelist
<del>
<del>currentframe = sys._getframe
<del>
<del>def stack(context=1):
<del> """Return a list of records for the stack above the caller's frame."""
<del> return getouterframes(sys._getframe(1), context)
<del>
<del>def trace(context=1):
<del> """Return a list of records for the stack below the current exception."""
<del> return getinnerframes(sys.exc_info()[2], context)
<del>
<ide> if __name__ == '__main__':
<ide> import inspect
<ide> def foo(x, y, z=None): | 1 |
Python | Python | add more typing to airflow.utils.helpers | 896f35107db370c7ecf6ce5c93791c2f4edb52d8 | <ide><path>airflow/utils/helpers.py
<ide> from datetime import datetime
<ide> from functools import reduce
<ide> from itertools import filterfalse, tee
<del>from typing import Any, Callable, Dict, Generator, Iterable, List, Optional, TypeVar
<add>from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, Iterable, List, Optional, Tuple, TypeVar
<ide> from urllib import parse
<ide>
<ide> from flask import url_for
<ide> from airflow.exceptions import AirflowException
<ide> from airflow.utils.module_loading import import_string
<ide>
<add>if TYPE_CHECKING:
<add> from airflow.models import TaskInstance
<add>
<ide> KEY_REGEX = re.compile(r'^[\w.-]+$')
<add>CAMELCASE_TO_SNAKE_CASE_REGEX = re.compile(r'(?!^)([A-Z]+)')
<add>
<add>T = TypeVar('T')
<add>S = TypeVar('S')
<ide>
<ide>
<del>def validate_key(k, max_length=250):
<add>def validate_key(k: str, max_length: int = 250) -> bool:
<ide> """Validates value used as a key."""
<ide> if not isinstance(k, str):
<ide> raise TypeError("The key has to be a string")
<ide> def alchemy_to_dict(obj: Any) -> Optional[Dict]:
<ide> return output
<ide>
<ide>
<del>def ask_yesno(question):
<add>def ask_yesno(question: str) -> bool:
<ide> """Helper to get yes / no answer from user."""
<ide> yes = {'yes', 'y'}
<ide> no = {'no', 'n'}
<ide> def ask_yesno(question):
<ide> print("Please respond by yes or no.")
<ide>
<ide>
<del>def is_container(obj):
<add>def is_container(obj: Any) -> bool:
<ide> """Test if an object is a container (iterable) but not a string"""
<ide> return hasattr(obj, '__iter__') and not isinstance(obj, str)
<ide>
<ide>
<del>def as_tuple(obj):
<add>def as_tuple(obj: Any) -> tuple:
<ide> """
<ide> If obj is a container, returns obj as a tuple.
<ide> Otherwise, returns a tuple containing obj.
<ide> def as_tuple(obj):
<ide> return tuple([obj])
<ide>
<ide>
<del>T = TypeVar('T')
<del>S = TypeVar('S')
<del>
<del>
<ide> def chunks(items: List[T], chunk_size: int) -> Generator[List[T], None, None]:
<ide> """Yield successive chunks of a given size from a list of items"""
<ide> if chunk_size <= 0:
<ide> def parse_template_string(template_string):
<ide> return template_string, None
<ide>
<ide>
<del>def render_log_filename(ti, try_number, filename_template):
<add>def render_log_filename(ti: "TaskInstance", try_number, filename_template) -> str:
<ide> """
<ide> Given task instance, try_number, filename_template, return the rendered log
<ide> filename
<ide> def render_log_filename(ti, try_number, filename_template):
<ide> )
<ide>
<ide>
<del>def convert_camel_to_snake(camel_str):
<add>def convert_camel_to_snake(camel_str: str) -> str:
<ide> """Converts CamelCase to snake_case."""
<del> return re.sub('(?!^)([A-Z]+)', r'_\1', camel_str).lower()
<add> return CAMELCASE_TO_SNAKE_CASE_REGEX.sub(r'_\1', camel_str).lower()
<ide>
<ide>
<del>def merge_dicts(dict1, dict2):
<add>def merge_dicts(dict1: Dict, dict2: Dict) -> Dict:
<ide> """
<ide> Merge two dicts recursively, returning new dict (input dict is not mutated).
<ide>
<ide> def merge_dicts(dict1, dict2):
<ide> return merged
<ide>
<ide>
<del>def partition(pred: Callable, iterable: Iterable):
<add>def partition(pred: Callable[[T], bool], iterable: Iterable[T]) -> Tuple[Iterable[T], Iterable[T]]:
<ide> """Use a predicate to partition entries into false entries and true entries"""
<ide> iter_1, iter_2 = tee(iterable)
<ide> return filterfalse(pred, iter_1), filter(pred, iter_2) | 1 |
Python | Python | fix provider name in the user-agent string | 9535ec0bbae112f78f0e8ccde6b5aff39f3fa75b | <ide><path>airflow/providers/databricks/hooks/databricks_base.py
<ide> def user_agent_value(self) -> str:
<ide> python_version = platform.python_version()
<ide> system = platform.system().lower()
<ide> ua_string = (
<del> f"databricks-aiflow/{version} _/0.0.0 python/{python_version} os/{system} "
<add> f"databricks-airflow/{version} _/0.0.0 python/{python_version} os/{system} "
<ide> f"airflow/{__version__} operator/{self.caller}"
<ide> )
<ide> return ua_string | 1 |
Javascript | Javascript | fix http agent keep alive | fe776b8f42be7aa8d17b6619de3ecd67d7a4d743 | <ide><path>lib/_http_agent.js
<ide> Agent.prototype.createSocket = function createSocket(req, options, cb) {
<ide> installListeners(this, s, options);
<ide> cb(null, s);
<ide> });
<del>
<add> // When keepAlive is true, pass the related options to createConnection
<add> if (this.keepAlive) {
<add> options.keepAlive = this.keepAlive;
<add> options.keepAliveInitialDelay = this.keepAliveMsecs;
<add> }
<ide> const newSocket = this.createConnection(options, oncreate);
<ide> if (newSocket)
<ide> oncreate(null, newSocket);
<ide><path>test/parallel/test-http-agent-keepalive-delay.js
<add>'use strict';
<add>
<add>const common = require('../common');
<add>const assert = require('assert');
<add>const http = require('http');
<add>const { Agent } = require('_http_agent');
<add>
<add>const agent = new Agent({
<add> keepAlive: true,
<add> keepAliveMsecs: 1000,
<add>});
<add>
<add>const server = http.createServer(common.mustCall((req, res) => {
<add> res.end('ok');
<add>}));
<add>
<add>server.listen(0, common.mustCall(() => {
<add> const createConnection = agent.createConnection;
<add> agent.createConnection = (options, ...args) => {
<add> assert.strictEqual(options.keepAlive, true);
<add> assert.strictEqual(options.keepAliveInitialDelay, agent.keepAliveMsecs);
<add> return createConnection.call(agent, options, ...args);
<add> };
<add> http.get({
<add> host: 'localhost',
<add> port: server.address().port,
<add> agent: agent,
<add> path: '/'
<add> }, common.mustCall((res) => {
<add> // for emit end event
<add> res.on('data', () => {});
<add> res.on('end', () => {
<add> server.close();
<add> });
<add> }));
<add>})); | 2 |
Javascript | Javascript | fix extend_prototypes for sproutcore-views | 5431c3990377ef052eced529f0bce0929a90f439 | <ide><path>packages/sproutcore-views/lib/system/ext.js
<ide> // Add a new named queue for rendering views that happens
<ide> // after bindings have synced.
<ide> var queues = SC.run.queues;
<del>queues.insertAt(queues.indexOf('actions')+1, 'render');
<add>queues.splice(jQuery.inArray('actions', queues)+1, 0, 'render');
<ide><path>packages/sproutcore-views/lib/system/render_buffer.js
<ide> SC._RenderBuffer = SC.Object.extend(
<ide> init: function() {
<ide> this._super();
<ide>
<del> set(this ,'elementClasses', []);
<add> set(this ,'elementClasses', SC.NativeArray.apply([]));
<ide> set(this, 'elementAttributes', {});
<ide> set(this, 'elementStyle', {});
<del> set(this, 'childBuffers', []);
<add> set(this, 'childBuffers', SC.NativeArray.apply([]));
<ide> set(this, 'elements', {});
<ide> },
<ide>
<ide><path>packages/sproutcore-views/lib/views/view.js
<ide> var getPath = SC.getPath, meta = SC.meta, fmt = SC.String.fmt;
<ide> var childViewsProperty = SC.computed(function() {
<ide> var childViews = get(this, '_childViews');
<ide>
<del> var ret = [];
<add> var ret = SC.NativeArray.apply([]);
<ide>
<ide> childViews.forEach(function(view) {
<ide> if (view.isVirtual) {
<del> ret = ret.concat(get(view, 'childViews'));
<add> ret.pushObjects(get(view, 'childViews'));
<ide> } else {
<ide> ret.push(view);
<ide> }
<ide> SC.View = SC.Object.extend(
<ide> }
<ide>
<ide> if (!template) {
<del> throw new SC.Error('%@ - Unable to find template "%@".'.fmt(this, templateName));
<add> throw new SC.Error(fmt('%@ - Unable to find template "%@".', this, templateName));
<ide> }
<ide> }
<ide>
<ide> SC.View = SC.Object.extend(
<ide> */
<ide> childViews: childViewsProperty,
<ide>
<del> _childViews: [],
<add> _childViews: SC.NativeArray.apply([]),
<ide>
<ide> /**
<ide> Return the nearest ancestor that is an instance of the provided
<ide> SC.View = SC.Object.extend(
<ide> // Normalize property path to be suitable for use
<ide> // as a class name. For exaple, content.foo.barBaz
<ide> // becomes bar-baz.
<del> return SC.String.dasherize(get(property.split('.'), 'lastObject'));
<add> parts = property.split('.');
<add> return SC.String.dasherize(parts[parts.length-1]);
<ide>
<ide> // If the value is not NO, undefined, or null, return the current
<ide> // value of the property.
<ide> SC.View = SC.Object.extend(
<ide> // SC.RootResponder to dispatch incoming events.
<ide> SC.View.views[get(this, 'elementId')] = this;
<ide>
<del> var childViews = get(this, '_childViews').slice();
<add> var childViews = SC.NativeArray.apply(get(this, '_childViews').slice());
<ide> // setup child views. be sure to clone the child views array first
<ide> set(this, '_childViews', childViews);
<ide>
<ide>
<del> this.classNameBindings = get(this, 'classNameBindings').slice();
<del> this.classNames = get(this, 'classNames').slice();
<add> this.classNameBindings = SC.NativeArray.apply(get(this, 'classNameBindings').slice());
<add> this.classNames = SC.NativeArray.apply(get(this, 'classNames').slice());
<ide>
<ide> this.set('domManager', this.domManagerClass.create({ view: this }));
<ide>
<ide><path>packages/sproutcore-views/tests/views/collection_test.js
<ide> module("SC.CollectionView", {
<ide>
<ide> test("should render a view for each item in its content array", function() {
<ide> view = SC.CollectionView.create({
<del> content: [1, 2, 3, 4]
<add> content: SC.NativeArray.apply([1, 2, 3, 4])
<ide> });
<ide>
<ide> SC.run(function() {
<ide> test("should render a view for each item in its content array", function() {
<ide> test("should render the emptyView if content array is empty (view class)", function() {
<ide> view = SC.CollectionView.create({
<ide> tagName: 'del',
<del> content: [],
<add> content: SC.NativeArray.apply([]),
<ide>
<ide> emptyView: SC.View.extend({
<ide> tagName: 'kbd',
<ide> test("should render the emptyView if content array is empty (view class)", funct
<ide> test("should render the emptyView if content array is empty (view instance)", function() {
<ide> view = SC.CollectionView.create({
<ide> tagName: 'del',
<del> content: [],
<add> content: SC.NativeArray.apply([]),
<ide>
<ide> emptyView: SC.View.create({
<ide> tagName: 'kbd',
<ide> test("should render the emptyView if content array is empty (view instance)", fu
<ide> test("should be able to override the tag name of itemViewClass even if tag is in default mapping", function() {
<ide> view = SC.CollectionView.create({
<ide> tagName: 'del',
<del> content: ['NEWS GUVNAH'],
<add> content: SC.NativeArray.apply(['NEWS GUVNAH']),
<ide>
<ide> itemViewClass: SC.View.extend({
<ide> tagName: 'kbd',
<ide> test("should be able to override the tag name of itemViewClass even if tag is in
<ide> test("should allow custom item views by setting itemViewClass", function() {
<ide> var passedContents = [];
<ide> view = SC.CollectionView.create({
<del> content: ['foo', 'bar', 'baz'],
<add> content: SC.NativeArray.apply(['foo', 'bar', 'baz']),
<ide>
<ide> itemViewClass: SC.View.extend({
<ide> render: function(buf) {
<ide> test("should allow custom item views by setting itemViewClass", function() {
<ide> });
<ide>
<ide> test("should insert a new item in DOM when an item is added to the content array", function() {
<del> var content = ['foo', 'bar', 'baz'];
<add> var content = SC.NativeArray.apply(['foo', 'bar', 'baz']);
<ide>
<ide> view = SC.CollectionView.create({
<ide> content: content,
<ide> test("should insert a new item in DOM when an item is added to the content array
<ide> });
<ide>
<ide> test("should remove an item from DOM when an item is removed from the content array", function() {
<del> var content = ['foo', 'bar', 'baz'];
<add> var content = SC.NativeArray.apply(['foo', 'bar', 'baz']);
<ide>
<ide> view = SC.CollectionView.create({
<ide> content: content,
<ide> test("should remove an item from DOM when an item is removed from the content ar
<ide> });
<ide>
<ide> content.forEach(function(item, idx) {
<del> equals(view.$(':nth-child(%@)'.fmt(idx+1)).text(), item);
<add> equals(view.$(SC.String.fmt(':nth-child(%@)', String(idx+1))).text(), item);
<ide> });
<ide> });
<ide>
<ide> test("should allow changes to content object before layer is created", function(
<ide> content: null
<ide> });
<ide>
<del> set(view, 'content', []);
<del> set(view, 'content', [1, 2, 3]);
<del> set(view, 'content', [1, 2]);
<add> set(view, 'content', SC.NativeArray.apply([]));
<add> set(view, 'content', SC.NativeArray.apply([1, 2, 3]));
<add> set(view, 'content', SC.NativeArray.apply([1, 2]));
<ide>
<ide> SC.run(function() {
<ide> view.append();
<ide> test("should allow changes to content object before layer is created", function(
<ide>
<ide> test("should allow changing content property to be null", function() {
<ide> view = SC.CollectionView.create({
<del> content: [1, 2, 3],
<add> content: SC.NativeArray.apply([1, 2, 3]),
<ide>
<ide> emptyView: SC.View.extend({
<ide> template: function() { return "(empty)"; }
<ide> test("should allow changing content property to be null", function() {
<ide>
<ide> test("should allow items to access to the CollectionView's current index in the content array", function() {
<ide> view = SC.CollectionView.create({
<del> content: ['zero', 'one', 'two'],
<add> content: SC.NativeArray.apply(['zero', 'one', 'two']),
<ide> itemViewClass: SC.View.extend({
<ide> render: function(buf) {
<ide> buf.push(get(this, 'contentIndex'));
<ide><path>packages/sproutcore-views/tests/views/view/nearest_view_test.js
<ide> test("collectionView should return the nearest collection view", function() {
<ide> var itemViewChild;
<ide>
<ide> var view = SC.CollectionView.create({
<del> content: [1, 2, 3],
<add> content: SC.NativeArray.apply([1, 2, 3]),
<ide> isARealCollection: true,
<ide>
<ide> itemViewClass: SC.View.extend({
<ide> test("itemView should return the nearest child of a collection view", function()
<ide> var itemViewChild;
<ide>
<ide> var view = SC.CollectionView.create({
<del> content: [1, 2, 3],
<add> content: SC.NativeArray.apply([1, 2, 3]),
<ide>
<ide> itemViewClass: SC.View.extend({
<ide> isAnItemView: true,
<ide> test("itemView should return the nearest child of a collection view", function()
<ide> var itemViewChild;
<ide>
<ide> var view = SC.CollectionView.create({
<del> content: [1, 2, 3],
<add> content: SC.NativeArray.apply([1, 2, 3]),
<ide>
<ide> itemViewClass: SC.View.extend({
<ide> isAnItemView: true, | 5 |
Python | Python | replace nystromformertokenizer with autotokenizer | e239fc3b0baf1171079a5e0177a69254350a063b | <ide><path>src/transformers/models/nystromformer/modeling_nystromformer.py
<ide>
<ide> _CHECKPOINT_FOR_DOC = "uw-madison/nystromformer-512"
<ide> _CONFIG_FOR_DOC = "NystromformerConfig"
<del>_TOKENIZER_FOR_DOC = "NystromformerTokenizer"
<add>_TOKENIZER_FOR_DOC = "AutoTokenizer"
<ide>
<ide> NYSTROMFORMER_PRETRAINED_MODEL_ARCHIVE_LIST = [
<ide> "uw-madison/nystromformer-512", | 1 |
Javascript | Javascript | move encodestr function to internal for reusable | db9a7459c3439c282ddcb7353e00491aeb704d22 | <ide><path>lib/internal/querystring.js
<ide> 'use strict';
<ide>
<add>const { ERR_INVALID_URI } = require('internal/errors').codes;
<add>
<ide> const hexTable = new Array(256);
<ide> for (var i = 0; i < 256; ++i)
<ide> hexTable[i] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
<ide> const isHexTable = [
<ide> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // ... 256
<ide> ];
<ide>
<add>function encodeStr(str, noEscapeTable, hexTable) {
<add> const len = str.length;
<add> if (len === 0)
<add> return '';
<add>
<add> var out = '';
<add> var lastPos = 0;
<add>
<add> for (var i = 0; i < len; i++) {
<add> var c = str.charCodeAt(i);
<add>
<add> // ASCII
<add> if (c < 0x80) {
<add> if (noEscapeTable[c] === 1)
<add> continue;
<add> if (lastPos < i)
<add> out += str.slice(lastPos, i);
<add> lastPos = i + 1;
<add> out += hexTable[c];
<add> continue;
<add> }
<add>
<add> if (lastPos < i)
<add> out += str.slice(lastPos, i);
<add>
<add> // Multi-byte characters ...
<add> if (c < 0x800) {
<add> lastPos = i + 1;
<add> out += hexTable[0xC0 | (c >> 6)] +
<add> hexTable[0x80 | (c & 0x3F)];
<add> continue;
<add> }
<add> if (c < 0xD800 || c >= 0xE000) {
<add> lastPos = i + 1;
<add> out += hexTable[0xE0 | (c >> 12)] +
<add> hexTable[0x80 | ((c >> 6) & 0x3F)] +
<add> hexTable[0x80 | (c & 0x3F)];
<add> continue;
<add> }
<add> // Surrogate pair
<add> ++i;
<add>
<add> // This branch should never happen because all URLSearchParams entries
<add> // should already be converted to USVString. But, included for
<add> // completion's sake anyway.
<add> if (i >= len)
<add> throw new ERR_INVALID_URI();
<add>
<add> var c2 = str.charCodeAt(i) & 0x3FF;
<add>
<add> lastPos = i + 1;
<add> c = 0x10000 + (((c & 0x3FF) << 10) | c2);
<add> out += hexTable[0xF0 | (c >> 18)] +
<add> hexTable[0x80 | ((c >> 12) & 0x3F)] +
<add> hexTable[0x80 | ((c >> 6) & 0x3F)] +
<add> hexTable[0x80 | (c & 0x3F)];
<add> }
<add> if (lastPos === 0)
<add> return str;
<add> if (lastPos < len)
<add> return out + str.slice(lastPos);
<add> return out;
<add>}
<add>
<ide> module.exports = {
<add> encodeStr,
<ide> hexTable,
<ide> isHexTable
<ide> };
<ide><path>lib/internal/url.js
<ide>
<ide> const util = require('util');
<ide> const {
<add> encodeStr,
<ide> hexTable,
<ide> isHexTable
<ide> } = require('internal/querystring');
<ide> const noEscape = [
<ide> const paramHexTable = hexTable.slice();
<ide> paramHexTable[0x20] = '+';
<ide>
<del>function encodeStr(str, noEscapeTable, hexTable) {
<del> const len = str.length;
<del> if (len === 0)
<del> return '';
<del>
<del> var out = '';
<del> var lastPos = 0;
<del>
<del> for (var i = 0; i < len; i++) {
<del> var c = str.charCodeAt(i);
<del>
<del> // ASCII
<del> if (c < 0x80) {
<del> if (noEscapeTable[c] === 1)
<del> continue;
<del> if (lastPos < i)
<del> out += str.slice(lastPos, i);
<del> lastPos = i + 1;
<del> out += hexTable[c];
<del> continue;
<del> }
<del>
<del> if (lastPos < i)
<del> out += str.slice(lastPos, i);
<del>
<del> // Multi-byte characters ...
<del> if (c < 0x800) {
<del> lastPos = i + 1;
<del> out += hexTable[0xC0 | (c >> 6)] +
<del> hexTable[0x80 | (c & 0x3F)];
<del> continue;
<del> }
<del> if (c < 0xD800 || c >= 0xE000) {
<del> lastPos = i + 1;
<del> out += hexTable[0xE0 | (c >> 12)] +
<del> hexTable[0x80 | ((c >> 6) & 0x3F)] +
<del> hexTable[0x80 | (c & 0x3F)];
<del> continue;
<del> }
<del> // Surrogate pair
<del> ++i;
<del> var c2;
<del> if (i < len)
<del> c2 = str.charCodeAt(i) & 0x3FF;
<del> else {
<del> // This branch should never happen because all URLSearchParams entries
<del> // should already be converted to USVString. But, included for
<del> // completion's sake anyway.
<del> c2 = 0;
<del> }
<del> lastPos = i + 1;
<del> c = 0x10000 + (((c & 0x3FF) << 10) | c2);
<del> out += hexTable[0xF0 | (c >> 18)] +
<del> hexTable[0x80 | ((c >> 12) & 0x3F)] +
<del> hexTable[0x80 | ((c >> 6) & 0x3F)] +
<del> hexTable[0x80 | (c & 0x3F)];
<del> }
<del> if (lastPos === 0)
<del> return str;
<del> if (lastPos < len)
<del> return out + str.slice(lastPos);
<del> return out;
<del>}
<del>
<ide> // application/x-www-form-urlencoded serializer
<ide> // Ref: https://url.spec.whatwg.org/#concept-urlencoded-serializer
<ide> function serializeParams(array) {
<ide><path>lib/querystring.js
<ide> 'use strict';
<ide>
<ide> const { Buffer } = require('buffer');
<del>const { ERR_INVALID_URI } = require('internal/errors').codes;
<ide> const {
<add> encodeStr,
<ide> hexTable,
<ide> isHexTable
<ide> } = require('internal/querystring');
<ide> function qsEscape(str) {
<ide> else
<ide> str += '';
<ide> }
<del> var out = '';
<del> var lastPos = 0;
<del>
<del> for (var i = 0; i < str.length; ++i) {
<del> var c = str.charCodeAt(i);
<del>
<del> // ASCII
<del> if (c < 0x80) {
<del> if (noEscape[c] === 1)
<del> continue;
<del> if (lastPos < i)
<del> out += str.slice(lastPos, i);
<del> lastPos = i + 1;
<del> out += hexTable[c];
<del> continue;
<del> }
<ide>
<del> if (lastPos < i)
<del> out += str.slice(lastPos, i);
<del>
<del> // Multi-byte characters ...
<del> if (c < 0x800) {
<del> lastPos = i + 1;
<del> out += hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)];
<del> continue;
<del> }
<del> if (c < 0xD800 || c >= 0xE000) {
<del> lastPos = i + 1;
<del> out += hexTable[0xE0 | (c >> 12)] +
<del> hexTable[0x80 | ((c >> 6) & 0x3F)] +
<del> hexTable[0x80 | (c & 0x3F)];
<del> continue;
<del> }
<del> // Surrogate pair
<del> ++i;
<del>
<del> if (i >= str.length)
<del> throw new ERR_INVALID_URI();
<del>
<del> var c2 = str.charCodeAt(i) & 0x3FF;
<del>
<del> lastPos = i + 1;
<del> c = 0x10000 + (((c & 0x3FF) << 10) | c2);
<del> out += hexTable[0xF0 | (c >> 18)] +
<del> hexTable[0x80 | ((c >> 12) & 0x3F)] +
<del> hexTable[0x80 | ((c >> 6) & 0x3F)] +
<del> hexTable[0x80 | (c & 0x3F)];
<del> }
<del> if (lastPos === 0)
<del> return str;
<del> if (lastPos < str.length)
<del> return out + str.slice(lastPos);
<del> return out;
<add> return encodeStr(str, noEscape, hexTable);
<ide> }
<ide>
<ide> function stringifyPrimitive(v) { | 3 |
Mixed | Ruby | make hash#extract! more symmetric with hash#slice | 5d27338ab08496b41ef71c789e5ae4de0b3b8df7 | <ide><path>activesupport/CHANGELOG.md
<ide> ## Rails 4.0.0 (unreleased) ##
<ide>
<add>* Hash#extract! returns only those keys that present in the reciever.
<add>
<add> {:a => 1, :b => 2}.extract!(:a, :x) # => {:a => 1}
<add>
<add> *Mikhail Dieterle*
<add>
<add>* Hash#extract! returns the same subclass, that the reciever is. I.e.
<add> HashWithIndifferentAccess#extract! returns HashWithIndifferentAccess instance.
<add>
<add> *Mikhail Dieterle*
<add>
<ide> * Optimize ActiveSupport::Cache::Entry to reduce memory and processing overhead. *Brian Durand*
<ide>
<ide> * Tests tag the Rails log with the current test class and test case:
<ide><path>activesupport/lib/active_support/core_ext/hash/slice.rb
<ide> def slice!(*keys)
<ide>
<ide> # Removes and returns the key/value pairs matching the given keys.
<ide> #
<del> # { a: 1, b: 2, c: 3, d: 4 }.extract!(:a, :b)
<del> # # => {:a => 1, :b => 2}
<add> # { a: 1, b: 2, c: 3, d: 4 }.extract!(:a, :b) # => { a: 1, b: 2 }
<add> # { a: 1, b: 2 }.extract!(:a, :x) # => { a: 1 }
<ide> def extract!(*keys)
<del> keys.each_with_object({}) { |key, result| result[key] = delete(key) }
<add> keys.each_with_object(self.class.new) { |key, result| result[key] = delete(key) if has_key?(key) }
<ide> end
<ide> end
<ide><path>activesupport/test/core_ext/hash_ext_test.rb
<ide> def test_extract
<ide> original = {:a => 1, :b => 2, :c => 3, :d => 4}
<ide> expected = {:a => 1, :b => 2}
<ide>
<add> assert_equal expected, original.extract!(:a, :b, :x)
<add> end
<add>
<add> def test_extract_nils
<add> original = {:a => nil, :b => nil}
<add> expected = {:a => nil}
<add> extracted = original.extract!(:a, :x)
<add>
<add> assert_equal expected, extracted
<add> assert_equal nil, extracted[:a]
<add> assert_equal nil, extracted[:x]
<add> end
<add>
<add> def test_indifferent_extract
<add> original = {:a => 1, :b => 2, :c => 3, :d => 4}.with_indifferent_access
<add> expected = {:a => 1, :b => 2}.with_indifferent_access
<add>
<ide> assert_equal expected, original.extract!(:a, :b)
<ide> end
<ide> | 3 |
Python | Python | add schema as dbapihook instance attribute | 3ee916e9e11f0e9d9c794fa41b102161df3f2cd4 | <ide><path>airflow/hooks/dbapi.py
<ide> from contextlib import closing
<ide> from datetime import datetime
<ide> from typing import Any, Optional
<del>from urllib.parse import quote_plus
<add>from urllib.parse import quote_plus, urlunsplit
<ide>
<ide> from sqlalchemy import create_engine
<ide>
<ide> def __init__(self, *args, **kwargs):
<ide> setattr(self, self.conn_name_attr, self.default_conn_name)
<ide> else:
<ide> setattr(self, self.conn_name_attr, kwargs[self.conn_name_attr])
<add> self.schema: Optional[str] = kwargs.pop("schema", None)
<ide>
<ide> def get_conn(self):
<ide> """Returns a connection object"""
<ide> def get_uri(self) -> str:
<ide> host = conn.host
<ide> if conn.port is not None:
<ide> host += f':{conn.port}'
<del> uri = f'{conn.conn_type}://{login}{host}/'
<del> if conn.schema:
<del> uri += conn.schema
<del> return uri
<add> schema = self.schema or conn.schema or ''
<add> return urlunsplit((conn.conn_type, f'{login}{host}', schema, '', ''))
<ide>
<ide> def get_sqlalchemy_engine(self, engine_kwargs=None):
<ide> """
<ide><path>airflow/providers/postgres/hooks/postgres.py
<ide> class PostgresHook(DbApiHook):
<ide>
<ide> def __init__(self, *args, **kwargs) -> None:
<ide> super().__init__(*args, **kwargs)
<del> self.schema: Optional[str] = kwargs.pop("schema", None)
<ide> self.connection: Optional[Connection] = kwargs.pop("connection", None)
<ide> self.conn: connection = None
<ide>
<ide><path>tests/hooks/test_dbapi.py
<ide> def test_get_uri_schema_not_none(self):
<ide> )
<ide> assert "conn_type://login:password@host:1/schema" == self.db_hook.get_uri()
<ide>
<add> def test_get_uri_schema_override(self):
<add> self.db_hook.get_connection = mock.MagicMock(
<add> return_value=Connection(
<add> conn_type="conn_type",
<add> host="host",
<add> login="login",
<add> password="password",
<add> schema="schema",
<add> port=1,
<add> )
<add> )
<add> self.db_hook.schema = 'schema-override'
<add> assert "conn_type://login:password@host:1/schema-override" == self.db_hook.get_uri()
<add>
<ide> def test_get_uri_schema_none(self):
<ide> self.db_hook.get_connection = mock.MagicMock(
<ide> return_value=Connection(
<ide> conn_type="conn_type", host="host", login="login", password="password", schema=None, port=1
<ide> )
<ide> )
<del> assert "conn_type://login:password@host:1/" == self.db_hook.get_uri()
<add> assert "conn_type://login:password@host:1" == self.db_hook.get_uri()
<ide>
<ide> def test_get_uri_special_characters(self):
<ide> self.db_hook.get_connection = mock.MagicMock(
<ide><path>tests/providers/postgres/hooks/test_postgres.py
<ide> def test_get_conn_rds_iam_redshift(self, mock_client, mock_connect):
<ide> [get_cluster_credentials_call, get_cluster_credentials_call]
<ide> )
<ide>
<add> def test_get_uri_from_connection_without_schema_override(self):
<add> self.db_hook.get_connection = mock.MagicMock(
<add> return_value=Connection(
<add> conn_type="postgres",
<add> host="host",
<add> login="login",
<add> password="password",
<add> schema="schema",
<add> port=1,
<add> )
<add> )
<add> assert "postgres://login:password@host:1/schema" == self.db_hook.get_uri()
<add>
<add> def test_get_uri_from_connection_with_schema_override(self):
<add> hook = PostgresHook(schema='schema-override')
<add> hook.get_connection = mock.MagicMock(
<add> return_value=Connection(
<add> conn_type="postgres",
<add> host="host",
<add> login="login",
<add> password="password",
<add> schema="schema",
<add> port=1,
<add> )
<add> )
<add> assert "postgres://login:password@host:1/schema-override" == hook.get_uri()
<add>
<ide>
<ide> class TestPostgresHook(unittest.TestCase):
<ide> def __init__(self, *args, **kwargs): | 4 |
Javascript | Javascript | add symbol to normalized connect() args | 51664fc265bf4ce9757f18b7b78f18b34678b3e3 | <ide><path>lib/internal/net.js
<ide> function isLegalPort(port) {
<ide> }
<ide>
<ide> module.exports = {
<del> isLegalPort
<add> isLegalPort,
<add> normalizedArgsSymbol: Symbol('normalizedArgs')
<ide> };
<ide><path>lib/net.js
<ide> var dns;
<ide> const errnoException = util._errnoException;
<ide> const exceptionWithHostPort = util._exceptionWithHostPort;
<ide> const isLegalPort = internalNet.isLegalPort;
<add>const normalizedArgsSymbol = internalNet.normalizedArgsSymbol;
<ide>
<ide> function noop() {}
<ide>
<ide> function connect() {
<ide> // For Server.prototype.listen(), the [...] part is [, backlog]
<ide> // but will not be handled here (handled in listen())
<ide> function normalizeArgs(args) {
<add> var arr;
<add>
<ide> if (args.length === 0) {
<del> return [{}, null];
<add> arr = [{}, null];
<add> arr[normalizedArgsSymbol] = true;
<add> return arr;
<ide> }
<ide>
<ide> const arg0 = args[0];
<ide> function normalizeArgs(args) {
<ide>
<ide> var cb = args[args.length - 1];
<ide> if (typeof cb !== 'function')
<del> return [options, null];
<add> arr = [options, null];
<ide> else
<del> return [options, cb];
<add> arr = [options, cb];
<add>
<add> arr[normalizedArgsSymbol] = true;
<add> return arr;
<ide> }
<ide>
<ide>
<ide> Socket.prototype.connect = function() {
<ide> // already been normalized (so we don't normalize more than once). This has
<ide> // been solved before in https://github.com/nodejs/node/pull/12342, but was
<ide> // reverted as it had unintended side effects.
<del> if (arguments.length === 1 && Array.isArray(arguments[0])) {
<add> if (Array.isArray(arguments[0]) && arguments[0][normalizedArgsSymbol]) {
<ide> normalized = arguments[0];
<ide> } else {
<ide> var args = new Array(arguments.length);
<ide><path>test/parallel/test-net-normalize-args.js
<add>'use strict';
<add>// Flags: --expose-internals
<add>const common = require('../common');
<add>const assert = require('assert');
<add>const net = require('net');
<add>const { normalizedArgsSymbol } = require('internal/net');
<add>
<add>function validateNormalizedArgs(input, output) {
<add> const args = net._normalizeArgs(input);
<add>
<add> assert.deepStrictEqual(args, output);
<add> assert.strictEqual(args[normalizedArgsSymbol], true);
<add>}
<add>
<add>// Test creation of normalized arguments.
<add>validateNormalizedArgs([], [{}, null]);
<add>validateNormalizedArgs([{ port: 1234 }], [{ port: 1234 }, null]);
<add>validateNormalizedArgs([{ port: 1234 }, assert.fail],
<add> [{ port: 1234 }, assert.fail]);
<add>
<add>// Connecting to the server should fail with a standard array.
<add>{
<add> const server = net.createServer(common.mustNotCall('should not connect'));
<add>
<add> server.listen(common.mustCall(() => {
<add> const possibleErrors = ['ECONNREFUSED', 'EADDRNOTAVAIL'];
<add> const port = server.address().port;
<add> const socket = new net.Socket();
<add>
<add> socket.on('error', common.mustCall((err) => {
<add> assert(possibleErrors.includes(err.code));
<add> assert(possibleErrors.includes(err.errno));
<add> assert.strictEqual(err.syscall, 'connect');
<add> server.close();
<add> }));
<add>
<add> socket.connect([{ port }, assert.fail]);
<add> }));
<add>}
<add>
<add>// Connecting to the server should succeed with a normalized array.
<add>{
<add> const server = net.createServer(common.mustCall((connection) => {
<add> connection.end();
<add> server.close();
<add> }));
<add>
<add> server.listen(common.mustCall(() => {
<add> const port = server.address().port;
<add> const socket = new net.Socket();
<add> const args = net._normalizeArgs([{ port }, common.mustCall()]);
<add>
<add> socket.connect(args);
<add> }));
<add>} | 3 |
Javascript | Javascript | preserve controller instance across rerenders | dc97966be2134d794611b0c693193caad8207dc0 | <ide><path>packages/ember-htmlbars/lib/keywords/with.js
<ide> export default {
<ide> setupState(state, env, scope, params, hash) {
<ide> var controller = hash.controller;
<ide>
<del> if (controller && !state.controller) {
<del> var context = params[0];
<del> var controllerFactory = env.container.lookupFactory('controller:' + controller);
<del> var parentController = scope.view ? get(scope.view, 'context') : null;
<del>
<del> var controllerInstance = controllerFactory.create({
<del> model: env.hooks.getValue(context),
<del> parentController: parentController,
<del> target: parentController
<del> });
<del>
<del> params[0] = controllerInstance;
<del> return { controller: controllerInstance };
<add> if (controller) {
<add> if (!state.controller) {
<add> var context = params[0];
<add> var controllerFactory = env.container.lookupFactory('controller:' + controller);
<add> var parentController = scope.view ? get(scope.view, 'context') : null;
<add>
<add> var controllerInstance = controllerFactory.create({
<add> model: env.hooks.getValue(context),
<add> parentController: parentController,
<add> target: parentController
<add> });
<add>
<add> params[0] = controllerInstance;
<add> return { controller: controllerInstance };
<add> }
<add>
<add> return state;
<ide> }
<ide>
<ide> return { controller: null };
<ide><path>packages/ember-htmlbars/tests/helpers/with_test.js
<ide> QUnit.test("it should support #with this as qux", function() {
<ide>
<ide> QUnit.module("Handlebars {{#with foo}} with defined controller");
<ide>
<del>QUnit.skip("it should wrap context with object controller [DEPRECATED]", function() {
<add>QUnit.test("it should wrap context with object controller [DEPRECATED]", function() {
<ide> var childController;
<ide>
<ide> var Controller = ObjectController.extend({
<ide> QUnit.skip("it should wrap context with object controller [DEPRECATED]", functio
<ide> registry.register('controller:person', Controller);
<ide>
<ide> expectDeprecation(objectControllerDeprecation);
<del> expectDeprecation(function() {
<del> runAppend(view);
<del> }, 'Using the context switching form of `{{with}}` is deprecated. Please use the block param form (`{{#with bar as |foo|}}`) instead.');
<add> expectDeprecation('Using the context switching form of `{{with}}` is deprecated. Please use the block param form (`{{#with bar as |foo|}}`) instead.');
<add>
<add> runAppend(view);
<ide>
<ide> equal(view.$().text(), "controller:Steve Holt and Bob Loblaw");
<ide> | 2 |
Python | Python | remove incorrect docstrings in check_migrations | 9fde7a5ed0d72c8131e2002ace274fa0d45a6d5c | <ide><path>airflow/cli/commands/db_command.py
<ide> def upgradedb(args):
<ide>
<ide>
<ide> def check_migrations(args):
<del> """
<del> Function to wait for all airflow migrations to complete. Used for launching airflow in k8s
<del> @param timeout:
<del> @return:
<del> """
<add> """Function to wait for all airflow migrations to complete. Used for launching airflow in k8s"""
<ide> db.check_migrations(timeout=args.migration_wait_timeout)
<ide>
<ide> | 1 |
Ruby | Ruby | run the damn tests @tenderlove | cf3840e364161ae0206bf76051a2d21cc9e12e95 | <ide><path>activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
<ide> def to_sql(arel, binds = [])
<ide> # This is used in the StatementCache object. It returns an object that
<ide> # can be used to query the database repeatedly.
<ide> def cacheable_query(arel) # :nodoc:
<del> ActiveRecord::StatementCache.query self, visitor, arel.ast
<add> ActiveRecord::StatementCache.query visitor, arel.ast
<ide> end
<ide>
<ide> # Returns an ActiveRecord::Result instance.
<ide><path>activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
<ide> def initialize(connection, logger, connection_options, config)
<ide> end
<ide>
<ide> def cacheable_query(arel)
<del> ActiveRecord::StatementCache.partial_query self, visitor, arel.ast
<add> ActiveRecord::StatementCache.partial_query visitor, arel.ast
<ide> end
<ide>
<ide> MAX_INDEX_LENGTH_FOR_UTF8MB4 = 191 | 2 |
Javascript | Javascript | require common module only once | bfc4823d00c2609a462d4d0536d34b47f2684147 | <ide><path>test/parallel/test-tls-0-dns-altname.js
<ide> var tls = require('tls');
<ide>
<ide> var fs = require('fs');
<ide>
<del>var common = require('../common');
<del>
<ide> var requests = 0;
<ide>
<ide> var server = tls.createServer({
<ide><path>test/parallel/test-tls-max-send-fragment.js
<ide> var tls = require('tls');
<ide>
<ide> var fs = require('fs');
<ide>
<del>var common = require('../common');
<del>
<ide> var buf = new Buffer(10000);
<ide> var received = 0;
<ide> var ended = 0; | 2 |
Javascript | Javascript | add hash method to concatenated module | 4e90f435961f9267d7cd7e12f240f8bdcfcda077 | <ide><path>lib/optimize/ConcatenatedModule.js
<ide> class ConcatenatedModule extends Module {
<ide> return name;
<ide> }
<ide>
<add> updateHash(hash) {
<add> for(const m of this.modules) {
<add> m.updateHash(hash);
<add> }
<add> super.updateHash(hash);
<add> }
<add>
<ide> }
<ide>
<ide> class HarmonyImportSpecifierDependencyConcatenatedTemplate { | 1 |
Ruby | Ruby | remove `@nesting` ivar | 53454bfcb6b2351781cc7cde70792e347016c6f5 | <ide><path>actionpack/lib/action_dispatch/routing/mapper.rb
<ide> def with_scope_level(kind)
<ide>
<ide> def resource_scope(kind, resource) #:nodoc:
<ide> @scope = @scope.new(:scope_level_resource => resource)
<del> @nesting.push(resource)
<ide>
<ide> with_scope_level(kind) do
<ide> controller_scope(resource.resource_scope) { yield }
<ide> end
<ide> ensure
<del> @nesting.pop
<ide> @scope = @scope.parent
<ide> end
<ide>
<ide> def nested_options #:nodoc:
<ide> options
<ide> end
<ide>
<del> def nesting_depth #:nodoc:
<del> @nesting.size
<del> end
<del>
<ide> def shallow_nesting_depth #:nodoc:
<del> @nesting.count(&:shallow?)
<add> @scope.find_all { |frame|
<add> frame[:scope_level_resource]
<add> }.count { |frame| frame[:scope_level_resource].shallow? }
<ide> end
<ide>
<ide> def param_constraint? #:nodoc:
<ide> class Scope # :nodoc:
<ide>
<ide> attr_reader :parent, :scope_level
<ide>
<del> def initialize(hash, parent = {}, scope_level = nil)
<add> def initialize(hash, parent = NULL, scope_level = nil)
<ide> @hash = hash
<ide> @parent = parent
<ide> @scope_level = scope_level
<ide> def fetch(key, &block)
<ide> def [](key)
<ide> @hash.fetch(key) { @parent[key] }
<ide> end
<add>
<add> include Enumerable
<add>
<add> def each
<add> node = self
<add> loop do
<add> break if node.equal? NULL
<add> yield node.frame
<add> node = node.parent
<add> end
<add> end
<add>
<add> protected
<add>
<add> def frame; @hash; end
<add>
<add> NULL = Scope.new({}.freeze, {}.freeze)
<ide> end
<ide>
<ide> def initialize(set) #:nodoc:
<ide> @set = set
<ide> @scope = Scope.new({ :path_names => @set.resources_path_names })
<ide> @concerns = {}
<del> @nesting = []
<ide> end
<ide>
<ide> include Base | 1 |
Python | Python | implement fixes for trainingarguments doc | fa6dce250fd114fdc81f40a0f15c04b73a51ced1 | <ide><path>src/transformers/training_args.py
<ide> class TrainingArguments:
<ide> push_to_hub (`bool`, *optional*, defaults to `False`):
<ide> Whether or not to push the model to the Hub every time the model is saved. If this is activated,
<ide> `output_dir` will begin a git directory synced with the the repo (determined by `hub_model_id`) and the
<del> content will be pushed each time a save is triggered (depneding on your `save_strategy`). Calling
<del> [`~Trainer.save_model`] will also trigger a push
<add> content will be pushed each time a save is triggered (depending on your `save_strategy`). Calling
<add> [`~Trainer.save_model`] will also trigger a push.
<ide>
<ide> <Tip warning={true}>
<ide> | 1 |
Javascript | Javascript | upgrade apiplugin to es6 | 11c2865c641e38bc66973a5d80705a348190864c | <ide><path>lib/APIPlugin.js
<ide> MIT License http://www.opensource.org/licenses/mit-license.php
<ide> Author Tobias Koppers @sokra
<ide> */
<del>var ConstDependency = require("./dependencies/ConstDependency");
<del>var BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
<add>"use strict";
<ide>
<del>var NullFactory = require("./NullFactory");
<add>const ConstDependency = require("./dependencies/ConstDependency");
<add>const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
<ide>
<del>function APIPlugin() {}
<del>module.exports = APIPlugin;
<add>const NullFactory = require("./NullFactory");
<ide>
<del>var REPLACEMENTS = {
<add>const REPLACEMENTS = {
<ide> __webpack_require__: "__webpack_require__", // eslint-disable-line camelcase
<ide> __webpack_public_path__: "__webpack_require__.p", // eslint-disable-line camelcase
<ide> __webpack_modules__: "__webpack_require__.m", // eslint-disable-line camelcase
<ide> var REPLACEMENTS = {
<ide> __webpack_nonce__: "__webpack_require__.nc", // eslint-disable-line camelcase
<ide> "require.onError": "__webpack_require__.oe" // eslint-disable-line camelcase
<ide> };
<del>var REPLACEMENT_TYPES = {
<add>const REPLACEMENT_TYPES = {
<ide> __webpack_public_path__: "string", // eslint-disable-line camelcase
<ide> __webpack_require__: "function", // eslint-disable-line camelcase
<ide> __webpack_modules__: "object", // eslint-disable-line camelcase
<ide> __webpack_chunk_load__: "function", // eslint-disable-line camelcase
<ide> __webpack_nonce__: "string" // eslint-disable-line camelcase
<ide> };
<del>var IGNORES = [];
<del>APIPlugin.prototype.apply = function(compiler) {
<del> compiler.plugin("compilation", function(compilation, params) {
<del> compilation.dependencyFactories.set(ConstDependency, new NullFactory());
<del> compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
<del>
<del> params.normalModuleFactory.plugin("parser", function(parser) {
<del> Object.keys(REPLACEMENTS).forEach(function(key) {
<del> parser.plugin("expression " + key, function(expr) {
<del> var dep = new ConstDependency(REPLACEMENTS[key], expr.range);
<del> dep.loc = expr.loc;
<del> this.state.current.addDependency(dep);
<del> return true;
<del> });
<del> parser.plugin("evaluate typeof " + key, function(expr) {
<del> return new BasicEvaluatedExpression().setString(REPLACEMENT_TYPES[key]).setRange(expr.range);
<add>
<add>const IGNORES = [];
<add>
<add>class APIPlugin {
<add>
<add> apply(compiler) {
<add> compiler.plugin("compilation", (compilation, params) => {
<add> compilation.dependencyFactories.set(ConstDependency, new NullFactory());
<add> compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
<add>
<add> params.normalModuleFactory.plugin("parser", parser => {
<add> Object.keys(REPLACEMENTS).forEach(key => {
<add> parser.plugin(`expression ${key}`, expr => {
<add> const dep = new ConstDependency(REPLACEMENTS[key], expr.range);
<add> dep.loc = expr.loc;
<add> parser.state.current.addDependency(dep);
<add> return true;
<add> });
<add> parser.plugin(`evaluate typeof ${key}`, expr => {
<add> return new BasicEvaluatedExpression().setString(REPLACEMENT_TYPES[key]).setRange(expr.range);
<add> });
<ide> });
<del> });
<del> IGNORES.forEach(function(key) {
<del> parser.plugin(key, function() {
<del> return true;
<add> IGNORES.forEach(key => {
<add> parser.plugin(key, () => true);
<ide> });
<ide> });
<ide> });
<del> });
<del>};
<add> }
<add>}
<add>
<add>module.exports = APIPlugin; | 1 |
Javascript | Javascript | remove unneeded closure | 8b98b74076d961b755c1f46dcb168ccf61bc3291 | <ide><path>editor/js/Sidebar.Geometry.TubeGeometry.js
<ide> Sidebar.Geometry.TubeGeometry = function ( editor, object ) {
<ide> var pointsList = new UI.Div();
<ide> points.add( pointsList );
<ide>
<del> ( function () {
<add> var parameterPoints = parameters.path.points;
<add> for ( var i = 0; i < parameterPoints.length; i ++ ) {
<ide>
<del> var points = parameters.path.points;
<del> for ( var i = 0; i < points.length; i ++ ) {
<add> var point = parameterPoints[ i ];
<add> pointsList.add( createPointRow( point.x, point.y, point.z ) );
<ide>
<del> var point = points[ i ];
<del> pointsList.add( createPointRow( point.x, point.y, point.z ) );
<del>
<del> }
<del>
<del> } )();
<add> }
<ide>
<ide> var addPointButton = new UI.Button( '+' ).onClick( function () {
<ide> | 1 |
Ruby | Ruby | remove needless autoloads | 1c4a57e0e5b9666f0a05eb4fbdad09a6998ef54b | <ide><path>lib/action_mailbox.rb
<ide> module ActionMailbox
<ide>
<ide> autoload :Base
<ide> autoload :Router
<del> autoload :Callbacks
<del> autoload :Routing
<ide>
<ide> mattr_accessor :logger
<ide> mattr_accessor :incinerate_after, default: 30.days | 1 |
Ruby | Ruby | improve documentation and consistency | 3454d6a96199cc4f405a52d1525d0cc760a0ebf8 | <ide><path>Library/Homebrew/formula.rb
<ide> def recursive_requirements(&block)
<ide> Requirement.expand(self, &block)
<ide> end
<ide>
<add> # Returns a Keg for the opt_prefix or installed_prefix if they exist.
<add> # If not, return nil.
<add> # @private
<add> def opt_or_installed_prefix_keg
<add> if optlinked? && opt_prefix.exist?
<add> Keg.new(opt_prefix)
<add> elsif installed_prefix.directory?
<add> Keg.new(installed_prefix)
<add> end
<add> end
<add>
<ide> # Returns a list of Dependency objects that are required at runtime.
<ide> # @private
<ide> def runtime_dependencies(read_from_tab: true)
<ide> if read_from_tab &&
<ide> installed_prefix.directory? &&
<del> (keg = Keg.new(installed_prefix)) &&
<add> (keg = opt_or_installed_prefix_keg) &&
<ide> (tab_deps = keg.runtime_dependencies)
<ide> return tab_deps.map { |d| Dependency.new d["full_name"] }.compact
<ide> end
<ide>
<ide> declared_runtime_dependencies | undeclared_runtime_dependencies
<ide> end
<ide>
<add> # Returns a list of Dependency objects that are declared in the formula.
<add> # @private
<ide> def declared_runtime_dependencies
<ide> recursive_dependencies do |_, dependency|
<ide> Dependency.prune if dependency.build?
<ide> Dependency.prune if !dependency.required? && build.without?(dependency)
<ide> end
<ide> end
<ide>
<add> # Returns a list of Dependency objects that are not declared in the formula
<add> # but the formula links to.
<add> # @private
<ide> def undeclared_runtime_dependencies
<del> if optlinked?
<del> keg = Keg.new(opt_prefix)
<del> elsif prefix.directory?
<del> keg = Keg.new(prefix)
<del> else
<del> return []
<del> end
<add> keg = opt_or_installed_prefix_keg
<add> return [] unless keg
<ide>
<ide> linkage_checker = LinkageChecker.new(keg, self)
<ide> linkage_checker.undeclared_deps.map { |n| Dependency.new(n) }
<ide><path>Library/Homebrew/linkage_checker.rb
<ide> require "formula"
<ide>
<ide> class LinkageChecker
<add> attr_reader :undeclared_deps
<add>
<ide> def initialize(keg, formula = nil)
<ide> @keg = keg
<ide> @formula = formula || resolve_formula(keg)
<ide> def check_undeclared_deps
<ide>
<ide> missing_deps = @broken_deps.values.flatten.map { |d| dylib_to_dep(d) }
<ide> unnecessary_deps -= missing_deps
<del>
<add>
<ide> [indirect_deps, undeclared_deps, unnecessary_deps]
<ide> end
<ide>
<ide><path>Library/Homebrew/test/formula_spec.rb
<ide> def test
<ide> expect(f3.runtime_dependencies.map(&:name)).to eq(["foo/bar/f1", "baz/qux/f2"])
<ide> end
<ide>
<del> it "includes non-declared direct dependencies" do
<add> it "includes non-declared direct dependencies", :focus do
<ide> formula = Class.new(Testball).new
<ide> dependency = formula("dependency") { url "f-1.0" }
<ide>
<ide> formula.brew { formula.install }
<del> keg = Keg.for(formula.prefix)
<add> keg = Keg.for(formula.installed_prefix)
<ide> keg.link
<ide>
<ide> linkage_checker = double("linkage checker", undeclared_deps: [dependency.name])
<del> allow(LinkageChecker).to receive(:new).with(keg, any_args)
<del> .and_return(linkage_checker)
<add> allow(LinkageChecker).to receive(:new).and_return(linkage_checker)
<ide>
<del> expect(formula.runtime_dependencies).to include an_object_having_attributes(name: dependency.name)
<add> expect(formula.runtime_dependencies.map(&:name)).to eq [dependency.name]
<ide> end
<ide> end
<ide> | 3 |
Javascript | Javascript | improve history up/previous | b52bf605187d65be272a0ab8fb7f5623d8934f18 | <ide><path>lib/readline.js
<ide> Interface.prototype._historyNext = function() {
<ide> };
<ide>
<ide> Interface.prototype._historyPrev = function() {
<del> if (this.historyIndex < this.history.length) {
<add> if (this.historyIndex < this.history.length && this.history.length) {
<ide> const search = this[kSubstringSearch] || '';
<ide> let index = this.historyIndex + 1;
<ide> while (index < this.history.length &&
<ide> Interface.prototype._historyPrev = function() {
<ide> index++;
<ide> }
<ide> if (index === this.history.length) {
<del> // TODO(BridgeAR): Change this to:
<del> // this.line = search;
<del> return;
<add> this.line = search;
<ide> } else {
<ide> this.line = this.history[index];
<ide> }
<ide><path>test/parallel/test-readline-interface.js
<ide> function isWarned(emitter) {
<ide> fi.emit('keypress', '.', { name: 'up' }); // 'baz'
<ide> assert.strictEqual(rli.historyIndex, 2);
<ide> assert.strictEqual(rli.line, 'baz');
<del> fi.emit('keypress', '.', { name: 'up' }); // 'baz'
<del> assert.strictEqual(rli.historyIndex, 2);
<del> assert.strictEqual(rli.line, 'baz');
<del> fi.emit('keypress', '.', { name: 'up' }); // 'baz'
<del> assert.strictEqual(rli.historyIndex, 2);
<del> assert.strictEqual(rli.line, 'baz');
<add> fi.emit('keypress', '.', { name: 'up' }); // 'ba'
<add> assert.strictEqual(rli.historyIndex, 4);
<add> assert.strictEqual(rli.line, 'ba');
<add> fi.emit('keypress', '.', { name: 'up' }); // 'ba'
<add> assert.strictEqual(rli.historyIndex, 4);
<add> assert.strictEqual(rli.line, 'ba');
<add> // Deactivate substring history search and reset history index.
<add> fi.emit('keypress', '.', { name: 'right' }); // 'ba'
<add> assert.strictEqual(rli.historyIndex, -1);
<add> assert.strictEqual(rli.line, 'ba');
<add> // Substring history search activated.
<add> fi.emit('keypress', '.', { name: 'up' }); // 'ba'
<add> assert.strictEqual(rli.historyIndex, 0);
<add> assert.strictEqual(rli.line, 'bat');
<ide> rli.close();
<ide> }
<ide>
<ide><path>test/parallel/test-repl-history-navigation.js
<ide> const tests = [
<ide> },
<ide> {
<ide> env: { NODE_REPL_HISTORY: defaultHistoryPath },
<del> checkTotal: true,
<del> test: [UP, UP, UP, UP, UP, DOWN, DOWN, DOWN, DOWN],
<add> test: [UP, UP, UP, UP, UP, DOWN, DOWN, DOWN, DOWN, DOWN],
<ide> expected: [prompt,
<ide> `${prompt}Array(100).fill(1).map((e, i) => i ** 2)`,
<ide> prev && '\n// [ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, ' +
<ide> const tests = [
<ide> `${prompt}555 + 909`,
<ide> prev && '\n// 1464',
<ide> `${prompt}let ab = 45`,
<add> prompt,
<add> `${prompt}let ab = 45`,
<ide> `${prompt}555 + 909`,
<ide> prev && '\n// 1464',
<ide> `${prompt}{key : {key2 :[] }}`,
<ide> const tests = [
<ide> // UP - skipping const foo = true
<ide> '\x1B[1G', '\x1B[0J',
<ide> '> 555 + 909', '\x1B[12G',
<del> // UP, UP, ENTER. UPs at the end of the history have no effect.
<del> '\r\n',
<del> '1464\n',
<add> // UP, UP
<add> // UPs at the end of the history reset the line to the original input.
<add> '\x1B[1G', '\x1B[0J',
<add> '> 55', '\x1B[5G',
<add> // ENTER
<add> '\r\n', '55\n',
<ide> '\x1B[1G', '\x1B[0J',
<ide> '> ', '\x1B[3G',
<ide> '\r\n'
<ide><path>test/parallel/test-repl-persistent-history.js
<ide> const assert = require('assert');
<ide> const fs = require('fs');
<ide> const path = require('path');
<ide> const os = require('os');
<add>const util = require('util');
<ide>
<ide> const tmpdir = require('../common/tmpdir');
<ide> tmpdir.refresh();
<ide> ActionStream.prototype.readable = true;
<ide>
<ide> // Mock keys
<ide> const UP = { name: 'up' };
<add>const DOWN = { name: 'down' };
<ide> const ENTER = { name: 'enter' };
<ide> const CLEAR = { ctrl: true, name: 'u' };
<ide>
<ide> const tests = [
<ide> },
<ide> {
<ide> env: {},
<del> test: [UP, '\'42\'', ENTER],
<del> expected: [prompt, '\'', '4', '2', '\'', '\'42\'\n', prompt, prompt],
<add> test: [UP, '21', ENTER, "'42'", ENTER],
<add> expected: [
<add> prompt,
<add> '2', '1', '21\n', prompt, prompt,
<add> "'", '4', '2', "'", "'42'\n", prompt, prompt
<add> ],
<ide> clean: false
<ide> },
<ide> { // Requires the above test case
<ide> env: {},
<del> test: [UP, UP, ENTER],
<del> expected: [prompt, `${prompt}'42'`, '\'42\'\n', prompt]
<add> test: [UP, UP, CLEAR, ENTER, DOWN, CLEAR, ENTER, UP, ENTER],
<add> expected: [
<add> prompt,
<add> `${prompt}'42'`,
<add> `${prompt}21`,
<add> prompt,
<add> prompt,
<add> `${prompt}'42'`,
<add> prompt,
<add> prompt,
<add> `${prompt}21`,
<add> '21\n',
<add> prompt,
<add> ]
<ide> },
<ide> {
<ide> env: { NODE_REPL_HISTORY: historyPath,
<ide> NODE_REPL_HISTORY_SIZE: 1 },
<del> test: [UP, UP, CLEAR],
<del> expected: [prompt, `${prompt}'you look fabulous today'`, prompt]
<add> test: [UP, UP, DOWN, CLEAR],
<add> expected: [
<add> prompt,
<add> `${prompt}'you look fabulous today'`,
<add> prompt,
<add> `${prompt}'you look fabulous today'`,
<add> prompt
<add> ]
<ide> },
<ide> {
<ide> env: { NODE_REPL_HISTORY: historyPathFail,
<ide> function runTest(assertCleaned) {
<ide> const opts = tests.shift();
<ide> if (!opts) return; // All done
<ide>
<add> console.log('NEW');
<add>
<ide> if (assertCleaned) {
<ide> try {
<ide> assert.strictEqual(fs.readFileSync(defaultHistoryPath, 'utf8'), '');
<ide> function runTest(assertCleaned) {
<ide> output: new stream.Writable({
<ide> write(chunk, _, next) {
<ide> const output = chunk.toString();
<add> console.log('INPUT', util.inspect(output));
<ide>
<ide> // Ignore escapes and blank lines
<ide> if (output.charCodeAt(0) === 27 || /^[\r\n]+$/.test(output))
<ide> function runTest(assertCleaned) {
<ide> next();
<ide> }
<ide> }),
<del> prompt: prompt,
<add> prompt,
<ide> useColors: false,
<ide> terminal: true
<ide> }, function(err, repl) {
<ide><path>test/parallel/test-repl-programmatic-history.js
<ide> const assert = require('assert');
<ide> const fs = require('fs');
<ide> const path = require('path');
<ide> const os = require('os');
<add>const util = require('util');
<ide>
<ide> const tmpdir = require('../common/tmpdir');
<ide> tmpdir.refresh();
<ide> ActionStream.prototype.readable = true;
<ide>
<ide> // Mock keys
<ide> const UP = { name: 'up' };
<add>const DOWN = { name: 'down' };
<ide> const ENTER = { name: 'enter' };
<ide> const CLEAR = { ctrl: true, name: 'u' };
<ide>
<ide> const tests = [
<ide> },
<ide> {
<ide> env: {},
<del> test: [UP, '\'42\'', ENTER],
<del> expected: [prompt, '\'', '4', '2', '\'', '\'42\'\n', prompt, prompt],
<add> test: [UP, '21', ENTER, "'42'", ENTER],
<add> expected: [
<add> prompt,
<add> // TODO(BridgeAR): The line is refreshed too many times. The double prompt
<add> // is redundant and can be optimized away.
<add> '2', '1', '21\n', prompt, prompt,
<add> "'", '4', '2', "'", "'42'\n", prompt, prompt
<add> ],
<ide> clean: false
<ide> },
<ide> { // Requires the above test case
<ide> env: {},
<del> test: [UP, UP, ENTER],
<del> expected: [prompt, `${prompt}'42'`, '\'42\'\n', prompt]
<add> test: [UP, UP, UP, DOWN, ENTER],
<add> expected: [
<add> prompt,
<add> `${prompt}'42'`,
<add> `${prompt}21`,
<add> prompt,
<add> `${prompt}21`,
<add> '21\n',
<add> prompt
<add> ]
<ide> },
<ide> {
<ide> env: { NODE_REPL_HISTORY: historyPath,
<ide> NODE_REPL_HISTORY_SIZE: 1 },
<del> test: [UP, UP, CLEAR],
<del> expected: [prompt, `${prompt}'you look fabulous today'`, prompt]
<add> test: [UP, UP, DOWN, CLEAR],
<add> expected: [
<add> prompt,
<add> `${prompt}'you look fabulous today'`,
<add> prompt,
<add> `${prompt}'you look fabulous today'`,
<add> prompt
<add> ]
<ide> },
<ide> {
<ide> env: { NODE_REPL_HISTORY: historyPathFail,
<ide> function runTest(assertCleaned) {
<ide> const opts = tests.shift();
<ide> if (!opts) return; // All done
<ide>
<add> console.log('NEW');
<add>
<ide> if (assertCleaned) {
<ide> try {
<ide> assert.strictEqual(fs.readFileSync(defaultHistoryPath, 'utf8'), '');
<ide> function runTest(assertCleaned) {
<ide> output: new stream.Writable({
<ide> write(chunk, _, next) {
<ide> const output = chunk.toString();
<add> console.log('INPUT', util.inspect(output));
<ide>
<ide> // Ignore escapes and blank lines
<ide> if (output.charCodeAt(0) === 27 || /^[\r\n]+$/.test(output)) | 5 |
PHP | PHP | add missing docblock | 9e987784c934b9ab012f6c9360ef40646170d7f6 | <ide><path>src/Illuminate/Encryption/EncryptionServiceProvider.php
<ide> public function register()
<ide> *
<ide> * @param array $config
<ide> * @return string
<add> *
<add> * @throws \RuntimeException
<ide> */
<ide> protected function key(array $config)
<ide> { | 1 |
Ruby | Ruby | destroy blob record before deleting stored data | 07ecaa614b127a1a0b319c5f8eab3d6cad630ddc | <ide><path>activestorage/app/models/active_storage/blob.rb
<ide> def delete
<ide> # blobs. Note, though, that deleting the file off the service will initiate a HTTP connection to the service, which may
<ide> # be slow or prevented, so you should not use this method inside a transaction or in callbacks. Use #purge_later instead.
<ide> def purge
<del> delete
<ide> destroy
<add> delete
<ide> end
<ide>
<ide> # Enqueues an ActiveStorage::PurgeJob to call #purge. This is the recommended way to purge blobs from a transaction, | 1 |
Python | Python | fix spancat training on nested entities | 4d52d7051cda8492c54acf43a4e76fafd1aef6ec | <ide><path>spacy/pipeline/spancat.py
<ide> def _validate_categories(self, examples):
<ide> pass
<ide>
<ide> def _get_aligned_spans(self, eg: Example):
<del> return eg.get_aligned_spans_y2x(eg.reference.spans.get(self.key, []))
<add> return eg.get_aligned_spans_y2x(eg.reference.spans.get(self.key, []), allow_overlap=True)
<ide>
<ide> def _make_span_group(
<ide> self, doc: Doc, indices: Ints2d, scores: Floats2d, labels: List[str]
<ide><path>spacy/tests/pipeline/test_spancat.py
<ide> import numpy
<ide> from numpy.testing import assert_array_equal, assert_almost_equal
<ide> from thinc.api import get_current_ops
<add>
<add>from spacy import util
<add>from spacy.lang.en import English
<ide> from spacy.language import Language
<ide> from spacy.tokens.doc import SpanGroups
<ide> from spacy.tokens import SpanGroup
<ide> from spacy.training import Example
<del>from spacy.util import fix_random_seed, registry
<add>from spacy.util import fix_random_seed, registry, make_tempdir
<ide>
<ide> OPS = get_current_ops()
<ide>
<ide> ),
<ide> ]
<ide>
<add>TRAIN_DATA_OVERLAPPING = [
<add> ("Who is Shaka Khan?", {"spans": {SPAN_KEY: [(7, 17, "PERSON")]}}),
<add> (
<add> "I like London and Berlin",
<add> {"spans": {SPAN_KEY: [(7, 13, "LOC"), (18, 24, "LOC"), (7, 24, "DOUBLE_LOC")]}},
<add> ),
<add>]
<add>
<ide>
<del>def make_get_examples(nlp):
<add>def make_examples(nlp, data=TRAIN_DATA):
<ide> train_examples = []
<del> for t in TRAIN_DATA:
<add> for t in data:
<ide> eg = Example.from_dict(nlp.make_doc(t[0]), t[1])
<ide> train_examples.append(eg)
<del>
<del> def get_examples():
<del> return train_examples
<del>
<del> return get_examples
<add> return train_examples
<ide>
<ide>
<ide> def test_no_label():
<ide> def test_implicit_labels():
<ide> nlp = Language()
<ide> spancat = nlp.add_pipe("spancat", config={"spans_key": SPAN_KEY})
<ide> assert len(spancat.labels) == 0
<del> train_examples = []
<del> for t in TRAIN_DATA:
<del> train_examples.append(Example.from_dict(nlp.make_doc(t[0]), t[1]))
<add> train_examples = make_examples(nlp)
<ide> nlp.initialize(get_examples=lambda: train_examples)
<ide> assert spancat.labels == ("PERSON", "LOC")
<ide>
<ide> def test_make_spangroup(max_positive, nr_results):
<ide> assert_almost_equal(0.9, spangroup.attrs["scores"][-1], 5)
<ide>
<ide>
<del>def test_simple_train():
<del> fix_random_seed(0)
<del> nlp = Language()
<del> spancat = nlp.add_pipe("spancat", config={"spans_key": SPAN_KEY})
<del> get_examples = make_get_examples(nlp)
<del> nlp.initialize(get_examples)
<del> sgd = nlp.create_optimizer()
<del> assert len(spancat.labels) != 0
<del> for i in range(40):
<del> losses = {}
<del> nlp.update(list(get_examples()), losses=losses, drop=0.1, sgd=sgd)
<del> doc = nlp("I like London and Berlin.")
<del> assert doc.spans[spancat.key] == doc.spans[SPAN_KEY]
<del> assert len(doc.spans[spancat.key]) == 2
<del> assert len(doc.spans[spancat.key].attrs["scores"]) == 2
<del> assert doc.spans[spancat.key][0].text == "London"
<del> scores = nlp.evaluate(get_examples())
<del> assert f"spans_{SPAN_KEY}_f" in scores
<del> assert scores[f"spans_{SPAN_KEY}_f"] == 1.0
<del> # also test that the spancat works for just a single entity in a sentence
<del> doc = nlp("London")
<del> assert len(doc.spans[spancat.key]) == 1
<del>
<del>
<ide> def test_ngram_suggester(en_tokenizer):
<ide> # test different n-gram lengths
<ide> for size in [1, 2, 3]:
<ide> def test_ngram_sizes(en_tokenizer):
<ide> range_suggester = suggester_factory(min_size=2, max_size=4)
<ide> ngrams_3 = range_suggester(docs)
<ide> assert_array_equal(OPS.to_numpy(ngrams_3.lengths), [0, 1, 3, 6, 9])
<add>
<add>
<add>def test_overfitting_IO():
<add> # Simple test to try and quickly overfit the spancat component - ensuring the ML models work correctly
<add> fix_random_seed(0)
<add> nlp = English()
<add> spancat = nlp.add_pipe("spancat", config={"spans_key": SPAN_KEY})
<add> train_examples = make_examples(nlp)
<add> optimizer = nlp.initialize(get_examples=lambda: train_examples)
<add> assert spancat.model.get_dim("nO") == 2
<add> assert set(spancat.labels) == {"LOC", "PERSON"}
<add>
<add> for i in range(50):
<add> losses = {}
<add> nlp.update(train_examples, sgd=optimizer, losses=losses)
<add> assert losses["spancat"] < 0.01
<add>
<add> # test the trained model
<add> test_text = "I like London and Berlin"
<add> doc = nlp(test_text)
<add> assert doc.spans[spancat.key] == doc.spans[SPAN_KEY]
<add> spans = doc.spans[SPAN_KEY]
<add> assert len(spans) == 2
<add> assert len(spans.attrs["scores"]) == 2
<add> assert min(spans.attrs["scores"]) > 0.9
<add> assert set([span.text for span in spans]) == {"London", "Berlin"}
<add> assert set([span.label_ for span in spans]) == {"LOC"}
<add>
<add> # Also test the results are still the same after IO
<add> with make_tempdir() as tmp_dir:
<add> nlp.to_disk(tmp_dir)
<add> nlp2 = util.load_model_from_path(tmp_dir)
<add> doc2 = nlp2(test_text)
<add> spans2 = doc2.spans[SPAN_KEY]
<add> assert len(spans2) == 2
<add> assert len(spans2.attrs["scores"]) == 2
<add> assert min(spans2.attrs["scores"]) > 0.9
<add> assert set([span.text for span in spans2]) == {"London", "Berlin"}
<add> assert set([span.label_ for span in spans2]) == {"LOC"}
<add>
<add> # Test scoring
<add> scores = nlp.evaluate(train_examples)
<add> assert f"spans_{SPAN_KEY}_f" in scores
<add> assert scores[f"spans_{SPAN_KEY}_p"] == 1.0
<add> assert scores[f"spans_{SPAN_KEY}_r"] == 1.0
<add> assert scores[f"spans_{SPAN_KEY}_f"] == 1.0
<add>
<add> # also test that the spancat works for just a single entity in a sentence
<add> doc = nlp("London")
<add> assert len(doc.spans[spancat.key]) == 1
<add>
<add>
<add>def test_overfitting_IO_overlapping():
<add> # Test for overfitting on overlapping entities
<add> fix_random_seed(0)
<add> nlp = English()
<add> spancat = nlp.add_pipe("spancat", config={"spans_key": SPAN_KEY})
<add>
<add> train_examples = make_examples(nlp, data=TRAIN_DATA_OVERLAPPING)
<add> optimizer = nlp.initialize(get_examples=lambda: train_examples)
<add> assert spancat.model.get_dim("nO") == 3
<add> assert set(spancat.labels) == {"PERSON", "LOC", "DOUBLE_LOC"}
<add>
<add> for i in range(50):
<add> losses = {}
<add> nlp.update(train_examples, sgd=optimizer, losses=losses)
<add> assert losses["spancat"] < 0.01
<add>
<add> # test the trained model
<add> test_text = "I like London and Berlin"
<add> doc = nlp(test_text)
<add> spans = doc.spans[SPAN_KEY]
<add> assert len(spans) == 3
<add> assert len(spans.attrs["scores"]) == 3
<add> assert min(spans.attrs["scores"]) > 0.9
<add> assert set([span.text for span in spans]) == {"London", "Berlin", "London and Berlin"}
<add> assert set([span.label_ for span in spans]) == {"LOC", "DOUBLE_LOC"}
<add>
<add> # Also test the results are still the same after IO
<add> with make_tempdir() as tmp_dir:
<add> nlp.to_disk(tmp_dir)
<add> nlp2 = util.load_model_from_path(tmp_dir)
<add> doc2 = nlp2(test_text)
<add> spans2 = doc2.spans[SPAN_KEY]
<add> assert len(spans2) == 3
<add> assert len(spans2.attrs["scores"]) == 3
<add> assert min(spans2.attrs["scores"]) > 0.9
<add> assert set([span.text for span in spans2]) == {"London", "Berlin", "London and Berlin"}
<add> assert set([span.label_ for span in spans2]) == {"LOC", "DOUBLE_LOC"} | 2 |
Mixed | Ruby | add preload_link_tag helper | eb90b8bc86e758045a707cae43d11dab538ca6db | <ide><path>actionview/CHANGELOG.md
<add>* Add `preload_link_tag` helper
<add>
<add> This helper that allows to the browser to initiate early fetch of resources
<add> (different to the specified in javascript_include_tag and stylesheet_link_tag).
<add> Additionally, this sends Early Hints if supported by browser.
<add>
<add> *Guillermo Iguaran*
<add>
<ide> ## Rails 5.2.0.beta2 (November 28, 2017) ##
<ide>
<ide> * No changes.
<ide><path>actionview/lib/action_view/helpers/asset_tag_helper.rb
<ide>
<ide> require "active_support/core_ext/array/extract_options"
<ide> require "active_support/core_ext/hash/keys"
<add>require "active_support/core_ext/object/inclusion"
<add>require "active_support/core_ext/object/try"
<ide> require "action_view/helpers/asset_url_helper"
<ide> require "action_view/helpers/tag_helper"
<ide>
<ide> def favicon_link_tag(source = "favicon.ico", options = {})
<ide> }.merge!(options.symbolize_keys))
<ide> end
<ide>
<add> # Returns a link tag that browsers can use to preload the +source+.
<add> # The +source+ can be the path of an resource managed by asset pipeline,
<add> # a full path or an URI.
<add> #
<add> # ==== Options
<add> #
<add> # * <tt>:type</tt> - Override the auto-generated mime type, defaults to the mime type for +source+ extension.
<add> # * <tt>:as</tt> - Override the auto-generated value for as attribute, calculated using +source+ extension and mime type.
<add> # * <tt>:crossorigin</tt> - Specify the crossorigin attribute, required to load cross-origin resources.
<add> # * <tt>:nopush</tt> - Specify if the use of server push is not desired for the resource. Defaults to +false+.
<add> #
<add> # ==== Examples
<add> #
<add> # preload_link_tag("custom_theme.css")
<add> # # => <link rel="preload" href="/assets/custom_theme.css" as="style" type="text/css" />
<add> #
<add> # preload_link_tag("/videos/video.webm")
<add> # # => <link rel="preload" href="/videos/video.mp4" as="video" type="video/webm" />
<add> #
<add> # preload_link_tag(post_path(format: :json), as: "fetch")
<add> # # => <link rel="preload" href="/posts.json" as="fetch" type="application/json" />
<add> #
<add> # preload_link_tag("worker.js", as: "worker")
<add> # # => <link rel="preload" href="/assets/worker.js" as="worker" type="text/javascript" />
<add> #
<add> # preload_link_tag("//example.com/font.woff2")
<add> # # => <link rel="preload" href="//example.com/font.woff2" as="font" type="font/woff2" crossorigin="anonymous"/>
<add> #
<add> # preload_link_tag("//example.com/font.woff2", crossorigin: "use-credentials")
<add> # # => <link rel="preload" href="//example.com/font.woff2" as="font" type="font/woff2" crossorigin="use-credentials" />
<add> #
<add> # preload_link_tag("/media/audio.ogg", nopush: true)
<add> # # => <link rel="preload" href="/media/audio.ogg" as="audio" type="audio/ogg" />
<add> #
<add> def preload_link_tag(source, options = {})
<add> href = asset_path(source, skip_pipeline: options.delete(:skip_pipeline))
<add> extname = File.extname(source).downcase.delete(".")
<add> mime_type = options.delete(:type) || Template::Types[extname].try(:to_s)
<add> as_type = options.delete(:as) || resolve_link_as(extname, mime_type)
<add> crossorigin = options.delete(:crossorigin)
<add> crossorigin = "anonymous" if crossorigin == true || (crossorigin.blank? && as_type == "font")
<add> nopush = options.delete(:nopush) || false
<add>
<add> link_tag = tag.link({
<add> rel: "preload",
<add> href: href,
<add> as: as_type,
<add> type: mime_type,
<add> crossorigin: crossorigin
<add> }.merge!(options.symbolize_keys))
<add>
<add> early_hints_link = "<#{href}>; rel=preload; as=#{as_type}"
<add> early_hints_link += "; type=#{mime_type}" if mime_type
<add> early_hints_link += "; crossorigin=#{crossorigin}" if crossorigin
<add> early_hints_link += "; nopush" if nopush
<add>
<add> request.send_early_hints("Link" => early_hints_link) if respond_to?(:request) && request
<add>
<add> link_tag
<add> end
<add>
<ide> # Returns an HTML image tag for the +source+. The +source+ can be a full
<ide> # path, a file or an Active Storage attachment.
<ide> #
<ide> def check_for_image_tag_errors(options)
<ide> raise ArgumentError, "Cannot pass a :size option with a :height or :width option"
<ide> end
<ide> end
<add>
<add> def resolve_link_as(extname, mime_type)
<add> if extname == "js"
<add> "script"
<add> elsif extname == "css"
<add> "style"
<add> elsif extname == "vtt"
<add> "track"
<add> elsif (type = mime_type.to_s.split("/")[0]) && type.in?(%w(audio video font))
<add> type
<add> end
<add> end
<ide> end
<ide> end
<ide> end
<ide><path>actionview/test/template/asset_tag_helper_test.rb
<ide> def url_for(*args)
<ide> %(favicon_link_tag 'mb-icon.png', :rel => 'apple-touch-icon', :type => 'image/png') => %(<link href="/images/mb-icon.png" rel="apple-touch-icon" type="image/png" />)
<ide> }
<ide>
<add> PreloadLinkToTag = {
<add> %(preload_link_tag '/styles/custom_theme.css') => %(<link rel="preload" href="/styles/custom_theme.css" as="style" type="text/css" />),
<add> %(preload_link_tag '/videos/video.webm') => %(<link rel="preload" href="/videos/video.webm" as="video" type="video/webm" />),
<add> %(preload_link_tag '/posts.json', as: 'fetch') => %(<link rel="preload" href="/posts.json" as="fetch" type="application/json" />),
<add> %(preload_link_tag '/users', as: 'fetch', type: 'application/json') => %(<link rel="preload" href="/users" as="fetch" type="application/json" />),
<add> %(preload_link_tag '//example.com/map?callback=initMap', as: 'fetch', type: 'application/javascript') => %(<link rel="preload" href="//example.com/map?callback=initMap" as="fetch" type="application/javascript" />),
<add> %(preload_link_tag '//example.com/font.woff2') => %(<link rel="preload" href="//example.com/font.woff2" as="font" type="font/woff2" crossorigin="anonymous"/>),
<add> %(preload_link_tag '//example.com/font.woff2', crossorigin: 'use-credentials') => %(<link rel="preload" href="//example.com/font.woff2" as="font" type="font/woff2" crossorigin="use-credentials" />),
<add> %(preload_link_tag '/media/audio.ogg', nopush: true) => %(<link rel="preload" href="/media/audio.ogg" as="audio" type="audio/ogg" />)
<add> }
<add>
<ide> VideoPathToTag = {
<ide> %(video_path("xml")) => %(/videos/xml),
<ide> %(video_path("xml.ogg")) => %(/videos/xml.ogg),
<ide> def test_favicon_link_tag
<ide> FaviconLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
<ide> end
<ide>
<add> def test_preload_link_tag
<add> PreloadLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
<add> end
<add>
<ide> def test_video_path
<ide> VideoPathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
<ide> end | 3 |
Text | Text | update introduction documentation | 5129e1aaf7800e1a816b4638cde3326af684eb31 | <ide><path>docs/README.md
<ide> var myChart = new Chart(ctx, {
<ide>
<ide> ## Contributing
<ide>
<del>Before submitting an issue or a pull request to the project, please take a moment to look over the [contributing guidelines](https://github.com/chartjs/Chart.js/blob/master/docs/developers/contributing.md) first.
<add>Before submitting an issue or a pull request to the project, please take a moment to look over the [contributing guidelines](./developers/contributing.md) first.
<ide>
<ide> For support using Chart.js, please post questions with the [`chartjs` tag on Stack Overflow](https://stackoverflow.com/questions/tagged/chartjs).
<ide> | 1 |
PHP | PHP | fix a test | 0e4a1c2a9700688f52ea6f88d1346cd452b00af3 | <ide><path>tests/TestCase/ORM/TableTest.php
<ide> public function testDeleteDependentAliased()
<ide> $Articles->associations()->removeAll();
<ide>
<ide> $Authors->hasMany('AliasedArticles', [
<del> 'className' => 'articles',
<add> 'className' => 'Articles',
<ide> 'dependent' => true,
<ide> 'cascadeCallbacks' => true
<ide> ]); | 1 |
Go | Go | move directive out of globals | 755be795b4e48b3eadcdf1427bf9731b0e97bed1 | <ide><path>builder/dockerfile/builder.go
<ide> type Builder struct {
<ide> disableCommit bool
<ide> cacheBusted bool
<ide> allowedBuildArgs map[string]bool // list of build-time args that are allowed for expansion/substitution and passing to commands in 'run'.
<add> directive parser.Directive
<ide>
<ide> // TODO: remove once docker.Commit can receive a tag
<ide> id string
<ide> func NewBuilder(clientCtx context.Context, config *types.ImageBuildOptions, back
<ide> tmpContainers: map[string]struct{}{},
<ide> id: stringid.GenerateNonCryptoID(),
<ide> allowedBuildArgs: make(map[string]bool),
<add> directive: parser.Directive{
<add> EscapeSeen: false,
<add> LookingForDirectives: true,
<add> },
<ide> }
<add> parser.SetEscapeToken(parser.DefaultEscapeToken, &b.directive) // Assume the default token for escape
<add>
<ide> if dockerfile != nil {
<del> b.dockerfile, err = parser.Parse(dockerfile)
<add> b.dockerfile, err = parser.Parse(dockerfile, &b.directive)
<ide> if err != nil {
<ide> return nil, err
<ide> }
<ide> func (b *Builder) build(stdout io.Writer, stderr io.Writer, out io.Writer) (stri
<ide> for k, v := range b.options.Labels {
<ide> line += fmt.Sprintf("%q=%q ", k, v)
<ide> }
<del> _, node, err := parser.ParseLine(line)
<add> _, node, err := parser.ParseLine(line, &b.directive)
<ide> if err != nil {
<ide> return "", err
<ide> }
<ide> func (b *Builder) Cancel() {
<ide> //
<ide> // TODO: Remove?
<ide> func BuildFromConfig(config *container.Config, changes []string) (*container.Config, error) {
<del> ast, err := parser.Parse(bytes.NewBufferString(strings.Join(changes, "\n")))
<add> b, err := NewBuilder(context.Background(), nil, nil, nil, nil)
<add> if err != nil {
<add> return nil, err
<add> }
<add>
<add> ast, err := parser.Parse(bytes.NewBufferString(strings.Join(changes, "\n")), &b.directive)
<ide> if err != nil {
<ide> return nil, err
<ide> }
<ide> func BuildFromConfig(config *container.Config, changes []string) (*container.Con
<ide> }
<ide> }
<ide>
<del> b, err := NewBuilder(context.Background(), nil, nil, nil, nil)
<del> if err != nil {
<del> return nil, err
<del> }
<ide> b.runConfig = config
<ide> b.Stdout = ioutil.Discard
<ide> b.Stderr = ioutil.Discard
<ide><path>builder/dockerfile/evaluator_test.go
<ide> func executeTestCase(t *testing.T, testCase dispatchTestCase) {
<ide> }()
<ide>
<ide> r := strings.NewReader(testCase.dockerfile)
<del> n, err := parser.Parse(r)
<add> d := parser.Directive{}
<add> parser.SetEscapeToken(parser.DefaultEscapeToken, &d)
<add> n, err := parser.Parse(r, &d)
<ide>
<ide> if err != nil {
<ide> t.Fatalf("Error when parsing Dockerfile: %s", err)
<ide><path>builder/dockerfile/internals.go
<ide> func (b *Builder) processImageFrom(img builder.Image) error {
<ide>
<ide> // parse the ONBUILD triggers by invoking the parser
<ide> for _, step := range onBuildTriggers {
<del> ast, err := parser.Parse(strings.NewReader(step))
<add> ast, err := parser.Parse(strings.NewReader(step), &b.directive)
<ide> if err != nil {
<ide> return err
<ide> }
<ide> func (b *Builder) parseDockerfile() error {
<ide> return fmt.Errorf("The Dockerfile (%s) cannot be empty", b.options.Dockerfile)
<ide> }
<ide> }
<del> b.dockerfile, err = parser.Parse(f)
<add> b.dockerfile, err = parser.Parse(f, &b.directive)
<ide> if err != nil {
<ide> return err
<ide> }
<ide><path>builder/dockerfile/parser/dumper/main.go
<ide> func main() {
<ide> panic(err)
<ide> }
<ide>
<del> ast, err := parser.Parse(f)
<add> d := parser.Directive{LookingForDirectives: true}
<add> parser.SetEscapeToken(parser.DefaultEscapeToken, &d)
<add>
<add> ast, err := parser.Parse(f, &d)
<ide> if err != nil {
<ide> panic(err)
<ide> } else {
<ide><path>builder/dockerfile/parser/json_test.go
<ide> var validJSONArraysOfStrings = map[string][]string{
<ide>
<ide> func TestJSONArraysOfStrings(t *testing.T) {
<ide> for json, expected := range validJSONArraysOfStrings {
<del> if node, _, err := parseJSON(json); err != nil {
<add> d := Directive{}
<add> SetEscapeToken(DefaultEscapeToken, &d)
<add>
<add> if node, _, err := parseJSON(json, &d); err != nil {
<ide> t.Fatalf("%q should be a valid JSON array of strings, but wasn't! (err: %q)", json, err)
<ide> } else {
<ide> i := 0
<ide> func TestJSONArraysOfStrings(t *testing.T) {
<ide> }
<ide> }
<ide> for _, json := range invalidJSONArraysOfStrings {
<del> if _, _, err := parseJSON(json); err != errDockerfileNotStringArray {
<add> d := Directive{}
<add> SetEscapeToken(DefaultEscapeToken, &d)
<add>
<add> if _, _, err := parseJSON(json, &d); err != errDockerfileNotStringArray {
<ide> t.Fatalf("%q should be an invalid JSON array of strings, but wasn't!", json)
<ide> }
<ide> }
<ide><path>builder/dockerfile/parser/line_parsers.go
<ide> var (
<ide>
<ide> // ignore the current argument. This will still leave a command parsed, but
<ide> // will not incorporate the arguments into the ast.
<del>func parseIgnore(rest string) (*Node, map[string]bool, error) {
<add>func parseIgnore(rest string, d *Directive) (*Node, map[string]bool, error) {
<ide> return &Node{}, nil, nil
<ide> }
<ide>
<ide> func parseIgnore(rest string) (*Node, map[string]bool, error) {
<ide> //
<ide> // ONBUILD RUN foo bar -> (onbuild (run foo bar))
<ide> //
<del>func parseSubCommand(rest string) (*Node, map[string]bool, error) {
<add>func parseSubCommand(rest string, d *Directive) (*Node, map[string]bool, error) {
<ide> if rest == "" {
<ide> return nil, nil, nil
<ide> }
<ide>
<del> _, child, err := ParseLine(rest)
<add> _, child, err := ParseLine(rest, d)
<ide> if err != nil {
<ide> return nil, nil, err
<ide> }
<ide> func parseSubCommand(rest string) (*Node, map[string]bool, error) {
<ide> // helper to parse words (i.e space delimited or quoted strings) in a statement.
<ide> // The quotes are preserved as part of this function and they are stripped later
<ide> // as part of processWords().
<del>func parseWords(rest string) []string {
<add>func parseWords(rest string, d *Directive) []string {
<ide> const (
<ide> inSpaces = iota // looking for start of a word
<ide> inWord
<ide> func parseWords(rest string) []string {
<ide> blankOK = true
<ide> phase = inQuote
<ide> }
<del> if ch == tokenEscape {
<add> if ch == d.EscapeToken {
<ide> if pos+chWidth == len(rest) {
<ide> continue // just skip an escape token at end of line
<ide> }
<ide> func parseWords(rest string) []string {
<ide> phase = inWord
<ide> }
<ide> // The escape token is special except for ' quotes - can't escape anything for '
<del> if ch == tokenEscape && quote != '\'' {
<add> if ch == d.EscapeToken && quote != '\'' {
<ide> if pos+chWidth == len(rest) {
<ide> phase = inWord
<ide> continue // just skip the escape token at end
<ide> func parseWords(rest string) []string {
<ide>
<ide> // parse environment like statements. Note that this does *not* handle
<ide> // variable interpolation, which will be handled in the evaluator.
<del>func parseNameVal(rest string, key string) (*Node, map[string]bool, error) {
<add>func parseNameVal(rest string, key string, d *Directive) (*Node, map[string]bool, error) {
<ide> // This is kind of tricky because we need to support the old
<ide> // variant: KEY name value
<ide> // as well as the new one: KEY name=value ...
<ide> // The trigger to know which one is being used will be whether we hit
<ide> // a space or = first. space ==> old, "=" ==> new
<ide>
<del> words := parseWords(rest)
<add> words := parseWords(rest, d)
<ide> if len(words) == 0 {
<ide> return nil, nil, nil
<ide> }
<ide> func parseNameVal(rest string, key string) (*Node, map[string]bool, error) {
<ide> return rootnode, nil, nil
<ide> }
<ide>
<del>func parseEnv(rest string) (*Node, map[string]bool, error) {
<del> return parseNameVal(rest, "ENV")
<add>func parseEnv(rest string, d *Directive) (*Node, map[string]bool, error) {
<add> return parseNameVal(rest, "ENV", d)
<ide> }
<ide>
<del>func parseLabel(rest string) (*Node, map[string]bool, error) {
<del> return parseNameVal(rest, "LABEL")
<add>func parseLabel(rest string, d *Directive) (*Node, map[string]bool, error) {
<add> return parseNameVal(rest, "LABEL", d)
<ide> }
<ide>
<ide> // parses a statement containing one or more keyword definition(s) and/or
<ide> func parseLabel(rest string) (*Node, map[string]bool, error) {
<ide> // In addition, a keyword definition alone is of the form `keyword` like `name1`
<ide> // above. And the assignments `name2=` and `name3=""` are equivalent and
<ide> // assign an empty value to the respective keywords.
<del>func parseNameOrNameVal(rest string) (*Node, map[string]bool, error) {
<del> words := parseWords(rest)
<add>func parseNameOrNameVal(rest string, d *Directive) (*Node, map[string]bool, error) {
<add> words := parseWords(rest, d)
<ide> if len(words) == 0 {
<ide> return nil, nil, nil
<ide> }
<ide> func parseNameOrNameVal(rest string) (*Node, map[string]bool, error) {
<ide>
<ide> // parses a whitespace-delimited set of arguments. The result is effectively a
<ide> // linked list of string arguments.
<del>func parseStringsWhitespaceDelimited(rest string) (*Node, map[string]bool, error) {
<add>func parseStringsWhitespaceDelimited(rest string, d *Directive) (*Node, map[string]bool, error) {
<ide> if rest == "" {
<ide> return nil, nil, nil
<ide> }
<ide> func parseStringsWhitespaceDelimited(rest string) (*Node, map[string]bool, error
<ide> }
<ide>
<ide> // parsestring just wraps the string in quotes and returns a working node.
<del>func parseString(rest string) (*Node, map[string]bool, error) {
<add>func parseString(rest string, d *Directive) (*Node, map[string]bool, error) {
<ide> if rest == "" {
<ide> return nil, nil, nil
<ide> }
<ide> func parseString(rest string) (*Node, map[string]bool, error) {
<ide> }
<ide>
<ide> // parseJSON converts JSON arrays to an AST.
<del>func parseJSON(rest string) (*Node, map[string]bool, error) {
<add>func parseJSON(rest string, d *Directive) (*Node, map[string]bool, error) {
<ide> rest = strings.TrimLeftFunc(rest, unicode.IsSpace)
<ide> if !strings.HasPrefix(rest, "[") {
<ide> return nil, nil, fmt.Errorf(`Error parsing "%s" as a JSON array`, rest)
<ide> func parseJSON(rest string) (*Node, map[string]bool, error) {
<ide> // parseMaybeJSON determines if the argument appears to be a JSON array. If
<ide> // so, passes to parseJSON; if not, quotes the result and returns a single
<ide> // node.
<del>func parseMaybeJSON(rest string) (*Node, map[string]bool, error) {
<add>func parseMaybeJSON(rest string, d *Directive) (*Node, map[string]bool, error) {
<ide> if rest == "" {
<ide> return nil, nil, nil
<ide> }
<ide>
<del> node, attrs, err := parseJSON(rest)
<add> node, attrs, err := parseJSON(rest, d)
<ide>
<ide> if err == nil {
<ide> return node, attrs, nil
<ide> func parseMaybeJSON(rest string) (*Node, map[string]bool, error) {
<ide> // parseMaybeJSONToList determines if the argument appears to be a JSON array. If
<ide> // so, passes to parseJSON; if not, attempts to parse it as a whitespace
<ide> // delimited string.
<del>func parseMaybeJSONToList(rest string) (*Node, map[string]bool, error) {
<del> node, attrs, err := parseJSON(rest)
<add>func parseMaybeJSONToList(rest string, d *Directive) (*Node, map[string]bool, error) {
<add> node, attrs, err := parseJSON(rest, d)
<ide>
<ide> if err == nil {
<ide> return node, attrs, nil
<ide> func parseMaybeJSONToList(rest string) (*Node, map[string]bool, error) {
<ide> return nil, nil, err
<ide> }
<ide>
<del> return parseStringsWhitespaceDelimited(rest)
<add> return parseStringsWhitespaceDelimited(rest, d)
<ide> }
<ide>
<ide> // The HEALTHCHECK command is like parseMaybeJSON, but has an extra type argument.
<del>func parseHealthConfig(rest string) (*Node, map[string]bool, error) {
<add>func parseHealthConfig(rest string, d *Directive) (*Node, map[string]bool, error) {
<ide> // Find end of first argument
<ide> var sep int
<ide> for ; sep < len(rest); sep++ {
<ide> func parseHealthConfig(rest string) (*Node, map[string]bool, error) {
<ide> }
<ide>
<ide> typ := rest[:sep]
<del> cmd, attrs, err := parseMaybeJSON(rest[next:])
<add> cmd, attrs, err := parseMaybeJSON(rest[next:], d)
<ide> if err != nil {
<ide> return nil, nil, err
<ide> }
<ide><path>builder/dockerfile/parser/parser.go
<ide> type Node struct {
<ide> EndLine int // the line in the original dockerfile where the node ends
<ide> }
<ide>
<del>const defaultTokenEscape = "\\"
<add>// Directive is the structure used during a build run to hold the state of
<add>// parsing directives.
<add>type Directive struct {
<add> EscapeToken rune // Current escape token
<add> LineContinuationRegex *regexp.Regexp // Current line contination regex
<add> LookingForDirectives bool // Whether we are currently looking for directives
<add> EscapeSeen bool // Whether the escape directive has been seen
<add>}
<ide>
<ide> var (
<del> dispatch map[string]func(string) (*Node, map[string]bool, error)
<del> tokenWhitespace = regexp.MustCompile(`[\t\v\f\r ]+`)
<del> tokenLineContinuation *regexp.Regexp
<del> tokenEscape = rune(defaultTokenEscape[0])
<del> tokenEscapeCommand = regexp.MustCompile(`^#[ \t]*escape[ \t]*=[ \t]*(?P<escapechar>.).*$`)
<del> tokenComment = regexp.MustCompile(`^#.*$`)
<del> lookingForDirectives bool
<del> directiveEscapeSeen bool
<add> dispatch map[string]func(string, *Directive) (*Node, map[string]bool, error)
<add> tokenWhitespace = regexp.MustCompile(`[\t\v\f\r ]+`)
<add> tokenEscapeCommand = regexp.MustCompile(`^#[ \t]*escape[ \t]*=[ \t]*(?P<escapechar>.).*$`)
<add> tokenComment = regexp.MustCompile(`^#.*$`)
<ide> )
<ide>
<del>// setTokenEscape sets the default token for escaping characters in a Dockerfile.
<del>func setTokenEscape(s string) error {
<add>// DefaultEscapeToken is the default escape token
<add>const DefaultEscapeToken = "\\"
<add>
<add>// SetEscapeToken sets the default token for escaping characters in a Dockerfile.
<add>func SetEscapeToken(s string, d *Directive) error {
<ide> if s != "`" && s != "\\" {
<ide> return fmt.Errorf("invalid ESCAPE '%s'. Must be ` or \\", s)
<ide> }
<del> tokenEscape = rune(s[0])
<del> tokenLineContinuation = regexp.MustCompile(`\` + s + `[ \t]*$`)
<add> d.EscapeToken = rune(s[0])
<add> d.LineContinuationRegex = regexp.MustCompile(`\` + s + `[ \t]*$`)
<ide> return nil
<ide> }
<ide>
<ide> func init() {
<ide> // reformulating the arguments according to the rules in the parser
<ide> // functions. Errors are propagated up by Parse() and the resulting AST can
<ide> // be incorporated directly into the existing AST as a next.
<del> dispatch = map[string]func(string) (*Node, map[string]bool, error){
<add> dispatch = map[string]func(string, *Directive) (*Node, map[string]bool, error){
<ide> command.Add: parseMaybeJSONToList,
<ide> command.Arg: parseNameOrNameVal,
<ide> command.Cmd: parseMaybeJSON,
<ide> func init() {
<ide> }
<ide>
<ide> // ParseLine parse a line and return the remainder.
<del>func ParseLine(line string) (string, *Node, error) {
<del>
<add>func ParseLine(line string, d *Directive) (string, *Node, error) {
<ide> // Handle the parser directive '# escape=<char>. Parser directives must precede
<ide> // any builder instruction or other comments, and cannot be repeated.
<del> if lookingForDirectives {
<add> if d.LookingForDirectives {
<ide> tecMatch := tokenEscapeCommand.FindStringSubmatch(strings.ToLower(line))
<ide> if len(tecMatch) > 0 {
<del> if directiveEscapeSeen == true {
<add> if d.EscapeSeen == true {
<ide> return "", nil, fmt.Errorf("only one escape parser directive can be used")
<ide> }
<ide> for i, n := range tokenEscapeCommand.SubexpNames() {
<ide> if n == "escapechar" {
<del> if err := setTokenEscape(tecMatch[i]); err != nil {
<add> if err := SetEscapeToken(tecMatch[i], d); err != nil {
<ide> return "", nil, err
<ide> }
<del> directiveEscapeSeen = true
<add> d.EscapeSeen = true
<ide> return "", nil, nil
<ide> }
<ide> }
<ide> }
<ide> }
<ide>
<del> lookingForDirectives = false
<add> d.LookingForDirectives = false
<ide>
<ide> if line = stripComments(line); line == "" {
<ide> return "", nil, nil
<ide> }
<ide>
<del> if tokenLineContinuation.MatchString(line) {
<del> line = tokenLineContinuation.ReplaceAllString(line, "")
<add> if d.LineContinuationRegex.MatchString(line) {
<add> line = d.LineContinuationRegex.ReplaceAllString(line, "")
<ide> return line, nil, nil
<ide> }
<ide>
<ide> func ParseLine(line string) (string, *Node, error) {
<ide> node := &Node{}
<ide> node.Value = cmd
<ide>
<del> sexp, attrs, err := fullDispatch(cmd, args)
<add> sexp, attrs, err := fullDispatch(cmd, args, d)
<ide> if err != nil {
<ide> return "", nil, err
<ide> }
<ide> func ParseLine(line string) (string, *Node, error) {
<ide>
<ide> // Parse is the main parse routine.
<ide> // It handles an io.ReadWriteCloser and returns the root of the AST.
<del>func Parse(rwc io.Reader) (*Node, error) {
<del> directiveEscapeSeen = false
<del> lookingForDirectives = true
<del> setTokenEscape(defaultTokenEscape) // Assume the default token for escape
<add>func Parse(rwc io.Reader, d *Directive) (*Node, error) {
<ide> currentLine := 0
<ide> root := &Node{}
<ide> root.StartLine = -1
<ide> func Parse(rwc io.Reader) (*Node, error) {
<ide> }
<ide> scannedLine := strings.TrimLeftFunc(string(scannedBytes), unicode.IsSpace)
<ide> currentLine++
<del> line, child, err := ParseLine(scannedLine)
<add> line, child, err := ParseLine(scannedLine, d)
<ide> if err != nil {
<ide> return nil, err
<ide> }
<ide> func Parse(rwc io.Reader) (*Node, error) {
<ide> continue
<ide> }
<ide>
<del> line, child, err = ParseLine(line + newline)
<add> line, child, err = ParseLine(line+newline, d)
<ide> if err != nil {
<ide> return nil, err
<ide> }
<ide> func Parse(rwc io.Reader) (*Node, error) {
<ide> }
<ide> }
<ide> if child == nil && line != "" {
<del> _, child, err = ParseLine(line)
<add> _, child, err = ParseLine(line, d)
<ide> if err != nil {
<ide> return nil, err
<ide> }
<ide><path>builder/dockerfile/parser/parser_test.go
<ide> func TestTestNegative(t *testing.T) {
<ide> t.Fatalf("Dockerfile missing for %s: %v", dir, err)
<ide> }
<ide>
<del> _, err = Parse(df)
<add> d := Directive{LookingForDirectives: true}
<add> SetEscapeToken(DefaultEscapeToken, &d)
<add> _, err = Parse(df, &d)
<ide> if err == nil {
<ide> t.Fatalf("No error parsing broken dockerfile for %s", dir)
<ide> }
<ide> func TestTestData(t *testing.T) {
<ide> }
<ide> defer df.Close()
<ide>
<del> ast, err := Parse(df)
<add> d := Directive{LookingForDirectives: true}
<add> SetEscapeToken(DefaultEscapeToken, &d)
<add> ast, err := Parse(df, &d)
<ide> if err != nil {
<ide> t.Fatalf("Error parsing %s's dockerfile: %v", dir, err)
<ide> }
<ide> func TestParseWords(t *testing.T) {
<ide> }
<ide>
<ide> for _, test := range tests {
<del> words := parseWords(test["input"][0])
<add> d := Directive{LookingForDirectives: true}
<add> SetEscapeToken(DefaultEscapeToken, &d)
<add> words := parseWords(test["input"][0], &d)
<ide> if len(words) != len(test["expect"]) {
<ide> t.Fatalf("length check failed. input: %v, expect: %q, output: %q", test["input"][0], test["expect"], words)
<ide> }
<ide> func TestLineInformation(t *testing.T) {
<ide> }
<ide> defer df.Close()
<ide>
<del> ast, err := Parse(df)
<add> d := Directive{LookingForDirectives: true}
<add> SetEscapeToken(DefaultEscapeToken, &d)
<add> ast, err := Parse(df, &d)
<ide> if err != nil {
<ide> t.Fatalf("Error parsing dockerfile %s: %v", testFileLineInfo, err)
<ide> }
<ide><path>builder/dockerfile/parser/utils.go
<ide> func (node *Node) Dump() string {
<ide>
<ide> // performs the dispatch based on the two primal strings, cmd and args. Please
<ide> // look at the dispatch table in parser.go to see how these dispatchers work.
<del>func fullDispatch(cmd, args string) (*Node, map[string]bool, error) {
<add>func fullDispatch(cmd, args string, d *Directive) (*Node, map[string]bool, error) {
<ide> fn := dispatch[cmd]
<ide>
<ide> // Ignore invalid Dockerfile instructions
<ide> if fn == nil {
<ide> fn = parseIgnore
<ide> }
<ide>
<del> sexp, attrs, err := fn(args)
<add> sexp, attrs, err := fn(args, d)
<ide> if err != nil {
<ide> return nil, nil, err
<ide> } | 9 |
PHP | PHP | add tests for usage of radiocontainer | 52f16a94f484d1081a4abf0ed2a4e57d2213977c | <ide><path>Test/TestCase/View/Input/RadioTest.php
<ide> public function testRenderLabelOptions() {
<ide> * @return void
<ide> */
<ide> public function testRenderContainerTemplate() {
<del> $this->markTestIncomplete();
<add> $this->templates->add([
<add> 'radioContainer' => '<div class="radio">{{input}}{{label}}</div>'
<add> ]);
<add> $radio = new Radio($this->templates);
<add> $data = [
<add> 'name' => 'Versions[ver]',
<add> 'options' => [
<add> 1 => 'one',
<add> '1x' => 'one x',
<add> '2' => 'two',
<add> ],
<add> ];
<add> $result = $radio->render($data);
<add> $this->assertContains(
<add> '<div class="radio"><input type="radio"',
<add> $result
<add> );
<add> $this->assertContains(
<add> '</label></div>',
<add> $result
<add> );
<ide> }
<ide>
<ide> } | 1 |
Javascript | Javascript | prevent firefox marking required textareas invalid | a5df18a9e5d7cc70c30ce144dcc291e9f64cb451 | <ide><path>fixtures/dom/src/components/fixtures/textareas/index.js
<add>import Fixture from '../../Fixture';
<ide> import FixtureSet from '../../FixtureSet';
<ide> import TestCase from '../../TestCase';
<ide>
<ide> export default class TextAreaFixtures extends React.Component {
<ide> <textarea placeholder="Hello, world" />
<ide> </div>
<ide> </TestCase>
<add>
<add> <TestCase
<add> title="Required Textareas"
<add> affectedBrowsers="Firefox"
<add> relatedIssues="16402">
<add> <TestCase.Steps>
<add> <li>View this test in Firefox</li>
<add> </TestCase.Steps>
<add>
<add> <TestCase.ExpectedResult>
<add> You should{' '}
<add> <b>
<add> <i>not</i>
<add> </b>{' '}
<add> see a red aura on initial page load, indicating the textarea is
<add> invalid.
<add> <br />
<add> This aura looks roughly like:
<add> <textarea style={{boxShadow: '0 0 1px 1px red', marginLeft: 8}} />
<add> </TestCase.ExpectedResult>
<add>
<add> <Fixture>
<add> <form className="control-box">
<add> <fieldset>
<add> <legend>Empty value prop string</legend>
<add> <textarea value="" required={true} />
<add> </fieldset>
<add> <fieldset>
<add> <legend>No value prop</legend>
<add> <textarea required={true} />
<add> </fieldset>
<add> <fieldset>
<add> <legend>Empty defaultValue prop string</legend>
<add> <textarea required={true} defaultValue="" />
<add> </fieldset>
<add> </form>
<add> </Fixture>
<add> </TestCase>
<ide> </FixtureSet>
<ide> );
<ide> }
<ide><path>packages/react-dom/src/__tests__/ReactDOMTextarea-test.js
<ide> describe('ReactDOMTextarea', () => {
<ide> expect(node.value).toEqual('gorilla');
<ide> });
<ide>
<add> it('will not initially assign an empty value (covers case where firefox throws a validation error when required attribute is set)', () => {
<add> const container = document.createElement('div');
<add>
<add> let counter = 0;
<add> const originalCreateElement = document.createElement;
<add> spyOnDevAndProd(document, 'createElement').and.callFake(function(type) {
<add> const el = originalCreateElement.apply(this, arguments);
<add> let value = '';
<add> if (type === 'textarea') {
<add> Object.defineProperty(el, 'value', {
<add> get: function() {
<add> return value;
<add> },
<add> set: function(val) {
<add> value = '' + val;
<add> counter++;
<add> },
<add> });
<add> }
<add> return el;
<add> });
<add>
<add> ReactDOM.render(<textarea value="" readOnly={true} />, container);
<add>
<add> expect(counter).toEqual(0);
<add> });
<add>
<ide> it('should render defaultValue for SSR', () => {
<ide> const markup = ReactDOMServer.renderToString(<textarea defaultValue="1" />);
<ide> const div = document.createElement('div');
<ide><path>packages/react-dom/src/client/ReactDOMTextarea.js
<ide> export function postMountWrapper(element: Element, props: Object) {
<ide> // will populate textContent as well.
<ide> // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/
<ide> if (textContent === node._wrapperState.initialValue) {
<del> node.value = textContent;
<add> if (textContent !== '' && textContent !== null) {
<add> node.value = textContent;
<add> }
<ide> }
<ide> }
<ide> | 3 |
Ruby | Ruby | remove useless case in #resolve_layout | c0daa02c24ced5940ad9ab36ca81dd25614e5e41 | <ide><path>actionview/lib/action_view/renderer/template_renderer.rb
<ide> def resolve_layout(layout, keys, formats)
<ide> end
<ide> when Proc
<ide> resolve_layout(layout.call, keys, formats)
<del> when FalseClass
<del> nil
<ide> else
<ide> layout
<ide> end | 1 |
Javascript | Javascript | use arrow functions in test-exception-handler | f8af209f428bd1233d5de5f399f74daaf359cb6e | <ide><path>test/parallel/test-exception-handler.js
<ide> const assert = require('assert');
<ide>
<ide> const MESSAGE = 'catch me if you can';
<ide>
<del>process.on('uncaughtException', common.mustCall(function(e) {
<add>process.on('uncaughtException', common.mustCall((e) => {
<ide> console.log('uncaught exception! 1');
<ide> assert.strictEqual(MESSAGE, e.message);
<ide> }));
<ide>
<del>process.on('uncaughtException', common.mustCall(function(e) {
<add>process.on('uncaughtException', common.mustCall((e) => {
<ide> console.log('uncaught exception! 2');
<ide> assert.strictEqual(MESSAGE, e.message);
<ide> }));
<ide>
<del>setTimeout(function() {
<add>setTimeout(() => {
<ide> throw new Error(MESSAGE);
<ide> }, 10); | 1 |
Javascript | Javascript | make relative ref to sys in fs module | 6d9227b79a65c1d5df8e0ffb86c8a7fb1efe7884 | <ide><path>lib/fs.js
<del>var
<del> sys = require('sys'),
<del> events = require('events'),
<del> fs = require('fs');
<add>var sys = require('./sys'),
<add> events = require('events');
<ide>
<ide> exports.Stats = process.Stats;
<ide>
<ide> var FileWriteStream = exports.FileWriteStream = function(path, options) {
<ide>
<ide> flush();
<ide> };
<del>sys.inherits(FileWriteStream, events.EventEmitter);
<ide>\ No newline at end of file
<add>sys.inherits(FileWriteStream, events.EventEmitter); | 1 |
Javascript | Javascript | make dommanager stateless for performance | caa4c9cd21b43c6f2f827e307f5486785d9b0174 | <ide><path>packages/ember-handlebars/lib/views/metamorph_view.js
<ide> require("ember-views/views/view");
<ide>
<ide> var set = Ember.set, get = Ember.get, getPath = Ember.getPath;
<ide>
<add>var DOMManager = {
<add> remove: function(view) {
<add> var morph = view.morph;
<add> if (morph.isRemoved()) { return; }
<add> morph.remove();
<add> },
<add>
<add> prepend: function(view, childView) {
<add> childView._insertElementLater(function() {
<add> var morph = view.morph;
<add> morph.prepend(childView.outerHTML);
<add> childView.outerHTML = null;
<add> });
<add> },
<add>
<add> after: function(view, nextView) {
<add> nextView._insertElementLater(function() {
<add> var morph = view.morph;
<add> morph.after(nextView.outerHTML);
<add> nextView,outerHTML = null;
<add> });
<add> },
<add>
<add> replace: function(view) {
<add> var morph = view.morph;
<add>
<add> view.transitionTo('preRender');
<add> view.clearRenderedChildren();
<add> var buffer = view.renderToBuffer();
<add>
<add> Ember.run.schedule('render', this, function() {
<add> if (get(view, 'isDestroyed')) { return; }
<add> view.invalidateRecursively('element');
<add> view._notifyWillInsertElement();
<add> morph.replaceWith(buffer.string());
<add> view.transitionTo('inDOM');
<add> view._notifyDidInsertElement();
<add> });
<add> }
<add>};
<add>
<add>// The `morph` and `outerHTML` properties are internal only
<add>// and not observable.
<add>
<ide> Ember.Metamorph = Ember.Mixin.create({
<ide> isVirtual: true,
<ide> tagName: '',
<ide>
<ide> init: function() {
<ide> this._super();
<del> set(this, 'morph', Metamorph());
<add> this.morph = Metamorph();
<ide> },
<ide>
<ide> beforeRender: function(buffer) {
<del> var morph = get(this, 'morph');
<del> buffer.push(morph.startTag());
<add> buffer.push(this.morph.startTag());
<ide> },
<ide>
<ide> afterRender: function(buffer) {
<del> var morph = get(this, 'morph');
<del> buffer.push(morph.endTag());
<add> buffer.push(this.morph.endTag());
<ide> },
<ide>
<ide> createElement: function() {
<ide> var buffer = this.renderToBuffer();
<del> set(this, 'outerHTML', buffer.string());
<add> this.outerHTML = buffer.string();
<ide> this.clearBuffer();
<ide> },
<ide>
<del> domManagerClass: Ember.Object.extend({
<del> remove: function(view) {
<del> var morph = getPath(this, 'view.morph');
<del> if (morph.isRemoved()) { return; }
<del> getPath(this, 'view.morph').remove();
<del> },
<del>
<del> prepend: function(childView) {
<del> var view = get(this, 'view');
<del>
<del> childView._insertElementLater(function() {
<del> var morph = get(view, 'morph');
<del> morph.prepend(get(childView, 'outerHTML'));
<del> childView.set('outerHTML', null);
<del> });
<del> },
<del>
<del> after: function(nextView) {
<del> var view = get(this, 'view');
<del>
<del> nextView._insertElementLater(function() {
<del> var morph = get(view, 'morph');
<del> morph.after(get(nextView, 'outerHTML'));
<del> nextView.set('outerHTML', null);
<del> });
<del> },
<del>
<del> replace: function() {
<del> var view = get(this, 'view');
<del> var morph = getPath(this, 'view.morph');
<del>
<del> view.transitionTo('preRender');
<del> view.clearRenderedChildren();
<del> var buffer = view.renderToBuffer();
<del>
<del> Ember.run.schedule('render', this, function() {
<del> if (get(view, 'isDestroyed')) { return; }
<del> view.invalidateRecursively('element');
<del> view._notifyWillInsertElement();
<del> morph.replaceWith(buffer.string());
<del> view.transitionTo('inDOM');
<del> view._notifyDidInsertElement();
<del> });
<del> }
<del> })
<add> domManager: DOMManager
<ide> });
<ide>
<ide><path>packages/ember-views/lib/views/container_view.js
<ide> Ember.ContainerView = Ember.View.extend({
<ide> */
<ide> _scheduleInsertion: function(view, prev) {
<ide> if (prev) {
<del> prev.get('domManager').after(view);
<add> prev.domManager.after(prev, view);
<ide> } else {
<del> this.get('domManager').prepend(view);
<add> this.domManager.prepend(this, view);
<ide> }
<ide> }
<ide> });
<ide><path>packages/ember-views/lib/views/states/in_dom.js
<ide> Ember.View.states.hasElement = {
<ide>
<ide> view.clearRenderedChildren();
<ide>
<del> get(view, 'domManager').replace();
<add> view.domManager.replace(view);
<ide> return view;
<ide> },
<ide>
<ide> Ember.View.states.hasElement = {
<ide> destroyElement: function(view) {
<ide> view._notifyWillDestroyElement();
<ide>
<del> get(view, 'domManager').remove();
<add> view.domManager.remove(view);
<ide> return view;
<ide> },
<ide>
<ide><path>packages/ember-views/lib/views/view.js
<ide> Ember.View = Ember.Object.extend(Ember.Evented,
<ide> */
<ide> attributeBindings: [],
<ide>
<add> state: 'preRender',
<add>
<ide> // .......................................................
<ide> // CORE DISPLAY METHODS
<ide> //
<ide> Ember.View = Ember.Object.extend(Ember.Evented,
<ide> dispatch
<ide> */
<ide> init: function() {
<del> set(this, 'state', 'preRender');
<del>
<ide> var parentView = get(this, '_parentView');
<ide>
<ide> this._super();
<ide> Ember.View = Ember.Object.extend(Ember.Evented,
<ide> Ember.View.views[get(this, 'elementId')] = this;
<ide>
<ide> var childViews = Ember.A(get(this, '_childViews').slice());
<add>
<ide> // setup child views. be sure to clone the child views array first
<ide> set(this, '_childViews', childViews);
<ide>
<del>
<ide> ember_assert("Only arrays are allowed for 'classNameBindings'", Ember.typeOf(this.classNameBindings) === 'array');
<ide> this.classNameBindings = Ember.A(this.classNameBindings.slice());
<ide>
<ide> ember_assert("Only arrays are allowed for 'classNames'", Ember.typeOf(this.classNames) === 'array');
<ide> this.classNames = Ember.A(this.classNames.slice());
<ide>
<del> set(this, 'domManager', this.domManagerClass.create({ view: this }));
<del>
<ide> var viewController = get(this, 'viewController');
<ide> if (viewController) {
<ide> viewController = Ember.getPath(viewController);
<ide> Ember.View = Ember.Object.extend(Ember.Evented,
<ide> // once the view has been inserted into the DOM, legal manipulations
<ide> // are done on the DOM element.
<ide>
<del>Ember.View.reopen({
<del> states: Ember.View.states,
<del> domManagerClass: Ember.Object.extend({
<del> view: this,
<del>
<del> prepend: function(childView) {
<del> var view = get(this, 'view');
<del>
<del> childView._insertElementLater(function() {
<del> var element = view.$();
<del> element.prepend(childView.$());
<del> });
<del> },
<add>DOMManager = {
<add> prepend: function(view, childView) {
<add> childView._insertElementLater(function() {
<add> var element = view.$();
<add> element.prepend(childView.$());
<add> });
<add> },
<ide>
<del> after: function(nextView) {
<del> var view = get(this, 'view');
<add> after: function(view, nextView) {
<add> nextView._insertElementLater(function() {
<add> var element = view.$();
<add> element.after(nextView.$());
<add> });
<add> },
<ide>
<del> nextView._insertElementLater(function() {
<del> var element = view.$();
<del> element.after(nextView.$());
<del> });
<del> },
<add> replace: function(view) {
<add> var element = get(view, 'element');
<ide>
<del> replace: function() {
<del> var view = get(this, 'view');
<del> var element = get(view, 'element');
<add> set(view, 'element', null);
<ide>
<del> set(view, 'element', null);
<add> view._insertElementLater(function() {
<add> Ember.$(element).replaceWith(get(view, 'element'));
<add> });
<add> },
<ide>
<del> view._insertElementLater(function() {
<del> Ember.$(element).replaceWith(get(view, 'element'));
<del> });
<del> },
<add> remove: function(view) {
<add> var elem = get(view, 'element');
<ide>
<del> remove: function() {
<del> var view = get(this, 'view');
<del> var elem = get(view, 'element');
<add> set(view, 'element', null);
<ide>
<del> set(view, 'element', null);
<add> Ember.$(elem).remove();
<add> }
<add>};
<ide>
<del> Ember.$(elem).remove();
<del> }
<del> })
<add>Ember.View.reopen({
<add> states: Ember.View.states,
<add> domManager: DOMManager
<ide> });
<ide>
<ide> // Create a global view hash. | 4 |
Javascript | Javascript | use es6 import for drawerlayoutandroid | d1f217e829cb3f6de312557212feb9c9aa5e7711 | <ide><path>Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js
<ide>
<ide> 'use strict';
<ide>
<del>const Platform = require('../../Utilities/Platform');
<del>const React = require('react');
<del>const StatusBar = require('../StatusBar/StatusBar');
<del>const StyleSheet = require('../../StyleSheet/StyleSheet');
<del>const View = require('../View/View');
<del>
<del>const dismissKeyboard = require('../../Utilities/dismissKeyboard');
<del>const nullthrows = require('nullthrows');
<add>import Platform from '../../Utilities/Platform';
<add>import * as React from 'react';
<add>import StatusBar from '../StatusBar/StatusBar';
<add>import StyleSheet from '../../StyleSheet/StyleSheet';
<add>import View from '../View/View';
<add>
<add>import dismissKeyboard from '../../Utilities/dismissKeyboard';
<add>import nullthrows from 'nullthrows';
<ide>
<ide> import AndroidDrawerLayoutNativeComponent, {
<ide> Commands, | 1 |
Javascript | Javascript | add meteor/package.js to bump version script | f32e2e5896a1c3601e695151111078cd92bd2693 | <ide><path>tasks/bump_version.js
<ide> module.exports = function (grunt) {
<ide> }
<ide> });
<ide>
<add> grunt.config('string-replace.meteor-package-js', {
<add> files: {'meteor/package.js': 'meteor/package.js'},
<add> options: {
<add> replacements: [
<add> {
<add> pattern: /version: .*/,
<add> replacement: 'version: \'' + version + '\','
<add> }
<add> ]
<add> }
<add> });
<add>
<ide> grunt.task.run([
<ide> 'string-replace:moment-js',
<ide> 'string-replace:package-json',
<ide> 'string-replace:component-json',
<del> 'string-replace:moment-js-nuspec'
<add> 'string-replace:moment-js-nuspec',
<add> 'string-replace:meteor-package-js'
<ide> ]);
<ide> });
<ide> }; | 1 |
Javascript | Javascript | kill navigationexperimental containers | 14eb427a8061e0c904ace022535070150c6872d4 | <ide><path>Examples/UIExplorer/NavigationExperimental/NavigationAnimatedExample.js
<ide> const {
<ide> Card: NavigationCard,
<ide> Header: NavigationHeader,
<ide> Reducer: NavigationReducer,
<del> RootContainer: NavigationRootContainer,
<ide> } = NavigationExperimental;
<ide>
<del>const NavigationBasicReducer = NavigationReducer.StackReducer({
<add>const ExampleReducer = NavigationReducer.StackReducer({
<ide> getPushedReducerForAction: (action) => {
<ide> if (action.type === 'push') {
<ide> return (state) => state || {key: action.key};
<ide> const NavigationBasicReducer = NavigationReducer.StackReducer({
<ide> });
<ide>
<ide> class NavigationAnimatedExample extends React.Component {
<add> constructor(props, context) {
<add> super(props, context);
<add> this.state = ExampleReducer();
<add> }
<add>
<ide> componentWillMount() {
<ide> this._renderCard = this._renderCard.bind(this);
<ide> this._renderHeader = this._renderHeader.bind(this);
<del> this._renderNavigation = this._renderNavigation.bind(this);
<ide> this._renderScene = this._renderScene.bind(this);
<ide> this._renderTitleComponent = this._renderTitleComponent.bind(this);
<add> this._handleAction = this._handleAction.bind(this);
<ide> }
<del> render() {
<del> return (
<del> <NavigationRootContainer
<del> reducer={NavigationBasicReducer}
<del> ref={navRootContainer => { this.navRootContainer = navRootContainer; }}
<del> persistenceKey="NavigationAnimExampleState"
<del> renderNavigation={this._renderNavigation}
<del> />
<del> );
<add>
<add> _handleAction(action): boolean {
<add> if (!action) {
<add> return false;
<add> }
<add> const newState = ExampleReducer(this.state, action);
<add> if (newState === this.state) {
<add> return false;
<add> }
<add> this.setState(newState);
<add> return true;
<ide> }
<del> handleBackAction() {
<del> return (
<del> this.navRootContainer &&
<del> this.navRootContainer.handleNavigation(NavigationRootContainer.getBackAction())
<del> );
<add>
<add> handleBackAction(): boolean {
<add> return this._handleAction({ type: 'BackAction', });
<ide> }
<del> _renderNavigation(navigationState, onNavigate) {
<del> if (!navigationState) {
<del> return null;
<del> }
<add>
<add> render() {
<ide> return (
<ide> <NavigationAnimatedView
<del> navigationState={navigationState}
<add> navigationState={this.state}
<ide> style={styles.animatedView}
<add> onNavigate={this._handleAction}
<ide> renderOverlay={this._renderHeader}
<ide> applyAnimation={(pos, navState) => {
<ide> Animated.timing(pos, {toValue: navState.index, duration: 500}).start();
<ide><path>Examples/UIExplorer/NavigationExperimental/NavigationBasicExample.js
<ide> /**
<add> * Copyright (c) 2013-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> *
<ide> * The examples provided by Facebook are for non-commercial testing and
<ide> * evaluation purposes only.
<ide> *
<ide> const {
<ide> } = ReactNative;
<ide> const NavigationExampleRow = require('./NavigationExampleRow');
<ide> const {
<del> RootContainer: NavigationRootContainer,
<ide> Reducer: NavigationReducer,
<ide> } = NavigationExperimental;
<del>const StackReducer = NavigationReducer.StackReducer;
<ide>
<del>const NavigationBasicReducer = NavigationReducer.StackReducer({
<add>const ExampleReducer = NavigationReducer.StackReducer({
<ide> getPushedReducerForAction: (action) => {
<ide> if (action.type === 'push') {
<ide> return (state) => state || {key: action.key};
<ide> const NavigationBasicReducer = NavigationReducer.StackReducer({
<ide> });
<ide>
<ide> const NavigationBasicExample = React.createClass({
<add>
<add> getInitialState: function() {
<add> return ExampleReducer();
<add> },
<add>
<ide> render: function() {
<ide> return (
<del> <NavigationRootContainer
<del> reducer={NavigationBasicReducer}
<del> persistenceKey="NavigationBasicExampleState"
<del> ref={navRootContainer => { this.navRootContainer = navRootContainer; }}
<del> renderNavigation={(navState, onNavigate) => {
<del> if (!navState) { return null; }
<del> return (
<del> <ScrollView style={styles.topView}>
<del> <NavigationExampleRow
<del> text={`Current page: ${navState.children[navState.index].key}`}
<del> />
<del> <NavigationExampleRow
<del> text={`Push page #${navState.children.length}`}
<del> onPress={() => {
<del> onNavigate({ type: 'push', key: 'page #' + navState.children.length });
<del> }}
<del> />
<del> <NavigationExampleRow
<del> text="pop"
<del> onPress={() => {
<del> onNavigate(NavigationRootContainer.getBackAction());
<del> }}
<del> />
<del> <NavigationExampleRow
<del> text="Exit Basic Nav Example"
<del> onPress={this.props.onExampleExit}
<del> />
<del> </ScrollView>
<del> );
<del> }}
<del> />
<add> <ScrollView style={styles.topView}>
<add> <NavigationExampleRow
<add> text={`Current page: ${this.state.children[this.state.index].key}`}
<add> />
<add> <NavigationExampleRow
<add> text={`Push page #${this.state.children.length}`}
<add> onPress={() => {
<add> this._handleAction({ type: 'push', key: 'page #' + this.state.children.length });
<add> }}
<add> />
<add> <NavigationExampleRow
<add> text="pop"
<add> onPress={() => {
<add> this._handleAction({ type: 'BackAction' });
<add> }}
<add> />
<add> <NavigationExampleRow
<add> text="Exit Basic Nav Example"
<add> onPress={this.props.onExampleExit}
<add> />
<add> </ScrollView>
<ide> );
<ide> },
<ide>
<del> handleBackAction: function() {
<del> return (
<del> this.navRootContainer &&
<del> this.navRootContainer.handleNavigation(NavigationRootContainer.getBackAction())
<del> );
<add> _handleAction(action) {
<add> if (!action) {
<add> return false;
<add> }
<add> const newState = ExampleReducer(this.state, action);
<add> if (newState === this.state) {
<add> return false;
<add> }
<add> this.setState(newState);
<add> return true;
<add> },
<add>
<add> handleBackAction() {
<add> return this._handleAction({ type: 'BackAction' });
<ide> },
<ide>
<ide> });
<ide><path>Examples/UIExplorer/NavigationExperimental/NavigationCardStackExample.js
<ide> const {
<ide> const {
<ide> CardStack: NavigationCardStack,
<ide> StateUtils: NavigationStateUtils,
<del> RootContainer: NavigationRootContainer,
<ide> } = NavigationExperimental;
<ide>
<ide> function createReducer(initialState) {
<del> return (currentState, action) => {
<add> return (currentState = initialState, action) => {
<ide> switch (action.type) {
<del> case 'RootContainerInitialAction':
<del> return initialState;
<del>
<ide> case 'push':
<ide> return NavigationStateUtils.push(currentState, {key: action.key});
<ide>
<add> case 'BackAction':
<ide> case 'back':
<ide> case 'pop':
<ide> return currentState.index > 0 ?
<ide> class NavigationCardStackExample extends React.Component {
<ide>
<ide> constructor(props, context) {
<ide> super(props, context);
<del> this.state = {isHorizontal: true};
<add> this.state = {
<add> isHorizontal: true,
<add> navState: ExampleReducer(undefined, {}),
<add> };
<ide> }
<ide>
<ide> componentWillMount() {
<del> this._renderNavigation = this._renderNavigation.bind(this);
<ide> this._renderScene = this._renderScene.bind(this);
<ide> this._toggleDirection = this._toggleDirection.bind(this);
<add> this._handleAction = this._handleAction.bind(this);
<ide> }
<ide>
<ide> render() {
<del> return (
<del> <NavigationRootContainer
<del> reducer={ExampleReducer}
<del> renderNavigation={this._renderNavigation}
<del> style={styles.main}
<del> />
<del> );
<del> }
<del>
<del> _renderNavigation(navigationState, onNavigate) {
<ide> return (
<ide> <NavigationCardStack
<ide> direction={this.state.isHorizontal ? 'horizontal' : 'vertical'}
<del> navigationState={navigationState}
<del> onNavigate={onNavigate}
<add> navigationState={this.state.navState}
<add> onNavigate={this._handleAction}
<ide> renderScene={this._renderScene}
<ide> style={styles.main}
<ide> />
<ide> );
<ide> }
<ide>
<add> _handleAction(action): boolean {
<add> if (!action) {
<add> return false;
<add> }
<add> const newState = ExampleReducer(this.state.navState, action);
<add> if (newState === this.state.navState) {
<add> return false;
<add> }
<add> this.setState({
<add> navState: newState,
<add> });
<add> return true;
<add> }
<add>
<add> handleBackAction(): boolean {
<add> return this._handleAction({ type: 'BackAction', });
<add> }
<add>
<ide> _renderScene(/*NavigationSceneRendererProps*/ props) {
<ide> return (
<ide> <ScrollView style={styles.scrollView}>
<ide><path>Examples/UIExplorer/NavigationExperimental/NavigationCompositionExample.js
<ide> const {
<ide>
<ide> const {
<ide> CardStack: NavigationCardStack,
<del> Container: NavigationContainer,
<ide> Header: NavigationHeader,
<ide> Reducer: NavigationReducer,
<del> RootContainer: NavigationRootContainer,
<ide> View: NavigationView,
<ide> } = NavigationExperimental;
<ide>
<ide> class ExampleTabScreen extends React.Component {
<ide> <NavigationCardStack
<ide> style={styles.tabContent}
<ide> navigationState={this.props.navigationState}
<add> onNavigate={this.props.onNavigate}
<ide> renderOverlay={this._renderHeader}
<ide> renderScene={this._renderScene}
<ide> />
<ide> class ExampleTabScreen extends React.Component {
<ide> );
<ide> }
<ide> }
<del>ExampleTabScreen = NavigationContainer.create(ExampleTabScreen);
<ide>
<ide> class NavigationCompositionExample extends React.Component {
<del> navRootContainer: NavigationRootContainer;
<del>
<del> render() {
<del> return (
<del> <NavigationRootContainer
<del> reducer={ExampleAppReducer}
<del> persistenceKey="NavigationCompositionState"
<del> ref={navRootContainer => { this.navRootContainer = navRootContainer; }}
<del> renderNavigation={this.renderApp.bind(this)}
<del> />
<del> );
<add> state: NavigationParentState;
<add> constructor() {
<add> super();
<add> this.state = ExampleAppReducer(undefined, {});
<add> }
<add> handleAction(action: Object): boolean {
<add> if (!action) {
<add> return false;
<add> }
<add> const newState = ExampleAppReducer(this.state, action);
<add> if (newState === this.state) {
<add> return false;
<add> }
<add> this.setState(newState);
<add> return true;
<ide> }
<ide> handleBackAction(): boolean {
<del> return (
<del> this.navRootContainer &&
<del> this.navRootContainer.handleNavigation(NavigationRootContainer.getBackAction())
<del> );
<add> return this.handleAction({ type: 'BackAction' });
<ide> }
<del> renderApp(navigationState: NavigationParentState, onNavigate: Function) {
<del> if (!navigationState) {
<add> render() {
<add> if (!this.state) {
<ide> return null;
<ide> }
<ide> return (
<ide> <View style={styles.topView}>
<ide> <ExampleMainView
<del> navigationState={navigationState}
<add> navigationState={this.state}
<ide> onExampleExit={this.props.onExampleExit}
<add> onNavigate={this.handleAction.bind(this)}
<ide> />
<ide> <NavigationExampleTabBar
<del> tabs={navigationState.children}
<del> index={navigationState.index}
<add> tabs={this.state.children}
<add> index={this.state.index}
<add> onNavigate={this.handleAction.bind(this)}
<ide> />
<ide> </View>
<ide> );
<ide> class NavigationCompositionExample extends React.Component {
<ide>
<ide> class ExampleMainView extends React.Component {
<ide> _renderScene: NavigationSceneRenderer;
<add> _handleNavigation: Function;
<ide>
<ide> componentWillMount() {
<ide> this._renderScene = this._renderScene.bind(this);
<add> this._handleNavigation = this._handleNavigation.bind(this);
<ide> }
<ide>
<ide> render() {
<ide> return (
<ide> <NavigationView
<ide> navigationState={this.props.navigationState}
<add> onNavigate={this._handleNavigation}
<ide> style={styles.tabsContent}
<ide> renderScene={this._renderScene}
<ide> />
<ide> class ExampleMainView extends React.Component {
<ide> <ExampleTabScreen
<ide> key={'tab_screen' + scene.key}
<ide> navigationState={scene.navigationState}
<del> onNavigate={this._handleNavigation.bind(this, scene.key)}
<add> onNavigate={this._handleNavigation}
<ide> />
<ide> );
<ide> }
<ide>
<del> _handleNavigation(tabKey, action) {
<add> _handleNavigation(action: Object) {
<ide> if (ExampleExitAction.match(action)) {
<ide> this.props.onExampleExit();
<ide> return;
<ide> class ExampleMainView extends React.Component {
<ide> }
<ide> }
<ide>
<del>ExampleMainView = NavigationContainer.create(ExampleMainView);
<del>
<ide> const styles = StyleSheet.create({
<ide> topView: {
<ide> flex: 1,
<ide><path>Examples/UIExplorer/NavigationExperimental/NavigationExampleTabBar.js
<ide> /**
<add> * Copyright (c) 2013-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> *
<ide> * The examples provided by Facebook are for non-commercial testing and
<ide> * evaluation purposes only.
<ide> *
<ide> */
<ide> 'use strict';
<ide>
<del>var React = require('react');
<del>var ReactNative = require('react-native');
<del>var {
<del> NavigationExperimental,
<del> StyleSheet,
<del> Text,
<del> TouchableOpacity,
<del> View,
<del>} = ReactNative;
<add>const NavigationExperimental = require('NavigationExperimental');
<add>const React = require('react');
<add>const StyleSheet = require('StyleSheet');
<add>const Text = require('Text');
<add>const TouchableOpacity = require('TouchableOpacity');
<add>const View = require('View');
<ide> const {
<del> Container: NavigationContainer,
<ide> Reducer: NavigationReducer,
<ide> } = NavigationExperimental;
<ide> const {
<ide> JumpToAction,
<ide> } = NavigationReducer.TabsReducer;
<ide>
<del>var NavigationExampleTabBar = React.createClass({
<add>const NavigationExampleTabBar = React.createClass({
<ide> render: function() {
<ide> return (
<ide> <View style={styles.tabBar}>
<ide> var NavigationExampleTabBar = React.createClass({
<ide> );
<ide> },
<ide> _renderTab: function(tab, index) {
<del> var textStyle = [styles.tabButtonText];
<add> const textStyle = [styles.tabButtonText];
<ide> if (this.props.index === index) {
<ide> textStyle.push(styles.selectedTabButtonText);
<ide> }
<ide> var NavigationExampleTabBar = React.createClass({
<ide> },
<ide> });
<ide>
<del>NavigationExampleTabBar = NavigationContainer.create(NavigationExampleTabBar);
<del>
<ide> const styles = StyleSheet.create({
<ide> tabBar: {
<ide> height: 50,
<ide><path>Examples/UIExplorer/NavigationExperimental/NavigationExperimentalExample.js
<ide> /**
<add> * Copyright (c) 2013-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> *
<ide> * The examples provided by Facebook are for non-commercial testing and
<ide> * evaluation purposes only.
<ide> *
<ide> */
<ide> 'use strict';
<ide>
<del>var React = require('react');
<del>var ReactNative = require('react-native');
<del>var {
<del> AsyncStorage,
<del> ScrollView,
<del> StyleSheet,
<del> View,
<del>} = ReactNative;
<del>var NavigationExampleRow = require('./NavigationExampleRow');
<add>const AsyncStorage = require('AsyncStorage');
<add>const NavigationExampleRow = require('./NavigationExampleRow');
<add>const React = require('react');
<add>const ScrollView = require('ScrollView');
<add>const StyleSheet = require('StyleSheet');
<add>const View = require('View');
<ide>
<ide> /*
<ide> * Heads up! This file is not the real navigation example- only a utility to switch between them.
<ide> *
<ide> * To learn how to use the Navigation API, take a look at the following example files:
<ide> */
<del>var EXAMPLES = {
<add>const EXAMPLES = {
<ide> 'Tabs': require('./NavigationTabsExample'),
<ide> 'Basic': require('./NavigationBasicExample'),
<ide> 'Animated Example': require('./NavigationAnimatedExample'),
<ide> var EXAMPLES = {
<ide> 'Tic Tac Toe': require('./NavigationTicTacToeExample'),
<ide> };
<ide>
<del>var EXAMPLE_STORAGE_KEY = 'NavigationExperimentalExample';
<add>const EXAMPLE_STORAGE_KEY = 'NavigationExperimentalExample';
<ide>
<del>var NavigationExperimentalExample = React.createClass({
<add>const NavigationExperimentalExample = React.createClass({
<ide> statics: {
<ide> title: 'Navigation (Experimental)',
<ide> description: 'Upcoming navigation APIs and animated navigation views',
<ide> var NavigationExperimentalExample = React.createClass({
<ide> },
<ide>
<ide> _renderMenu: function() {
<del> var exitRow = null;
<add> let exitRow = null;
<ide> if (this.props.onExampleExit) {
<ide> exitRow = (
<ide> <NavigationExampleRow
<ide> var NavigationExperimentalExample = React.createClass({
<ide> return this._renderMenu();
<ide> }
<ide> if (EXAMPLES[this.state.example]) {
<del> var Component = EXAMPLES[this.state.example];
<add> const Component = EXAMPLES[this.state.example];
<ide> return (
<ide> <Component
<ide> onExampleExit={this._exitInnerExample}
<ide><path>Examples/UIExplorer/NavigationExperimental/NavigationTabsExample.js
<ide> /**
<add> * Copyright (c) 2013-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> *
<ide> * The examples provided by Facebook are for non-commercial testing and
<ide> * evaluation purposes only.
<ide> *
<ide> const {
<ide> View,
<ide> } = ReactNative;
<ide> const {
<del> Container: NavigationContainer,
<del> RootContainer: NavigationRootContainer,
<ide> Reducer: NavigationReducer,
<ide> } = NavigationExperimental;
<ide>
<ide> class ExmpleTabPage extends React.Component {
<ide> );
<ide> }
<ide> }
<del>ExmpleTabPage = NavigationContainer.create(ExmpleTabPage);
<ide>
<ide> const ExampleTabsReducer = NavigationReducer.TabsReducer({
<ide> tabReducers: [
<ide> const ExampleTabsReducer = NavigationReducer.TabsReducer({
<ide> });
<ide>
<ide> class NavigationTabsExample extends React.Component {
<add> constructor() {
<add> super();
<add> this.state = ExampleTabsReducer(undefined, {});
<add> }
<ide> render() {
<ide> return (
<del> <NavigationRootContainer
<del> reducer={ExampleTabsReducer}
<del> persistenceKey="NAV_EXAMPLE_STATE_TABS"
<del> ref={navRootContainer => { this.navRootContainer = navRootContainer; }}
<del> renderNavigation={(navigationState) => {
<del> if (!navigationState) { return null; }
<del> return (
<del> <View style={styles.topView}>
<del> <ExmpleTabPage
<del> tabs={navigationState.children}
<del> index={navigationState.index}
<del> onExampleExit={this.props.onExampleExit}
<del> />
<del> <NavigationExampleTabBar
<del> tabs={navigationState.children}
<del> index={navigationState.index}
<del> />
<del> </View>
<del> );
<del> }}
<del> />
<add> <View style={styles.topView}>
<add> <ExmpleTabPage
<add> tabs={this.state.children}
<add> index={this.state.index}
<add> onExampleExit={this.props.onExampleExit}
<add> onNavigate={this.handleAction.bind(this)}
<add> />
<add> <NavigationExampleTabBar
<add> tabs={this.state.children}
<add> index={this.state.index}
<add> onNavigate={this.handleAction.bind(this)}
<add> />
<add> </View>
<ide> );
<ide> }
<add> handleAction(action) {
<add> if (!action) {
<add> return false;
<add> }
<add> const newState = ExampleTabsReducer(this.state, action);
<add> if (newState === this.state) {
<add> return false;
<add> }
<add> this.setState(newState);
<add> return true;
<add> }
<ide> handleBackAction() {
<del> return (
<del> this.navRootContainer &&
<del> this.navRootContainer.handleNavigation(NavigationRootContainer.getBackAction())
<del> );
<add> return this.handleAction({ type: 'BackAction' });
<ide> }
<ide> }
<ide>
<ide><path>Examples/UIExplorer/NavigationExperimental/NavigationTicTacToeExample.js
<ide> /**
<add> * Copyright (c) 2013-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> *
<ide> * The examples provided by Facebook are for non-commercial testing and
<ide> * evaluation purposes only.
<ide> *
<ide> */
<ide> 'use strict';
<ide>
<del>var React = require('react');
<del>var ReactNative = require('react-native');
<del>var {
<del> NavigationExperimental,
<del> StyleSheet,
<del> Text,
<del> TouchableHighlight,
<del> View,
<del>} = ReactNative;
<del>const {
<del> Container: NavigationContainer,
<del> RootContainer: NavigationRootContainer,
<del>} = NavigationExperimental;
<add>const React = require('react');
<add>const StyleSheet = require('StyleSheet');
<add>const Text = require('Text');
<add>const TouchableHighlight = require('TouchableHighlight');
<add>const View = require('View');
<ide>
<ide> type GameGrid = Array<Array<?string>>;
<ide>
<ide> function parseGame(game: string): GameGrid {
<ide> for (let i = 0; i < 3; i++) {
<ide> const row = Array(3);
<ide> for (let j = 0; j < 3; j++) {
<del> const turnIndex = gameTurns.indexOf(rowLetterMap[i]+j);
<add> const turnIndex = gameTurns.indexOf(rowLetterMap[i] + j);
<ide> if (turnIndex === -1) {
<ide> row[j] = null;
<ide> } else {
<ide> function playTurn(game: string, row: number, col: number): string {
<ide>
<ide> function getWinner(gameString: string): ?string {
<ide> const game = parseGame(gameString);
<del> for (var i = 0; i < 3; i++) {
<add> for (let i = 0; i < 3; i++) {
<ide> if (game[i][0] !== null && game[i][0] === game[i][1] &&
<ide> game[i][0] === game[i][2]) {
<ide> return game[i][0];
<ide> }
<ide> }
<del> for (var i = 0; i < 3; i++) {
<add> for (let i = 0; i < 3; i++) {
<ide> if (game[0][i] !== null && game[0][i] === game[1][i] &&
<ide> game[0][i] === game[2][i]) {
<ide> return game[0][i];
<ide> function isGameOver(gameString: string): boolean {
<ide> return true;
<ide> }
<ide> const game = parseGame(gameString);
<del> for (var i = 0; i < 3; i++) {
<del> for (var j = 0; j < 3; j++) {
<add> for (let i = 0; i < 3; i++) {
<add> for (let j = 0; j < 3; j++) {
<ide> if (game[i][j] === null) {
<ide> return false;
<ide> }
<ide> function GameEndOverlay(props) {
<ide> </View>
<ide> );
<ide> }
<del>GameEndOverlay = NavigationContainer.create(GameEndOverlay);
<ide>
<ide> function TicTacToeGame(props) {
<del> var rows = parseGame(props.game).map((cells, row) =>
<add> const rows = parseGame(props.game).map((cells, row) =>
<ide> <View key={'row' + row} style={styles.row}>
<ide> {cells.map((player, col) =>
<ide> <Cell
<ide> function TicTacToeGame(props) {
<ide> </View>
<ide> <GameEndOverlay
<ide> game={props.game}
<add> onNavigate={props.onNavigate}
<ide> />
<ide> </View>
<ide> );
<ide> }
<del>TicTacToeGame = NavigationContainer.create(TicTacToeGame);
<ide>
<ide> const GameActions = {
<ide> Turn: (row, col) => ({type: 'TicTacToeTurnAction', row, col }),
<ide> function GameReducer(lastGame: ?string, action: Object): string {
<ide> return lastGame;
<ide> }
<ide>
<add>type AppState = {
<add> game: string,
<add>};
<add>
<ide> class NavigationTicTacToeExample extends React.Component {
<del> static GameView = TicTacToeGame;
<del> static GameReducer = GameReducer;
<del> static GameActions = GameActions;
<add> _handleAction: Function;
<add> state: AppState;
<add> constructor() {
<add> super();
<add> this._handleAction = this._handleAction.bind(this);
<add> this.state = {
<add> game: ''
<add> };
<add> }
<add> _handleAction(action: Object) {
<add> const newState = GameReducer(this.state.game, action);
<add> if (newState !== this.state.game) {
<add> this.setState({
<add> game: newState,
<add> });
<add> }
<add> }
<ide> render() {
<ide> return (
<del> <NavigationRootContainer
<del> reducer={GameReducer}
<del> persistenceKey="TicTacToeGameState"
<del> renderNavigation={(game) => (
<del> <TicTacToeGame
<del> game={game}
<del> onExampleExit={this.props.onExampleExit}
<del> />
<del> )}
<add> <TicTacToeGame
<add> game={this.state && this.state.game}
<add> onExampleExit={this.props.onExampleExit}
<add> onNavigate={this._handleAction}
<ide> />
<ide> );
<ide> }
<ide><path>Examples/UIExplorer/UIExplorerActions.js
<ide> /**
<add> * Copyright (c) 2013-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> *
<ide> * The examples provided by Facebook are for non-commercial testing and
<ide> * evaluation purposes only.
<ide> *
<ide> export type UIExplorerExampleAction = {
<ide> openExample: string;
<ide> };
<ide>
<del>import type {BackAction} from 'NavigationRootContainer';
<del>
<del>export type UIExplorerAction = BackAction | UIExplorerListWithFilterAction | UIExplorerExampleAction;
<add>export type UIExplorerAction = UIExplorerListWithFilterAction | UIExplorerExampleAction;
<ide>
<ide> function ExampleListWithFilter(filter: ?string): UIExplorerListWithFilterAction {
<ide> return {
<ide><path>Examples/UIExplorer/UIExplorerApp.android.js
<ide> /**
<add> * Copyright (c) 2013-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> *
<ide> * The examples provided by Facebook are for non-commercial testing and
<ide> * evaluation purposes only.
<ide> *
<ide> */
<ide> 'use strict';
<ide>
<add>const AppRegistry = require('AppRegistry');
<add>const AsyncStorage = require('AsyncStorage');
<add>const BackAndroid = require('BackAndroid');
<add>const Dimensions = require('Dimensions');
<add>const DrawerLayoutAndroid = require('DrawerLayoutAndroid');
<add>const Linking = require('Linking');
<ide> const React = require('react');
<del>const ReactNative = require('react-native');
<del>const {
<del> AppRegistry,
<del> BackAndroid,
<del> Dimensions,
<del> DrawerLayoutAndroid,
<del> NavigationExperimental,
<del> StyleSheet,
<del> ToolbarAndroid,
<del> View,
<del> StatusBar,
<del>} = ReactNative;
<del>const {
<del> RootContainer: NavigationRootContainer,
<del>} = NavigationExperimental;
<add>const StatusBar = require('StatusBar');
<add>const StyleSheet = require('StyleSheet');
<add>const ToolbarAndroid = require('ToolbarAndroid');
<ide> const UIExplorerExampleList = require('./UIExplorerExampleList');
<ide> const UIExplorerList = require('./UIExplorerList');
<ide> const UIExplorerNavigationReducer = require('./UIExplorerNavigationReducer');
<ide> const UIExplorerStateTitleMap = require('./UIExplorerStateTitleMap');
<ide> const URIActionMap = require('./URIActionMap');
<add>const View = require('View');
<ide>
<del>var DRAWER_WIDTH_LEFT = 56;
<add>const DRAWER_WIDTH_LEFT = 56;
<ide>
<ide> type Props = {
<ide> exampleFromAppetizeParams: string,
<ide> type State = {
<ide> };
<ide>
<ide> class UIExplorerApp extends React.Component {
<del> _handleOpenInitialExample: Function;
<add> _handleAction: Function;
<add> _renderDrawerContent: Function;
<ide> state: State;
<ide> constructor(props: Props) {
<ide> super(props);
<del> this._handleOpenInitialExample = this._handleOpenInitialExample.bind(this);
<del> this.state = {
<del> initialExampleUri: props.exampleFromAppetizeParams,
<del> };
<add> this._handleAction = this._handleAction.bind(this);
<add> this._renderDrawerContent = this._renderDrawerContent.bind(this);
<ide> }
<ide>
<ide> componentWillMount() {
<ide> BackAndroid.addEventListener('hardwareBackPress', this._handleBackButtonPress.bind(this));
<ide> }
<ide>
<ide> componentDidMount() {
<del> // There's a race condition if we try to navigate to the specified example
<del> // from the initial props at the same time the navigation logic is setting
<del> // up the initial navigation state. This hack adds a delay to avoid this
<del> // scenario. So after the initial example list is shown, we then transition
<del> // to the initial example.
<del> setTimeout(this._handleOpenInitialExample, 500);
<add> Linking.getInitialURL().then((url) => {
<add> AsyncStorage.getItem('UIExplorerAppState', (err, storedString) => {
<add> const exampleAction = URIActionMap(this.props.exampleFromAppetizeParams);
<add> const urlAction = URIActionMap(url);
<add> const launchAction = exampleAction || urlAction;
<add> if (err || !storedString) {
<add> const initialAction = launchAction || {type: 'InitialAction'};
<add> this.setState(UIExplorerNavigationReducer(null, initialAction));
<add> return;
<add> }
<add> const storedState = JSON.parse(storedString);
<add> if (launchAction) {
<add> this.setState(UIExplorerNavigationReducer(storedState, launchAction));
<add> return;
<add> }
<add> this.setState(storedState);
<add> });
<add> });
<ide> }
<ide>
<ide> render() {
<del> return (
<del> <NavigationRootContainer
<del> persistenceKey="UIExplorerStateNavState"
<del> ref={navRootRef => { this._navigationRootRef = navRootRef; }}
<del> reducer={UIExplorerNavigationReducer}
<del> renderNavigation={this._renderApp.bind(this)}
<del> linkingActionMap={URIActionMap}
<del> />
<del> );
<del> }
<del>
<del> _handleOpenInitialExample() {
<del> if (this.state.initialExampleUri) {
<del> const exampleAction = URIActionMap(this.state.initialExampleUri);
<del> if (exampleAction && this._navigationRootRef) {
<del> this._navigationRootRef.handleNavigation(exampleAction);
<del> }
<del> }
<del> this.setState({initialExampleUri: null});
<del> }
<del>
<del> _renderApp(navigationState, onNavigate) {
<del> if (!navigationState) {
<add> if (!this.state) {
<ide> return null;
<ide> }
<ide> return (
<ide> class UIExplorerApp extends React.Component {
<ide> this._overrideBackPressForDrawerLayout = false;
<ide> }}
<ide> ref={(drawer) => { this.drawer = drawer; }}
<del> renderNavigationView={this._renderDrawerContent.bind(this, onNavigate)}
<add> renderNavigationView={this._renderDrawerContent}
<ide> statusBarBackgroundColor="#589c90">
<del> {this._renderNavigation(navigationState, onNavigate)}
<add> {this._renderApp()}
<ide> </DrawerLayoutAndroid>
<ide> );
<ide> }
<ide>
<del> _renderDrawerContent(onNavigate) {
<add> _renderDrawerContent() {
<ide> return (
<ide> <View style={styles.drawerContentWrapper}>
<ide> <UIExplorerExampleList
<ide> list={UIExplorerList}
<ide> displayTitleRow={true}
<ide> disableSearch={true}
<del> onNavigate={(action) => {
<del> this.drawer && this.drawer.closeDrawer();
<del> onNavigate(action);
<del> }}
<add> onNavigate={this._handleAction}
<ide> />
<ide> </View>
<ide> );
<ide> }
<ide>
<del> _renderNavigation(navigationState, onNavigate) {
<del> if (navigationState.externalExample) {
<del> var Component = UIExplorerList.Modules[navigationState.externalExample];
<add> _renderApp() {
<add> const {
<add> externalExample,
<add> stack,
<add> } = this.state;
<add> if (externalExample) {
<add> const Component = UIExplorerList.Modules[externalExample];
<ide> return (
<ide> <Component
<ide> onExampleExit={() => {
<del> onNavigate(NavigationRootContainer.getBackAction());
<add> this._handleAction({ type: 'BackAction' });
<ide> }}
<ide> ref={(example) => { this._exampleRef = example; }}
<ide> />
<ide> );
<ide> }
<del> const {stack} = navigationState;
<ide> const title = UIExplorerStateTitleMap(stack.children[stack.index]);
<ide> const index = stack.children.length <= 1 ? 1 : stack.index;
<ide>
<ide> class UIExplorerApp extends React.Component {
<ide> title={title}
<ide> />
<ide> <UIExplorerExampleList
<add> onNavigate={this._handleAction}
<ide> list={UIExplorerList}
<ide> {...stack.children[0]}
<ide> />
<ide> </View>
<ide> );
<ide> }
<ide>
<add> _handleAction(action: Object): boolean {
<add> this.drawer && this.drawer.closeDrawer();
<add> const newState = UIExplorerNavigationReducer(this.state, action);
<add> if (this.state !== newState) {
<add> this.setState(newState);
<add> AsyncStorage.setItem('UIExplorerAppState', JSON.stringify(this.state));
<add> return true;
<add> }
<add> return false;
<add> }
<add>
<ide> _handleBackButtonPress() {
<ide> if (this._overrideBackPressForDrawerLayout) {
<ide> // This hack is necessary because drawer layout provides an imperative API
<ide> class UIExplorerApp extends React.Component {
<ide> ) {
<ide> return true;
<ide> }
<del> if (this._navigationRootRef) {
<del> return this._navigationRootRef.handleNavigation(
<del> NavigationRootContainer.getBackAction()
<del> );
<del> }
<del> return false;
<add> return this._handleAction({ type: 'BackAction' });
<ide> }
<ide> }
<ide>
<ide><path>Examples/UIExplorer/UIExplorerApp.ios.js
<ide> */
<ide> 'use strict';
<ide>
<add>const AsyncStorage = require('AsyncStorage');
<add>const Linking = require('Linking');
<ide> const React = require('react');
<ide> const ReactNative = require('react-native');
<ide> const UIExplorerList = require('./UIExplorerList.ios');
<ide> const {
<ide> const {
<ide> CardStack: NavigationCardStack,
<ide> Header: NavigationHeader,
<del> RootContainer: NavigationRootContainer,
<ide> } = NavigationExperimental;
<ide>
<ide> import type { NavigationSceneRendererProps } from 'NavigationTypeDefinition';
<ide> type Props = {
<ide> exampleFromAppetizeParams: string,
<ide> };
<ide>
<del>type State = {
<del> initialExampleUri: ?string,
<add>type State = UIExplorerNavigationState & {
<add> externalExample?: string,
<ide> };
<ide>
<ide> class UIExplorerApp extends React.Component {
<del> _navigationRootRef: ?NavigationRootContainer;
<del> _renderNavigation: Function;
<ide> _renderOverlay: Function;
<ide> _renderScene: Function;
<ide> _renderCard: Function;
<ide> _renderTitleComponent: Function;
<del> _handleOpenInitialExample: Function;
<add> _handleAction: Function;
<ide> state: State;
<add>
<ide> constructor(props: Props) {
<ide> super(props);
<del> this._handleOpenInitialExample = this._handleOpenInitialExample.bind(this);
<del> this.state = {
<del> initialExampleUri: props.exampleFromAppetizeParams,
<del> };
<ide> }
<add>
<ide> componentWillMount() {
<del> this._renderNavigation = this._renderNavigation.bind(this);
<add> this._handleAction = this._handleAction.bind(this);
<ide> this._renderOverlay = this._renderOverlay.bind(this);
<ide> this._renderScene = this._renderScene.bind(this);
<ide> this._renderTitleComponent = this._renderTitleComponent.bind(this);
<ide> }
<add>
<ide> componentDidMount() {
<del> // There's a race condition if we try to navigate to the specified example
<del> // from the initial props at the same time the navigation logic is setting
<del> // up the initial navigation state. This hack adds a delay to avoid this
<del> // scenario. So after the initial example list is shown, we then transition
<del> // to the initial example.
<del> setTimeout(this._handleOpenInitialExample, 500);
<del> }
<del> render() {
<del> return (
<del> <NavigationRootContainer
<del> persistenceKey="UIExplorerState"
<del> reducer={UIExplorerNavigationReducer}
<del> ref={navRootRef => { this._navigationRootRef = navRootRef; }}
<del> renderNavigation={this._renderNavigation}
<del> linkingActionMap={URIActionMap}
<del> />
<del> );
<add> Linking.getInitialURL().then((url) => {
<add> AsyncStorage.getItem('UIExplorerAppState', (err, storedString) => {
<add> const exampleAction = URIActionMap(this.props.exampleFromAppetizeParams);
<add> const urlAction = URIActionMap(url);
<add> const launchAction = exampleAction || urlAction;
<add> if (err || !storedString) {
<add> const initialAction = launchAction || {type: 'InitialAction'};
<add> this.setState(UIExplorerNavigationReducer(null, initialAction));
<add> return;
<add> }
<add> const storedState = JSON.parse(storedString);
<add> if (launchAction) {
<add> this.setState(UIExplorerNavigationReducer(storedState, launchAction));
<add> return;
<add> }
<add> this.setState(storedState);
<add> });
<add> });
<add>
<add> Linking.addEventListener('url', (url) => {
<add> this._handleAction(URIActionMap(url));
<add> });
<ide> }
<del> _handleOpenInitialExample() {
<del> if (this.state.initialExampleUri) {
<del> const exampleAction = URIActionMap(this.state.initialExampleUri);
<del> if (exampleAction && this._navigationRootRef) {
<del> this._navigationRootRef.handleNavigation(exampleAction);
<del> }
<add>
<add> _handleAction(action: Object) {
<add> if (!action) {
<add> return;
<add> }
<add> const newState = UIExplorerNavigationReducer(this.state, action);
<add> if (this.state !== newState) {
<add> this.setState(newState);
<add> AsyncStorage.setItem('UIExplorerAppState', JSON.stringify(this.state));
<ide> }
<del> this.setState({initialExampleUri: null});
<ide> }
<del> _renderNavigation(navigationState: UIExplorerNavigationState, onNavigate: Function) {
<del> if (!navigationState) {
<add>
<add> render() {
<add> if (!this.state) {
<ide> return null;
<ide> }
<del> if (navigationState.externalExample) {
<del> var Component = UIExplorerList.Modules[navigationState.externalExample];
<add> if (this.state.externalExample) {
<add> const Component = UIExplorerList.Modules[this.state.externalExample];
<ide> return (
<ide> <Component
<ide> onExampleExit={() => {
<del> onNavigate(NavigationRootContainer.getBackAction());
<add> this._handleAction({ type: 'BackAction' });
<ide> }}
<ide> />
<ide> );
<ide> }
<del> const {stack} = navigationState;
<ide> return (
<ide> <NavigationCardStack
<del> navigationState={stack}
<add> navigationState={this.state.stack}
<ide> style={styles.container}
<ide> renderOverlay={this._renderOverlay}
<ide> renderScene={this._renderScene}
<add> onNavigate={this._handleAction}
<ide> />
<ide> );
<ide> }
<ide> class UIExplorerApp extends React.Component {
<ide> if (state.key === 'AppList') {
<ide> return (
<ide> <UIExplorerExampleList
<add> onNavigate={this._handleAction}
<ide> list={UIExplorerList}
<ide> style={styles.exampleContainer}
<ide> {...state}
<ide> AppRegistry.registerComponent('UIExplorerApp', () => UIExplorerApp);
<ide> UIExplorerList.ComponentExamples.concat(UIExplorerList.APIExamples).forEach((Example: UIExplorerExample) => {
<ide> const ExampleModule = Example.module;
<ide> if (ExampleModule.displayName) {
<del> var Snapshotter = React.createClass({
<add> const Snapshotter = React.createClass({
<ide> render: function() {
<del> var Renderable = UIExplorerExampleList.makeRenderable(ExampleModule);
<add> const Renderable = UIExplorerExampleList.makeRenderable(ExampleModule);
<ide> return (
<ide> <SnapshotViewIOS>
<ide> <Renderable />
<ide><path>Examples/UIExplorer/UIExplorerExampleList.js
<ide> const React = require('react');
<ide> const StyleSheet = require('StyleSheet');
<ide> const Text = require('Text');
<ide> const TextInput = require('TextInput');
<del>const NavigationContainer = require('NavigationContainer');
<ide> const TouchableHighlight = require('TouchableHighlight');
<ide> const View = require('View');
<ide> const UIExplorerActions = require('./UIExplorerActions');
<ide> class UIExplorerExampleList extends React.Component {
<ide> }) {
<ide>
<ide> }
<add>
<add> static makeRenderable(example: any): ReactClass<any> {
<add> return example.examples ?
<add> createExamplePage(null, example) :
<add> example;
<add> }
<add>
<ide> render(): ?ReactElement {
<ide> const filterText = this.props.filter || '';
<ide> const filterRegex = new RegExp(String(filterText), 'i');
<ide> class UIExplorerExampleList extends React.Component {
<ide> }
<ide> }
<ide>
<del>function makeRenderable(example: any): ReactClass<any> {
<del> return example.examples ?
<del> createExamplePage(null, example) :
<del> example;
<del>}
<del>
<del>UIExplorerExampleList = NavigationContainer.create(UIExplorerExampleList);
<del>UIExplorerExampleList.makeRenderable = makeRenderable;
<del>
<ide> const styles = StyleSheet.create({
<ide> listContainer: {
<ide> flex: 1,
<ide><path>Libraries/CustomComponents/NavigationExperimental/NavigationCard.js
<ide> const Animated = require('Animated');
<ide> const NavigationCardStackPanResponder = require('NavigationCardStackPanResponder');
<ide> const NavigationCardStackStyleInterpolator = require('NavigationCardStackStyleInterpolator');
<del>const NavigationContainer = require('NavigationContainer');
<ide> const NavigationPagerPanResponder = require('NavigationPagerPanResponder');
<ide> const NavigationPagerStyleInterpolator = require('NavigationPagerStyleInterpolator');
<ide> const NavigationPointerEventsContainer = require('NavigationPointerEventsContainer');
<ide> class NavigationCard extends React.Component<any, Props, any> {
<ide> </Animated.View>
<ide> );
<ide> }
<add>
<add> static CardStackPanResponder = NavigationCardStackPanResponder;
<add> static CardStackStyleInterpolator = NavigationCardStackStyleInterpolator;
<add> static PagerPanResponder = NavigationPagerPanResponder;
<add> static PagerStyleInterpolator = NavigationPagerStyleInterpolator;
<ide> }
<ide>
<ide> const styles = StyleSheet.create({
<ide> const styles = StyleSheet.create({
<ide> });
<ide>
<ide> NavigationCard = NavigationPointerEventsContainer.create(NavigationCard);
<del>NavigationCard = NavigationContainer.create(NavigationCard);
<del>
<del>// Export these buil-in interaction modules.
<del>NavigationCard.CardStackPanResponder = NavigationCardStackPanResponder;
<del>NavigationCard.CardStackStyleInterpolator = NavigationCardStackStyleInterpolator;
<del>NavigationCard.PagerPanResponder = NavigationPagerPanResponder;
<del>NavigationCard.PagerStyleInterpolator = NavigationPagerStyleInterpolator;
<ide>
<ide> module.exports = NavigationCard;
<ide><path>Libraries/CustomComponents/NavigationExperimental/NavigationCardStack.js
<ide> const NavigationAnimatedView = require('NavigationAnimatedView');
<ide> const NavigationCard = require('NavigationCard');
<ide> const NavigationCardStackStyleInterpolator = require('NavigationCardStackStyleInterpolator');
<del>const NavigationContainer = require('NavigationContainer');
<ide> const NavigationCardStackPanResponder = require('NavigationCardStackPanResponder');
<ide> const NavigationPropTypes = require('NavigationPropTypes');
<ide> const React = require('React');
<ide> const {PropTypes} = React;
<ide> const {Directions} = NavigationCardStackPanResponder;
<ide>
<ide> import type {
<add> NavigationActionCaller,
<ide> NavigationParentState,
<ide> NavigationSceneRenderer,
<ide> NavigationSceneRendererProps,
<ide> import type {
<ide> type Props = {
<ide> direction: NavigationGestureDirection,
<ide> navigationState: NavigationParentState,
<add> onNavigate: NavigationActionCaller,
<ide> renderOverlay: ?NavigationSceneRenderer,
<ide> renderScene: NavigationSceneRenderer,
<ide> };
<ide> class NavigationCardStack extends React.Component<DefaultProps, Props, void> {
<ide> static propTypes = {
<ide> direction: PropTypes.oneOf([Directions.HORIZONTAL, Directions.VERTICAL]),
<ide> navigationState: NavigationPropTypes.navigationParentState.isRequired,
<add> onNavigate: NavigationPropTypes.SceneRenderer.onNavigate,
<ide> renderOverlay: PropTypes.func,
<ide> renderScene: PropTypes.func.isRequired,
<ide> };
<ide> class NavigationCardStack extends React.Component<DefaultProps, Props, void> {
<ide> navigationState={this.props.navigationState}
<ide> renderOverlay={this.props.renderOverlay}
<ide> renderScene={this._renderScene}
<add> onNavigate={this.props.onNavigate}
<ide> // $FlowFixMe - style should be declared
<ide> style={[styles.animatedView, this.props.style]}
<ide> />
<ide> const styles = StyleSheet.create({
<ide> },
<ide> });
<ide>
<del>module.exports = NavigationContainer.create(NavigationCardStack);
<add>module.exports = NavigationCardStack;
<ide><path>Libraries/CustomComponents/NavigationExperimental/NavigationHeader.js
<ide>
<ide> const React = require('React');
<ide> const ReactNative = require('react-native');
<del>const NavigationContainer = require('NavigationContainer');
<ide> const NavigationHeaderTitle = require('NavigationHeaderTitle');
<ide> const NavigationHeaderBackButton = require('NavigationHeaderBackButton');
<ide> const NavigationPropTypes = require('NavigationPropTypes');
<ide> const {
<ide> } = ReactNative;
<ide>
<ide> import type {
<add> NavigationActionCaller,
<ide> NavigationSceneRenderer,
<ide> NavigationSceneRendererProps,
<ide> NavigationStyleInterpolator,
<ide> type Props = NavigationSceneRendererProps & {
<ide> renderLeftComponent: NavigationSceneRenderer,
<ide> renderRightComponent: NavigationSceneRenderer,
<ide> renderTitleComponent: NavigationSceneRenderer,
<del> style?: any;
<del> viewProps?: any;
<add> onNavigate: NavigationActionCaller,
<add> style?: any,
<add> viewProps?: any,
<ide> };
<ide>
<ide> type SubViewName = 'left' | 'title' | 'right';
<ide> class NavigationHeader extends React.Component<DefaultProps, Props, any> {
<ide> },
<ide>
<ide> renderLeftComponent: (props: NavigationSceneRendererProps) => {
<del> return props.scene.index > 0 ? <NavigationHeaderBackButton /> : null;
<add> if (props.scene.index === 0) {
<add> return null;
<add> }
<add> return (
<add> <NavigationHeaderBackButton
<add> onNavigate={props.onNavigate}
<add> />
<add> );
<ide> },
<ide>
<ide> renderRightComponent: (props: NavigationSceneRendererProps) => {
<ide> class NavigationHeader extends React.Component<DefaultProps, Props, any> {
<ide> </Animated.View>
<ide> );
<ide> }
<add>
<add> static HEIGHT = APPBAR_HEIGHT + STATUSBAR_HEIGHT;
<add> static Title = NavigationHeaderTitle;
<add> static BackButton = NavigationHeaderBackButton;
<add>
<ide> }
<ide>
<ide> const styles = StyleSheet.create({
<ide> const styles = StyleSheet.create({
<ide> },
<ide> });
<ide>
<del>const NavigationHeaderContainer = NavigationContainer.create(NavigationHeader);
<del>
<del>NavigationHeaderContainer.HEIGHT = APPBAR_HEIGHT + STATUSBAR_HEIGHT;
<del>NavigationHeaderContainer.Title = NavigationHeaderTitle;
<del>NavigationHeaderContainer.BackButton = NavigationHeaderBackButton;
<del>
<del>module.exports = NavigationHeaderContainer;
<add>module.exports = NavigationHeader;
<ide><path>Libraries/CustomComponents/NavigationExperimental/NavigationHeaderBackButton.js
<ide> /**
<add> * Copyright (c) 2013-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> *
<ide> * The examples provided by Facebook are for non-commercial testing and
<ide> * evaluation purposes only.
<ide> *
<ide>
<ide> const React = require('react');
<ide> const ReactNative = require('react-native');
<del>const NavigationContainer = require('NavigationContainer');
<del>const NavigationRootContainer = require('NavigationRootContainer');
<ide>
<ide> const {
<ide> Image,
<ide> type Props = {
<ide> }
<ide>
<ide> const NavigationHeaderBackButton = (props: Props) => (
<del> <TouchableOpacity style={styles.buttonContainer} onPress={() => props.onNavigate(NavigationRootContainer.getBackAction())}>
<add> <TouchableOpacity style={styles.buttonContainer} onPress={() => props.onNavigate({type: 'BackAction'})}>
<ide> <Image style={styles.button} source={require('./assets/back-icon.png')} />
<ide> </TouchableOpacity>
<ide> );
<ide> const styles = StyleSheet.create({
<ide> }
<ide> });
<ide>
<del>module.exports = NavigationContainer.create(NavigationHeaderBackButton);
<add>module.exports = NavigationHeaderBackButton;
<ide><path>Libraries/NavigationExperimental/NavigationAnimatedView.js
<ide> 'use strict';
<ide>
<ide> const Animated = require('Animated');
<del>const NavigationContainer = require('NavigationContainer');
<ide> const NavigationPropTypes = require('NavigationPropTypes');
<ide> const NavigationScenesReducer = require('NavigationScenesReducer');
<ide> const React = require('React');
<ide> const styles = StyleSheet.create({
<ide> },
<ide> });
<ide>
<del>NavigationAnimatedView = NavigationContainer.create(NavigationAnimatedView);
<del>
<ide> module.exports = NavigationAnimatedView;
<ide><path>Libraries/NavigationExperimental/NavigationContainer.js
<del>/**
<del> * Copyright (c) 2015-present, Facebook, Inc.
<del> * All rights reserved.
<del> *
<del> * This source code is licensed under the BSD-style license found in the
<del> * LICENSE file in the root directory of this source tree. An additional grant
<del> * of patent rights can be found in the PATENTS file in the same directory.
<del> *
<del> * @providesModule NavigationContainer
<del> * @flow
<del> */
<del>'use strict';
<del>
<del>var React = require('React');
<del>var NavigationRootContainer = require('NavigationRootContainer');
<del>
<del>function createNavigationContainer(
<del> Component: ReactClass<any>,
<del>): ReactClass & Object {
<del> class NavigationComponent extends React.Component {
<del> render() {
<del> return (
<del> <Component
<del> onNavigate={this.getNavigationHandler()}
<del> {...this.props}
<del> />
<del> );
<del> }
<del> getNavigationHandler() {
<del> return this.props.onNavigate || this.context.onNavigate;
<del> }
<del> getChildContext() {
<del> return {
<del> onNavigate: this.getNavigationHandler(),
<del> };
<del> }
<del> }
<del> NavigationComponent.contextTypes = {
<del> onNavigate: React.PropTypes.func,
<del> };
<del> NavigationComponent.childContextTypes = {
<del> onNavigate: React.PropTypes.func,
<del> };
<del> return NavigationComponent;
<del>}
<del>
<del>var NavigationContainer = {
<del> create: createNavigationContainer,
<del> RootContainer: NavigationRootContainer,
<del>};
<del>
<del>
<del>module.exports = NavigationContainer;
<ide><path>Libraries/NavigationExperimental/NavigationExperimental.js
<ide> const NavigationAnimatedView = require('NavigationAnimatedView');
<ide> const NavigationCard = require('NavigationCard');
<ide> const NavigationCardStack = require('NavigationCardStack');
<del>const NavigationContainer = require('NavigationContainer');
<ide> const NavigationHeader = require('NavigationHeader');
<ide> const NavigationReducer = require('NavigationReducer');
<del>const NavigationRootContainer = require('NavigationRootContainer');
<ide> const NavigationStateUtils = require('NavigationStateUtils');
<ide> const NavigationView = require('NavigationView');
<ide> const NavigationPropTypes = require('NavigationPropTypes');
<ide> const NavigationExperimental = {
<ide> StateUtils: NavigationStateUtils,
<ide> Reducer: NavigationReducer,
<ide>
<del> // Containers
<del> Container: NavigationContainer,
<del> RootContainer: NavigationRootContainer,
<del>
<ide> // Views
<ide> View: NavigationView,
<ide> AnimatedView: NavigationAnimatedView,
<ide><path>Libraries/NavigationExperimental/NavigationRootContainer.js
<del>/**
<del> * Copyright (c) 2015-present, Facebook, Inc.
<del> * All rights reserved.
<del> *
<del> * This source code is licensed under the BSD-style license found in the
<del> * LICENSE file in the root directory of this source tree. An additional grant
<del> * of patent rights can be found in the PATENTS file in the same directory.
<del> *
<del> * @providesModule NavigationRootContainer
<del> * @flow
<del> */
<del>'use strict';
<del>
<del>const AsyncStorage = require('AsyncStorage');
<del>const Linking = require('Linking');
<del>const NavigationPropTypes = require('NavigationPropTypes');
<del>const NavigationStateUtils = require('NavigationStateUtils');
<del>const Platform = require('Platform');
<del>const React = require('React');
<del>
<del>import type {
<del> NavigationAction,
<del> NavigationParentState,
<del> NavigationReducer,
<del> NavigationRenderer,
<del>} from 'NavigationTypeDefinition';
<del>
<del>export type BackAction = {
<del> type: 'BackAction',
<del>};
<del>
<del>type Props = {
<del> /*
<del> * The default action to be passed into the reducer when getting the first
<del> * state. Defaults to {type: 'RootContainerInitialAction'}
<del> */
<del> initialAction: NavigationAction,
<del>
<del> /*
<del> * Provide linkingActionMap to instruct the container to subscribe to linking
<del> * events, and use this mapper to convert URIs into actions that your app can
<del> * handle
<del> */
<del> linkingActionMap: ?((uri: ?string) => NavigationAction),
<del>
<del> /*
<del> * Provide this key, and the container will store the navigation state in
<del> * AsyncStorage through refreshes, with the provided key
<del> */
<del> persistenceKey: ?string,
<del>
<del>
<del> /*
<del> * A function that will output the latest navigation state as a function of
<del> * the (optional) previous state, and an action
<del> */
<del> reducer: NavigationReducer,
<del>
<del>
<del> /*
<del> * Set up the rendering of the app for a given navigation state
<del> */
<del> renderNavigation: NavigationRenderer,
<del>};
<del>
<del>type State = {
<del> navState: ?NavigationParentState,
<del>};
<del>
<del>function getBackAction(): BackAction {
<del> return { type: 'BackAction' };
<del>}
<del>
<del>const {PropTypes} = React;
<del>
<del>class NavigationRootContainer extends React.Component<any, Props, State> {
<del> _handleOpenURLEvent: Function;
<del>
<del> props: Props;
<del> state: State;
<del>
<del> static propTypes = {
<del> initialAction: NavigationPropTypes.action.isRequired,
<del> linkingActionMap: PropTypes.func,
<del> persistenceKey: PropTypes.string,
<del> reducer: PropTypes.func.isRequired,
<del> renderNavigation: PropTypes.func.isRequired,
<del> };
<del>
<del> static defaultProps = {
<del> initialAction: { type: 'RootContainerInitialAction' },
<del> };
<del>
<del> static childContextTypes = {
<del> onNavigate: PropTypes.func,
<del> };
<del>
<del>
<del> static getBackAction = getBackAction;
<del>
<del> constructor(props: Props) {
<del> super(props);
<del>
<del> let navState = null;
<del> if (!this.props.persistenceKey) {
<del> navState = NavigationStateUtils.getParent(
<del> this.props.reducer(null, props.initialAction)
<del> );
<del> }
<del> this.state = { navState };
<del> }
<del>
<del> componentWillMount(): void {
<del> (this: any).handleNavigation = this.handleNavigation.bind(this);
<del> (this: any)._handleOpenURLEvent = this._handleOpenURLEvent.bind(this);
<del> }
<del>
<del> componentDidMount(): void {
<del> if (this.props.linkingActionMap) {
<del> Linking.getInitialURL().then(this._handleOpenURL.bind(this));
<del> Platform.OS === 'ios' && Linking.addEventListener('url', this._handleOpenURLEvent);
<del> }
<del> if (this.props.persistenceKey) {
<del> AsyncStorage.getItem(this.props.persistenceKey, (err, storedString) => {
<del> if (err || !storedString) {
<del> this.setState({
<del> // $FlowFixMe - navState is missing properties :(
<del> navState: this.props.reducer(null, this.props.initialAction),
<del> });
<del> return;
<del> }
<del> this.setState({
<del> navState: JSON.parse(storedString),
<del> });
<del> });
<del> }
<del> }
<del>
<del> componentWillUnmount(): void {
<del> if (Platform.OS === 'ios') {
<del> Linking.removeEventListener('url', this._handleOpenURLEvent);
<del> }
<del> }
<del>
<del> _handleOpenURLEvent(event: {url: string}): void {
<del> this._handleOpenURL(event.url);
<del> }
<del>
<del> _handleOpenURL(url: ?string): void {
<del> if (!this.props.linkingActionMap) {
<del> return;
<del> }
<del> const action = this.props.linkingActionMap(url);
<del> if (action) {
<del> this.handleNavigation(action);
<del> }
<del> }
<del>
<del> getChildContext(): Object {
<del> return {
<del> onNavigate: this.handleNavigation,
<del> };
<del> }
<del>
<del> handleNavigation(action: Object): boolean {
<del> const navState = this.props.reducer(this.state.navState, action);
<del> if (navState === this.state.navState) {
<del> return false;
<del> }
<del> this.setState({
<del> // $FlowFixMe - navState is missing properties :(
<del> navState,
<del> });
<del>
<del> if (this.props.persistenceKey) {
<del> AsyncStorage.setItem(this.props.persistenceKey, JSON.stringify(navState));
<del> }
<del>
<del> return true;
<del> }
<del>
<del> render(): ReactElement {
<del> const navigation = this.props.renderNavigation(
<del> this.state.navState,
<del> this.handleNavigation
<del> );
<del> return navigation;
<del> }
<del>}
<del>
<del>module.exports = NavigationRootContainer;
<ide><path>Libraries/NavigationExperimental/NavigationView.js
<ide> 'use strict';
<ide>
<ide> const Animated = require('Animated');
<del>const NavigationContainer = require('NavigationContainer');
<ide> const React = require('React');
<ide> const StyleSheet = require('StyleSheet');
<ide> const View = require('View');
<ide> const styles = StyleSheet.create({
<ide> },
<ide> });
<ide>
<del>module.exports = NavigationContainer.create(NavigationView);
<add>module.exports = NavigationView;
<ide><path>Libraries/NavigationExperimental/Reducer/NavigationStackReducer.js
<ide> */
<ide> 'use strict';
<ide>
<del>var NavigationStateUtils = require('NavigationStateUtils');
<add>const NavigationStateUtils = require('NavigationStateUtils');
<ide>
<ide> import type {
<ide> NavigationState,
<ide> NavigationParentState,
<ide> NavigationReducer,
<ide> } from 'NavigationTypeDefinition';
<ide>
<del>import type {
<del> BackAction,
<del>} from 'NavigationRootContainer';
<del>
<del>export type NavigationStackReducerAction = BackAction | {
<del> type: string,
<del>};
<del>
<ide> export type ReducerForStateHandler = (state: NavigationState) => NavigationReducer;
<ide>
<ide> export type PushedReducerForActionHandler = (action: any, lastState: NavigationParentState) => ?NavigationReducer; | 22 |
Go | Go | replace sendpair() with the simpler sendconn() | 4f92ffb50036f313a51020e1bfdcad7b10db65fb | <ide><path>pkg/beam/beam.go
<ide> func SendPipe(dst Sender, data []byte) (*os.File, error) {
<ide> return w, nil
<ide> }
<ide>
<del>func SendPair(dst Sender, data []byte) (in ReceiveCloser, out SendCloser, err error) {
<add>func SendConn(dst Sender, data []byte) (conn *UnixConn, err error) {
<ide> local, remote, err := SocketPair()
<ide> if err != nil {
<del> return nil, nil, err
<add> return nil, err
<ide> }
<ide> defer func() {
<ide> if err != nil {
<ide> local.Close()
<ide> remote.Close()
<ide> }
<ide> }()
<del> endpoint, err := FileConn(local)
<add> conn, err = FileConn(local)
<ide> if err != nil {
<del> return nil, nil, err
<add> return nil, err
<ide> }
<ide> local.Close()
<ide> if err := dst.Send(data, remote); err != nil {
<del> return nil, nil, err
<add> return nil, err
<ide> }
<del> return ReceiveCloser(endpoint), SendCloser(endpoint), nil
<add> return conn, nil
<ide> }
<ide>
<del>func ReceivePair(src Receiver) ([]byte, Receiver, Sender, error) {
<add>func ReceiveConn(src Receiver) ([]byte, *UnixConn, error) {
<ide> for {
<ide> data, f, err := src.Receive()
<ide> if err != nil {
<del> return nil, nil, nil, err
<add> return nil, nil, err
<ide> }
<ide> if f == nil {
<ide> // Skip empty attachments
<ide> func ReceivePair(src Receiver) ([]byte, Receiver, Sender, error) {
<ide> // (for example might be a regular file, directory etc)
<ide> continue
<ide> }
<del> return data, Receiver(conn), Sender(conn), nil
<add> return data, conn, nil
<ide> }
<ide> panic("impossibru!")
<del> return nil, nil, nil, nil
<add> return nil, nil, nil
<ide> }
<ide>
<ide> func Copy(dst Sender, src Receiver) (int, error) {
<ide><path>pkg/beam/service.go
<ide> import (
<ide> // not point to a connection, that message will be skipped.
<ide> //
<ide> func Listen(conn Sender, name string) (net.Listener, error) {
<del> in, _, err := SendPair(conn, []byte(name))
<add> endpoint, err := SendConn(conn, []byte(name))
<ide> if err != nil {
<ide> return nil, err
<ide> }
<ide> return &listener{
<ide> name: name,
<del> endpoint: in,
<add> endpoint: endpoint,
<ide> }, nil
<ide> }
<ide> | 2 |
Text | Text | harmonize changes list ordering | bd45124f00473b0e5affdb206c520a70330dd27d | <ide><path>doc/api/crypto.md
<ide> console.log(uncompressedKey === ecdh.getPublicKey('hex'));
<ide> <!-- YAML
<ide> added: v0.11.14
<ide> changes:
<del> - version: v6.0.0
<del> pr-url: https://github.com/nodejs/node/pull/5522
<del> description: The default `inputEncoding` changed from `binary` to `utf8`.
<ide> - version: v10.0.0
<ide> pr-url: https://github.com/nodejs/node/pull/16849
<ide> description: Changed error format to better support invalid public key
<ide> error.
<add> - version: v6.0.0
<add> pr-url: https://github.com/nodejs/node/pull/5522
<add> description: The default `inputEncoding` changed from `binary` to `utf8`.
<ide> -->
<ide>
<ide> * `otherPublicKey` {string|ArrayBuffer|Buffer|TypedArray|DataView}
<ide><path>doc/api/dgram.md
<ide> changes:
<ide> - v12.19.0
<ide> pr-url: https://github.com/nodejs/node/pull/22413
<ide> description: The `msg` parameter can now be any `TypedArray` or `DataView`.
<add> - version: v12.0.0
<add> pr-url: https://github.com/nodejs/node/pull/26871
<add> description: Added support for sending data on connected sockets.
<ide> - version: v8.0.0
<ide> pr-url: https://github.com/nodejs/node/pull/11985
<ide> description: The `msg` parameter can be an `Uint8Array` now.
<ide> changes:
<ide> pr-url: https://github.com/nodejs/node/pull/4374
<ide> description: The `msg` parameter can be an array now. Also, the `offset`
<ide> and `length` parameters are optional now.
<del> - version: v12.0.0
<del> pr-url: https://github.com/nodejs/node/pull/26871
<del> description: Added support for sending data on connected sockets.
<ide> -->
<ide>
<ide> * `msg` {Buffer|TypedArray|DataView|string|Array} Message to be sent.
<ide> chained.
<ide> <!-- YAML
<ide> added: v0.11.13
<ide> changes:
<del> - version: v8.6.0
<del> pr-url: https://github.com/nodejs/node/pull/14560
<del> description: The `lookup` option is supported.
<add> - version: v11.4.0
<add> pr-url: https://github.com/nodejs/node/pull/23798
<add> description: The `ipv6Only` option is supported.
<ide> - version: v8.7.0
<ide> pr-url: https://github.com/nodejs/node/pull/13623
<ide> description: The `recvBufferSize` and `sendBufferSize` options are
<ide> supported now.
<del> - version: v11.4.0
<del> pr-url: https://github.com/nodejs/node/pull/23798
<del> description: The `ipv6Only` option is supported.
<add> - version: v8.6.0
<add> pr-url: https://github.com/nodejs/node/pull/14560
<add> description: The `lookup` option is supported.
<ide> -->
<ide>
<ide> * `options` {Object} Available options are:
<ide><path>doc/api/fs.md
<ide> If `options` is a string, then it specifies the encoding.
<ide> ## `fs.exists(path, callback)`
<ide> <!-- YAML
<ide> added: v0.0.2
<add>deprecated: v1.0.0
<ide> changes:
<ide> - version: v7.6.0
<ide> pr-url: https://github.com/nodejs/node/pull/10739
<ide> description: The `path` parameter can be a WHATWG `URL` object using
<ide> `file:` protocol. Support is currently still *experimental*.
<del>deprecated: v1.0.0
<ide> -->
<ide>
<ide> > Stability: 0 - Deprecated: Use [`fs.stat()`][] or [`fs.access()`][] instead.
<ide> Synchronous fdatasync(2). Returns `undefined`.
<ide> <!-- YAML
<ide> added: v0.1.95
<ide> changes:
<add> - version: v10.5.0
<add> pr-url: https://github.com/nodejs/node/pull/20220
<add> description: Accepts an additional `options` object to specify whether
<add> the numeric values returned should be bigint.
<ide> - version: v10.0.0
<ide> pr-url: https://github.com/nodejs/node/pull/12562
<ide> description: The `callback` parameter is no longer optional. Not passing
<ide> changes:
<ide> pr-url: https://github.com/nodejs/node/pull/7897
<ide> description: The `callback` parameter is no longer optional. Not passing
<ide> it will emit a deprecation warning with id DEP0013.
<del> - version: v10.5.0
<del> pr-url: https://github.com/nodejs/node/pull/20220
<del> description: Accepts an additional `options` object to specify whether
<del> the numeric values returned should be bigint.
<ide> -->
<ide>
<ide> * `fd` {integer}
<ide> Synchronous link(2). Returns `undefined`.
<ide> <!-- YAML
<ide> added: v0.1.30
<ide> changes:
<add> - version: v10.5.0
<add> pr-url: https://github.com/nodejs/node/pull/20220
<add> description: Accepts an additional `options` object to specify whether
<add> the numeric values returned should be bigint.
<ide> - version: v10.0.0
<ide> pr-url: https://github.com/nodejs/node/pull/12562
<ide> description: The `callback` parameter is no longer optional. Not passing
<ide> changes:
<ide> pr-url: https://github.com/nodejs/node/pull/7897
<ide> description: The `callback` parameter is no longer optional. Not passing
<ide> it will emit a deprecation warning with id DEP0013.
<del> - version: v10.5.0
<del> pr-url: https://github.com/nodejs/node/pull/20220
<del> description: Accepts an additional `options` object to specify whether
<del> the numeric values returned should be bigint.
<ide> -->
<ide>
<ide> * `path` {string|Buffer|URL}
<ide> not the file that it refers to.
<ide> <!-- YAML
<ide> added: v0.1.30
<ide> changes:
<del> - version: v7.6.0
<del> pr-url: https://github.com/nodejs/node/pull/10739
<del> description: The `path` parameter can be a WHATWG `URL` object using `file:`
<del> protocol. Support is currently still *experimental*.
<ide> - version: v10.5.0
<ide> pr-url: https://github.com/nodejs/node/pull/20220
<ide> description: Accepts an additional `options` object to specify whether
<ide> the numeric values returned should be bigint.
<add> - version: v7.6.0
<add> pr-url: https://github.com/nodejs/node/pull/10739
<add> description: The `path` parameter can be a WHATWG `URL` object using `file:`
<add> protocol. Support is currently still *experimental*.
<ide> -->
<ide>
<ide> * `path` {string|Buffer|URL}
<ide> utility). Returns `undefined`.
<ide> <!-- YAML
<ide> added: v0.0.2
<ide> changes:
<add> - version: v10.5.0
<add> pr-url: https://github.com/nodejs/node/pull/20220
<add> description: Accepts an additional `options` object to specify whether
<add> the numeric values returned should be bigint.
<ide> - version: v10.0.0
<ide> pr-url: https://github.com/nodejs/node/pull/12562
<ide> description: The `callback` parameter is no longer optional. Not passing
<ide> changes:
<ide> pr-url: https://github.com/nodejs/node/pull/7897
<ide> description: The `callback` parameter is no longer optional. Not passing
<ide> it will emit a deprecation warning with id DEP0013.
<del> - version: v10.5.0
<del> pr-url: https://github.com/nodejs/node/pull/20220
<del> description: Accepts an additional `options` object to specify whether
<del> the numeric values returned should be bigint.
<ide> -->
<ide>
<ide> * `path` {string|Buffer|URL}
<ide> Stats {
<ide> <!-- YAML
<ide> added: v0.1.21
<ide> changes:
<del> - version: v7.6.0
<del> pr-url: https://github.com/nodejs/node/pull/10739
<del> description: The `path` parameter can be a WHATWG `URL` object using `file:`
<del> protocol. Support is currently still *experimental*.
<ide> - version: v10.5.0
<ide> pr-url: https://github.com/nodejs/node/pull/20220
<ide> description: Accepts an additional `options` object to specify whether
<ide> the numeric values returned should be bigint.
<add> - version: v7.6.0
<add> pr-url: https://github.com/nodejs/node/pull/10739
<add> description: The `path` parameter can be a WHATWG `URL` object using `file:`
<add> protocol. Support is currently still *experimental*.
<ide> -->
<ide>
<ide> * `path` {string|Buffer|URL}
<ide> Synchronous stat(2).
<ide> <!-- YAML
<ide> added: v0.1.31
<ide> changes:
<add> - version: v12.0.0
<add> pr-url: https://github.com/nodejs/node/pull/23724
<add> description: If the `type` argument is left undefined, Node will autodetect
<add> `target` type and automatically select `dir` or `file`.
<ide> - version: v7.6.0
<ide> pr-url: https://github.com/nodejs/node/pull/10739
<ide> description: The `target` and `path` parameters can be WHATWG `URL` objects
<ide> using `file:` protocol. Support is currently still
<ide> *experimental*.
<del> - version: v12.0.0
<del> pr-url: https://github.com/nodejs/node/pull/23724
<del> description: If the `type` argument is left undefined, Node will autodetect
<del> `target` type and automatically select `dir` or `file`.
<ide> -->
<ide>
<ide> * `target` {string|Buffer|URL}
<ide> example/
<ide> <!-- YAML
<ide> added: v0.1.31
<ide> changes:
<add> - version: v12.0.0
<add> pr-url: https://github.com/nodejs/node/pull/23724
<add> description: If the `type` argument is left undefined, Node will autodetect
<add> `target` type and automatically select `dir` or `file`.
<ide> - version: v7.6.0
<ide> pr-url: https://github.com/nodejs/node/pull/10739
<ide> description: The `target` and `path` parameters can be WHATWG `URL` objects
<ide> using `file:` protocol. Support is currently still
<ide> *experimental*.
<del> - version: v12.0.0
<del> pr-url: https://github.com/nodejs/node/pull/23724
<del> description: If the `type` argument is left undefined, Node will autodetect
<del> `target` type and automatically select `dir` or `file`.
<ide> -->
<ide>
<ide> * `target` {string|Buffer|URL}
<ide><path>doc/api/http.md
<ide> not be emitted.
<ide> <!-- YAML
<ide> added: v0.1.94
<ide> changes:
<del> - version: v6.0.0
<del> pr-url: https://github.com/nodejs/node/pull/4557
<del> description: The default action of calling `.destroy()` on the `socket`
<del> will no longer take place if there are listeners attached
<del> for `'clientError'`.
<add> - version: v12.0.0
<add> pr-url: https://github.com/nodejs/node/pull/25605
<add> description: The default behavior will return a 431 Request Header
<add> Fields Too Large if a HPE_HEADER_OVERFLOW error occurs.
<ide> - version: v9.4.0
<ide> pr-url: https://github.com/nodejs/node/pull/17672
<ide> description: The `rawPacket` is the current buffer that just parsed. Adding
<ide> this buffer to the error object of `'clientError'` event is to
<ide> make it possible that developers can log the broken packet.
<del> - version: v12.0.0
<del> pr-url: https://github.com/nodejs/node/pull/25605
<del> description: The default behavior will return a 431 Request Header
<del> Fields Too Large if a HPE_HEADER_OVERFLOW error occurs.
<add> - version: v6.0.0
<add> pr-url: https://github.com/nodejs/node/pull/4557
<add> description: The default action of calling `.destroy()` on the `socket`
<add> will no longer take place if there are listeners attached
<add> for `'clientError'`.
<ide> -->
<ide>
<ide> * `exception` {Error}
<ide><path>doc/api/http2.md
<ide> changes:
<ide> pr-url: https://github.com/nodejs/node/pull/27782
<ide> description: The `options` parameter now supports `net.createServer()`
<ide> options.
<add> - version: v9.6.0
<add> pr-url: https://github.com/nodejs/node/pull/15752
<add> description: Added the `Http1IncomingMessage` and `Http1ServerResponse`
<add> option.
<ide> - version: v8.9.3
<ide> pr-url: https://github.com/nodejs/node/pull/17105
<ide> description: Added the `maxOutstandingPings` option with a default limit of
<ide> changes:
<ide> pr-url: https://github.com/nodejs/node/pull/16676
<ide> description: Added the `maxHeaderListPairs` option with a default limit of
<ide> 128 header pairs.
<del> - version: v9.6.0
<del> pr-url: https://github.com/nodejs/node/pull/15752
<del> description: Added the `Http1IncomingMessage` and `Http1ServerResponse`
<del> option.
<ide> -->
<ide>
<ide> * `options` {Object}
<ide><path>doc/api/https.md
<ide> separate module.
<ide> <!-- YAML
<ide> added: v0.4.5
<ide> changes:
<add> - version: v5.3.0
<add> pr-url: https://github.com/nodejs/node/pull/4252
<add> description: support `0` `maxCachedSessions` to disable TLS session caching.
<ide> - version: v2.5.0
<ide> pr-url: https://github.com/nodejs/node/pull/2228
<ide> description: parameter `maxCachedSessions` added to `options` for TLS
<ide> sessions reuse.
<del> - version: v5.3.0
<del> pr-url: https://github.com/nodejs/node/pull/4252
<del> description: support `0` `maxCachedSessions` to disable TLS session caching.
<ide> -->
<ide>
<ide> An [`Agent`][] object for HTTPS similar to [`http.Agent`][]. See
<ide><path>doc/api/packages.md
<ide> as ES modules and `.cjs` files are always treated as CommonJS.
<ide> added: v12.7.0
<ide> changes:
<ide> - version:
<del> - v13.2.0
<add> - v14.13.0
<add> pr-url: https://github.com/nodejs/node/pull/34718
<add> description: Add support for `"exports"` patterns.
<add> - version:
<add> - v13.7.0
<ide> - v12.16.0
<del> pr-url: https://github.com/nodejs/node/pull/29978
<del> description: Implement conditional exports.
<add> pr-url: https://github.com/nodejs/node/pull/31008
<add> description: Implement logical conditional exports ordering.
<ide> - version:
<ide> - v13.7.0
<ide> - v12.16.0
<ide> pr-url: https://github.com/nodejs/node/pull/31001
<ide> description: Remove the `--experimental-conditional-exports` option.
<ide> - version:
<del> - v13.7.0
<add> - v13.2.0
<ide> - v12.16.0
<del> pr-url: https://github.com/nodejs/node/pull/31008
<del> description: Implement logical conditional exports ordering.
<del> - version:
<del> - v14.13.0
<del> pr-url: https://github.com/nodejs/node/pull/34718
<del> description: Add support for `"exports"` patterns.
<add> pr-url: https://github.com/nodejs/node/pull/29978
<add> description: Implement conditional exports.
<ide> -->
<ide>
<ide> * Type: {Object} | {string} | {string[]}
<ide><path>doc/api/process.md
<ide> To get the version string without the prepended _v_, use
<ide> <!-- YAML
<ide> added: v0.2.0
<ide> changes:
<del> - version: v4.2.0
<del> pr-url: https://github.com/nodejs/node/pull/3102
<del> description: The `icu` property is now supported.
<ide> - version: v9.0.0
<ide> pr-url: https://github.com/nodejs/node/pull/15785
<ide> description: The `v8` property now includes a Node.js specific suffix.
<add> - version: v4.2.0
<add> pr-url: https://github.com/nodejs/node/pull/3102
<add> description: The `icu` property is now supported.
<ide> -->
<ide>
<ide> * {Object}
<ide><path>doc/api/stream.md
<ide> const cleanup = finished(rs, (err) => {
<ide> <!-- YAML
<ide> added: v10.0.0
<ide> changes:
<del> - version: v13.10.0
<del> pr-url: https://github.com/nodejs/node/pull/31223
<del> description: Add support for async generators.
<ide> - version: v14.0.0
<ide> pr-url: https://github.com/nodejs/node/pull/32158
<ide> description: The `pipeline(..., cb)` will wait for the `'close'` event
<ide> before invoking the callback. The implementation tries to
<ide> detect legacy streams and only apply this behavior to streams
<ide> which are expected to emit `'close'`.
<add> - version: v13.10.0
<add> pr-url: https://github.com/nodejs/node/pull/31223
<add> description: Add support for async generators.
<ide> -->
<ide>
<ide> * `streams` {Stream[]|Iterable[]|AsyncIterable[]|Function[]}
<ide> constructor and implement the [`readable._read()`][] method.
<ide> #### `new stream.Readable([options])`
<ide> <!-- YAML
<ide> changes:
<add> - version: v14.0.0
<add> pr-url: https://github.com/nodejs/node/pull/30623
<add> description: Change `autoDestroy` option default to `true`.
<ide> - version:
<ide> - v11.2.0
<ide> - v10.16.0
<ide> pr-url: https://github.com/nodejs/node/pull/22795
<ide> description: Add `autoDestroy` option to automatically `destroy()` the
<ide> stream when it emits `'end'` or errors.
<del> - version: v14.0.0
<del> pr-url: https://github.com/nodejs/node/pull/30623
<del> description: Change `autoDestroy` option default to `true`.
<ide> -->
<ide>
<ide> * `options` {Object}
<ide><path>doc/api/util.md
<ide> changes:
<ide> - version: v12.11.0
<ide> pr-url: https://github.com/nodejs/node/pull/29606
<ide> description: The `%c` specifier is ignored now.
<del> - version: v11.4.0
<del> pr-url: https://github.com/nodejs/node/pull/23708
<del> description: The `%d`, `%f` and `%i` specifiers now support Symbols
<del> properly.
<ide> - version: v12.0.0
<ide> pr-url: https://github.com/nodejs/node/pull/23162
<ide> description: The `format` argument is now only taken as such if it actually
<ide> changes:
<ide> first argument. This change removes previously present quotes
<ide> from strings that were being output when the first argument
<ide> was not a string.
<add> - version: v11.4.0
<add> pr-url: https://github.com/nodejs/node/pull/23708
<add> description: The `%d`, `%f` and `%i` specifiers now support Symbols
<add> properly.
<ide> - version: v11.4.0
<ide> pr-url: https://github.com/nodejs/node/pull/24806
<ide> description: The `%o` specifier's `depth` has default depth of 4 again.
<ide> changes:
<ide> pr-url: https://github.com/nodejs/node/pull/27109
<ide> description: The `compact` options default is changed to `3` and the
<ide> `breakLength` options default is changed to `80`.
<del> - version: v11.11.0
<del> pr-url: https://github.com/nodejs/node/pull/26269
<del> description: The `compact` option accepts numbers for a new output mode.
<ide> - version: v12.0.0
<ide> pr-url: https://github.com/nodejs/node/pull/24971
<ide> description: Internal properties no longer appear in the context argument
<ide> of a custom inspection function.
<add> - version: v11.11.0
<add> pr-url: https://github.com/nodejs/node/pull/26269
<add> description: The `compact` option accepts numbers for a new output mode.
<ide> - version: v11.7.0
<ide> pr-url: https://github.com/nodejs/node/pull/25006
<ide> description: ArrayBuffers now also show their binary contents.
<ide> changes:
<ide> - version: v11.0.0
<ide> pr-url: https://github.com/nodejs/node/pull/22846
<ide> description: The `depth` default changed to `20`.
<del> - version: v10.12.0
<del> pr-url: https://github.com/nodejs/node/pull/22788
<del> description: The `sorted` option is supported now.
<ide> - version: v11.0.0
<ide> pr-url: https://github.com/nodejs/node/pull/22756
<ide> description: The inspection output is now limited to about 128 MB. Data
<ide> above that size will not be fully inspected.
<add> - version: v10.12.0
<add> pr-url: https://github.com/nodejs/node/pull/22788
<add> description: The `sorted` option is supported now.
<ide> - version: v10.6.0
<ide> pr-url: https://github.com/nodejs/node/pull/20725
<ide> description: Inspecting linked lists and similar objects is now possible
<ide><path>doc/api/v8.md
<ide> stream.pipe(process.stdout);
<ide> <!-- YAML
<ide> added: v1.0.0
<ide> changes:
<add> - version: v7.5.0
<add> pr-url: https://github.com/nodejs/node/pull/10186
<add> description: Support values exceeding the 32-bit unsigned integer range.
<ide> - version: v7.2.0
<ide> pr-url: https://github.com/nodejs/node/pull/8610
<ide> description: Added `malloced_memory`, `peak_malloced_memory`,
<ide> and `does_zap_garbage`.
<del> - version: v7.5.0
<del> pr-url: https://github.com/nodejs/node/pull/10186
<del> description: Support values exceeding the 32-bit unsigned integer range.
<ide> -->
<ide>
<ide> * Returns: {Object}
<ide><path>doc/api/vm.md
<ide> executed in specific contexts.
<ide> <!-- YAML
<ide> added: v0.3.1
<ide> changes:
<del> - version: v5.7.0
<del> pr-url: https://github.com/nodejs/node/pull/4777
<del> description: The `cachedData` and `produceCachedData` options are
<del> supported now.
<ide> - version: v10.6.0
<ide> pr-url: https://github.com/nodejs/node/pull/20300
<ide> description: The `produceCachedData` is deprecated in favour of
<ide> `script.createCachedData()`.
<add> - version: v5.7.0
<add> pr-url: https://github.com/nodejs/node/pull/4777
<add> description: The `cachedData` and `produceCachedData` options are
<add> supported now.
<ide> -->
<ide>
<ide> * `code` {string} The JavaScript code to compile.
<ide> const vm = require('vm');
<ide> <!-- YAML
<ide> added: v10.10.0
<ide> changes:
<add> - version: v14.3.0
<add> pr-url: https://github.com/nodejs/node/pull/33364
<add> description: Removal of `importModuleDynamically` due to compatibility
<add> issues.
<ide> - version:
<ide> - v14.1.0
<ide> - v13.14.0
<ide> pr-url: https://github.com/nodejs/node/pull/32985
<ide> description: The `importModuleDynamically` option is now supported.
<del> - version: v14.3.0
<del> pr-url: https://github.com/nodejs/node/pull/33364
<del> description: Removal of `importModuleDynamically` due to compatibility
<del> issues.
<ide> -->
<ide>
<ide> * `code` {string} The body of the function to compile.
<ide><path>doc/api/worker_threads.md
<ide> changes:
<ide> pr-url: https://github.com/nodejs/node/pull/31664
<ide> description: The `filename` parameter can be a WHATWG `URL` object using
<ide> `file:` protocol.
<del> - version:
<del> - v13.2.0
<del> - v12.16.0
<del> pr-url: https://github.com/nodejs/node/pull/26628
<del> description: The `resourceLimits` option was introduced.
<ide> - version:
<ide> - v13.4.0
<ide> - v12.16.0
<ide> pr-url: https://github.com/nodejs/node/pull/30559
<ide> description: The `argv` option was introduced.
<add> - version:
<add> - v13.2.0
<add> - v12.16.0
<add> pr-url: https://github.com/nodejs/node/pull/26628
<add> description: The `resourceLimits` option was introduced.
<ide> -->
<ide>
<ide> * `filename` {string|URL} The path to the Worker’s main script or module. Must | 13 |
Javascript | Javascript | update node snippets | 911722fa6eb9f2e503e8f564406adb9634bc4fc0 | <ide><path>examples/jsm/renderers/webgpu/ShaderLib.js
<ide> const ShaderLib = {
<ide> layout(set = 0, binding = 3) uniform sampler mySampler;
<ide> layout(set = 0, binding = 4) uniform texture2D myTexture;
<ide>
<add> #ifdef NODE_UNIFORMS
<add>
<add> layout(set = 0, binding = 5) uniform NodeUniforms {
<add> NODE_UNIFORMS
<add> } nodeUniforms;
<add>
<add> #endif
<add>
<ide> layout(location = 0) in vec2 vUv;
<ide> layout(location = 0) out vec4 outColor;
<ide>
<ide> void main() {
<add>
<ide> outColor = texture( sampler2D( myTexture, mySampler ), vUv );
<add>
<add> #ifdef NODE_COLOR
<add>
<add> /* NODE_COLOR_CODE ignore (node code group) for now */
<add> outColor.rgb *= NODE_COLOR;
<add>
<add> #endif
<add>
<add> #ifdef NODE_OPACITY
<add>
<add> outColor.a *= NODE_OPACITY;
<add>
<add> #endif
<add>
<ide> outColor.a *= opacityUniforms.opacity;
<add>
<ide> }`
<ide> },
<ide> pointsBasic: {
<ide> const ShaderLib = {
<ide>
<ide> layout(location = 0) out vec4 outColor;
<ide>
<add> #ifdef NODE_UNIFORMS
<add>
<add> layout(set = 0, binding = 2) uniform NodeUniforms {
<add> NODE_UNIFORMS
<add> } nodeUniforms;
<add>
<add> #endif
<add>
<ide> void main() {
<add>
<ide> outColor = vec4( 1.0, 0.0, 0.0, 1.0 );
<add>
<add> #ifdef NODE_COLOR
<add>
<add> outColor.rgb = NODE_COLOR;
<add>
<add> #endif
<add>
<add> #ifdef NODE_OPACITY
<add>
<add> outColor.a *= NODE_OPACITY;
<add>
<add> #endif
<add>
<ide> }`
<ide> },
<ide> lineBasic: { | 1 |
Text | Text | add readme information | 2c1d5564ad8e7d937bccf500a12e95423f4b6545 | <ide><path>examples/README.md
<ide> similar API between the different models.
<ide>
<ide> | Section | Description |
<ide> |----------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
<add>| [TensorFlow 2.0 models on GLUE](#TensorFlow-2.0-Bert-models-on-GLUE) | Examples running BERT TensorFlow 2.0 model on the GLUE tasks.
<ide> | [Language Model fine-tuning](#language-model-fine-tuning) | Fine-tuning the library models for language modeling on a text dataset. Causal language modeling for GPT/GPT-2, masked language modeling for BERT/RoBERTa. |
<ide> | [Language Generation](#language-generation) | Conditional text generation using the auto-regressive models of the library: GPT, GPT-2, Transformer-XL and XLNet. |
<ide> | [GLUE](#glue) | Examples running BERT/XLM/XLNet/RoBERTa on the 9 GLUE tasks. Examples feature distributed training as well as half-precision. |
<ide> | [SQuAD](#squad) | Using BERT for question answering, examples with distributed training. |
<ide> | [Multiple Choice](#multiple-choice) | Examples running BERT/XLNet/RoBERTa on the SWAG/RACE/ARC tasks.
<ide>
<add>## TensorFlow 2.0 Bert models on GLUE
<add>
<add>Based on the script [`run_tf_glue.py`](https://github.com/huggingface/transformers/blob/master/examples/run_tf_glue.py).
<add>
<add>Fine-tuning the library TensorFlow 2.0 Bert model for sequence classification on the MRPC task of the GLUE benchmark: [General Language Understanding Evaluation](https://gluebenchmark.com/).
<add>
<add>This script has an option for mixed precision (Automatic Mixed Precision / AMP) to run models on Tensor Cores (NVIDIA Volta/Turing GPUs) and future hardware and an option for XLA, which uses the XLA compiler to reduce model runtime.
<add>Options are toggled using `USE_XLA` or `USE_AMP` variables in the script.
<add>These options and the below benchmark are provided by @tlkh.
<add>
<add>Quick benchmarks from the script (no other modifications):
<add>
<add>| GPU | Mode | Time (2nd epoch) | Val Acc (3 runs) |
<add>| --------- | -------- | ----------------------- | ----------------------|
<add>| Titan V | FP32 | 41s | 0.8438/0.8281/0.8333 |
<add>| Titan V | AMP | 26s | 0.8281/0.8568/0.8411 |
<add>| V100 | FP32 | 35s | 0.8646/0.8359/0.8464 |
<add>| V100 | AMP | 22s | 0.8646/0.8385/0.8411 |
<add>| 1080 Ti | FP32 | 55s | - |
<add>
<add>Mixed precision (AMP) reduces the training time considerably for the same hardware and hyper-parameters (same batch size was used).
<add>
<ide> ## Language model fine-tuning
<ide>
<ide> Based on the script [`run_lm_finetuning.py`](https://github.com/huggingface/transformers/blob/master/examples/run_lm_finetuning.py). | 1 |
Text | Text | fix changelog typo [ci skip] | 04907b64ac26ad033bcafc2b036a77a68fa64b22 | <ide><path>actionpack/CHANGELOG.md
<ide> Example:
<ide>
<ide> url_for [:new, :admin, :post, { param: 'value' }]
<del> # => http://example.com/admin/posts/new?params=value
<add> # => http://example.com/admin/posts/new?param=value
<ide>
<ide> *Andrey Ognevsky*
<ide> | 1 |
Javascript | Javascript | remove the chrome stringification hack | 813117da31bfc8731e8af26336915e29878b4294 | <ide><path>src/auto/injector.js
<ide> var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
<ide> var $injectorMinErr = minErr('$injector');
<ide>
<ide> function stringifyFn(fn) {
<del> // Support: Chrome 50-51 only
<del> // Creating a new string by adding `' '` at the end, to hack around some bug in Chrome v50/51
<del> // (See https://github.com/angular/angular.js/issues/14487.)
<del> // TODO (gkalpak): Remove workaround when Chrome v52 is released
<del> return Function.prototype.toString.call(fn) + ' ';
<add> return Function.prototype.toString.call(fn);
<ide> }
<ide>
<ide> function extractArgs(fn) {
<ide><path>test/auto/injectorSpec.js
<ide> describe('injector', function() {
<ide> // eslint-disable-next-line no-eval
<ide> expect(annotate(eval('a => b => b'))).toEqual(['a']);
<ide> });
<del>
<del> // Support: Chrome 50-51 only
<del> // TODO (gkalpak): Remove when Chrome v52 is released.
<del> // it('should be able to inject fat-arrow function', function() {
<del> // inject(($injector) => {
<del> // expect($injector).toBeDefined();
<del> // });
<del> // });
<ide> }
<ide>
<ide> if (support.classes) {
<ide> describe('injector', function() {
<ide> expect(instance).toEqual(jasmine.any(Clazz));
<ide> });
<ide> }
<del>
<del> // Support: Chrome 50-51 only
<del> // TODO (gkalpak): Remove when Chrome v52 is released.
<del> // it('should be able to invoke classes', function() {
<del> // class Test {
<del> // constructor($injector) {
<del> // this.$injector = $injector;
<del> // }
<del> // }
<del> // var instance = injector.invoke(Test, null, null, 'Test');
<del>
<del> // expect(instance.$injector).toBe(injector);
<del> // });
<ide> }
<ide> });
<ide> | 2 |
Ruby | Ruby | enforce https for bare bintray.com domain | 1b5fc1fb02691f0868f855443f1393568fe2b465 | <ide><path>Library/Homebrew/cmd/audit.rb
<ide> def audit_urls
<ide> problem "Fossies urls should be https://, not http (url is #{p})."
<ide> when %r[^http://mirrors\.kernel\.org/]
<ide> problem "mirrors.kernel urls should be https://, not http (url is #{p})."
<del> when %r[^http://[^/]*\.bintray\.com/]
<add> when %r[^http://([^/]*\.|)bintray\.com/]
<ide> problem "Bintray urls should be https://, not http (url is #{p})."
<ide> when %r[^http://tools\.ietf\.org/]
<ide> problem "ietf urls should be https://, not http (url is #{p})." | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.