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
Text
Text
translate 02.3-jsx-gotchas.md to japanese
19e1d11d2fe35976686f8084e4cbc893cac8ebc5
<ide><path>docs/docs/02.3-jsx-gotchas.ja-JP.md <add>--- <add>id: jsx-gotchas <add>title: JSXใฎ็†่งฃ <add>permalink: jsx-gotchas-ja-JP.html <add>prev: jsx-spread-ja-JP.html <add>next: interactivity-and-dynamic-uis-ja-JP.html <add> <add>--- <add> <add>JSXใฏHTMLใซไผผใฆใ„ใพใ™ใŒใ€้‡่ฆใช้•ใ„ใŒใ„ใใคใ‹ใ‚ใ‚Šใพใ™ใ€‚ <add> <add>> ๆณจๆ„: <add>> ใ‚คใƒณใƒฉใ‚คใƒณใฎ `style` ๅฑžๆ€งใฎใ‚ˆใ†ใชDOMใฎ้•ใ„ใซใคใ„ใฆใฏใ€[ใ“ใกใ‚‰](/react/docs/dom-differences.html)ใ‚’็ขบ่ชใ—ใฆใใ ใ•ใ„ใ€‚ <add> <add>## HTMLใฎใ‚จใƒณใƒ†ใ‚ฃใƒ†ใ‚ฃ <add> <add>ไปฅไธ‹ใฎใ‚ˆใ†ใซใ€JSXใฎๆ–‡ๅญ—ใฎใƒ†ใ‚ญใ‚นใƒˆใฎไธญใซHTMLใฎใ‚จใƒณใƒ†ใ‚ฃใƒ†ใ‚ฃใ‚’ๆŒฟๅ…ฅใ™ใ‚‹ใ“ใจใŒใงใใพใ™ใ€‚ <add> <add>```javascript <add><div>First &middot; Second</div> <add>``` <add> <add>ๅ‹•็š„ใชใ‚ณใƒณใƒ†ใƒณใƒ„ใจใ—ใฆHTMLใฎใ‚จใƒณใƒ†ใ‚ฃใƒ†ใ‚ฃใ‚’่กจ็คบใ™ใ‚‹้š›ใซใ€ใƒ€ใƒ–ใƒซใ‚จใ‚นใ‚ฑใƒผใƒ—ใ‚’ๆ›ธใ„ใฆใ—ใพใ†ใ“ใจใŒใ‚ใ‚‹ใ‹ใจๆ€ใ„ใพใ™ใŒใ€Reactใฏใƒ‡ใƒ•ใ‚ฉใƒซใƒˆใงๅบƒใ„็ฏ„ๅ›ฒใฎXSSๆ”ปๆ’ƒใ‚’้˜ฒใใŸใ‚ใซ่กจ็คบใ—ใ‚ˆใ†ใจใ—ใฆใ„ใ‚‹ๅ…จใฆใฎๆ–‡ๅญ—ๅˆ—ใ‚’ใ‚จใ‚นใ‚ฑใƒผใƒ—ใ—ใพใ™ใ€‚ <add> <add>```javascript <add>// ๆ‚ชใ„ไพ‹: ไปฅไธ‹ใฏ "First &middot; Second" ใ‚’่กจ็คบใ—ใพใ™ใ€‚ <add><div>{'First &middot; Second'}</div> <add>``` <add> <add>ใ“ใฎๅ•้กŒใ‚’้˜ฒๆญขใ™ใ‚‹ใŸใ‚ใซใฏใ„ใใคใ‹ใฎๆ–นๆณ•ใŒใ‚ใ‚Šใพใ™ใ€‚ๆœ€ใ‚‚็ฐกๅ˜ใชๆ–นๆณ•ใฏใ€unicodeใฎๆ–‡ๅญ—ใ‚’็›ดใงJavaScriptใซ่จ˜่ฟฐใ™ใ‚‹ๆ–นๆณ•ใงใ™ใ€‚ใใฎ้š›ใซใฏใ€ใƒ•ใ‚กใ‚คใƒซใŒUTF-8ใงไฟๅญ˜ใ•ใ‚Œใฆใ„ใ‚‹ใ“ใจใจใ€ใƒ–ใƒฉใ‚ฆใ‚ถใŒๆญฃใ—ใ่กจ็คบใงใใ‚‹ใ‚ˆใ†ใซใ€UTF-8ใง่กจ็คบใ™ใ‚‹ๅ‘ฝไปคใŒๆญฃใ—ใใ‚ปใƒƒใƒˆใ•ใ‚Œใฆใ„ใ‚‹ใ“ใจใ‚’็ขบ่ชใ—ใฆใใ ใ•ใ„ใ€‚ <add> <add>```javascript <add><div>{'First ยท Second'}</div> <add>``` <add> <add>ใ•ใ‚‰ใซๅฎ‰ๅ…จใชไปฃๆ›ฟใฎๆ–นๆณ•ใฏใ€[ใ‚จใƒณใƒ†ใ‚ฃใƒ†ใ‚ฃใซๅฏพๅฟœใ™ใ‚‹unicodeใฎๆ•ฐๅ€ค](http://www.fileformat.info/info/unicode/char/b7/index.htm)ใ‚’่ฆ‹ใคใ‘ใฆใ€JavaScriptใฎๆ–‡ๅญ—ๅˆ—ใฎไธญใงใใ‚Œใ‚’ไฝฟใ†ใ“ใจใงใ™ใ€‚ <add> <add>```javascript <add><div>{'First \u00b7 Second'}</div> <add><div>{'First ' + String.fromCharCode(183) + ' Second'}</div> <add>``` <add> <add>้…ๅˆ—ใจๆ–‡ๅญ—ๅˆ—ใจJSXใฎ่ฆ็ด ใ‚’ๆททใœใฆไฝฟใ†ใ“ใจใ‚‚ใงใใพใ™ใ€‚ <add> <add>```javascript <add><div>{['First ', <span>&middot;</span>, ' Second']}</div> <add>``` <add> <add>ๆœ€ๅพŒใฎๆ‰‹ๆฎตใจใ—ใฆใ€ๅธธใซ[็”ŸใฎHTMLใ‚’ๆŒฟๅ…ฅ](/react/tips/dangerously-set-inner-html.html)ใ™ใ‚‹ใ“ใจใ‚‚ใงใใพใ™ใ€‚ <add> <add>```javascript <add><div dangerouslySetInnerHTML={{'{{'}}__html: 'First &middot; Second'}} /> <add>``` <add> <add> <add>## ใ‚ซใ‚นใ‚ฟใƒ ใ•ใ‚ŒใŸHTMLใฎๅฑžๆ€ง <add> <add>HTMLใฎไป•ๆง˜ๆ›ธใซๅญ˜ๅœจใ—ใชใ„่ฆ็ด ใ‚’ใƒใ‚คใƒ†ใ‚ฃใƒ–ใชHTML่ฆ็ด ใซๆธกใ—ใŸๅ ดๅˆใฏใ€Reactใฏใใ‚Œใ‚‰ใ‚’ใƒฌใƒณใƒ€ใƒชใƒณใ‚ฐใ—ใพใ›ใ‚“ใ€‚ใ‚ซใ‚นใ‚ฟใƒ ใ—ใŸๅฑžๆ€งใ‚’ไฝฟใ†ๅ ดๅˆใฏใ€ `data-` ใ‚’้ ญใซใคใ‘ใฆใใ ใ•ใ„ใ€‚ <add> <add>```javascript <add><div data-custom-attribute="foo" /> <add>``` <add> <add>`aria-` ใ‹ใ‚‰ๅง‹ใพใ‚‹[Webใ‚ขใ‚ฏใ‚ปใ‚ทใƒ“ใƒชใƒ†ใ‚ฃ](http://www.w3.org/WAI/intro/aria)ๅฑžๆ€งใฏใƒ—ใƒญใƒ‘ใƒ†ใ‚ฃใ‚’ใƒฌใƒณใƒ€ใƒชใƒณใ‚ฐใ—ใพใ™ใ€‚ <add> <add>```javascript <add><div aria-hidden={true} /> <add>```
1
Text
Text
add jasongin & kunalspathak to collaborators
f5df94bf78edbf71a2fae98b8ca1ba7eb0597d9b
<ide><path>README.md <ide> more information about the governance of the Node.js project, see <ide> **Italo A. Casas** &lt;[email protected]&gt; (he/him) <ide> * [JacksonTian](https://github.com/JacksonTian) - <ide> **Jackson Tian** &lt;[email protected]&gt; <add>* [jasongin](https://github.com/jasongin) - <add>**Jason Ginchereau** &lt;[email protected]&gt; <ide> * [jbergstroem](https://github.com/jbergstroem) - <ide> **Johan Bergstrรถm** &lt;[email protected]&gt; <ide> * [jhamhader](https://github.com/jhamhader) - <ide> more information about the governance of the Node.js project, see <ide> **Julian Duque** &lt;[email protected]&gt; (he/him) <ide> * [JungMinu](https://github.com/JungMinu) - <ide> **Minwoo Jung** &lt;[email protected]&gt; (he/him) <add>* [kunalspathak](https://github.com/kunalspathak) - <add>**Kunal Pathak** &lt;[email protected]&gt; <ide> * [lance](https://github.com/lance) - <ide> **Lance Ball** &lt;[email protected]&gt; <ide> * [lpinca](https://github.com/lpinca) -
1
Javascript
Javascript
remove dag implementation
cfe3dbf4bdbfb62d0256f3cb55efefe2ed19aa37
<ide><path>packages/ember-application/lib/system/dag.js <del>import EmberError from "ember-metal/error"; <del> <del>function visit(vertex, fn, visited, path) { <del> var name = vertex.name; <del> var vertices = vertex.incoming; <del> var names = vertex.incomingNames; <del> var len = names.length; <del> var i; <del> <del> if (!visited) { <del> visited = {}; <del> } <del> if (!path) { <del> path = []; <del> } <del> if (visited.hasOwnProperty(name)) { <del> return; <del> } <del> path.push(name); <del> visited[name] = true; <del> for (i = 0; i < len; i++) { <del> visit(vertices[names[i]], fn, visited, path); <del> } <del> fn(vertex, path); <del> path.pop(); <del>} <del> <del> <del>/** <del> * DAG stands for Directed acyclic graph. <del> * <del> * It is used to build a graph of dependencies checking that there isn't circular <del> * dependencies. p.e Registering initializers with a certain precedence order. <del> * <del> * @class DAG <del> * @constructor <del> */ <del>function DAG() { <del> this.names = []; <del> this.vertices = Object.create(null); <del>} <del> <del>/** <del> * DAG Vertex <del> * <del> * @class Vertex <del> * @constructor <del> */ <del> <del>function Vertex(name) { <del> this.name = name; <del> this.incoming = {}; <del> this.incomingNames = []; <del> this.hasOutgoing = false; <del> this.value = null; <del>} <del> <del>/** <del> * Adds a vertex entry to the graph unless it is already added. <del> * <del> * @private <del> * @method add <del> * @param {String} name The name of the vertex to add <del> */ <del>DAG.prototype.add = function(name) { <del> if (!name) { <del> throw new Error("Can't add Vertex without name"); <del> } <del> if (this.vertices[name] !== undefined) { <del> return this.vertices[name]; <del> } <del> var vertex = new Vertex(name); <del> this.vertices[name] = vertex; <del> this.names.push(name); <del> return vertex; <del>}; <del> <del>/** <del> * Adds a vertex to the graph and sets its value. <del> * <del> * @private <del> * @method map <del> * @param {String} name The name of the vertex. <del> * @param value The value to put in the vertex. <del> */ <del>DAG.prototype.map = function(name, value) { <del> this.add(name).value = value; <del>}; <del> <del>/** <del> * Connects the vertices with the given names, adding them to the graph if <del> * necessary, only if this does not produce is any circular dependency. <del> * <del> * @private <del> * @method addEdge <del> * @param {String} fromName The name the vertex where the edge starts. <del> * @param {String} toName The name the vertex where the edge ends. <del> */ <del>DAG.prototype.addEdge = function(fromName, toName) { <del> if (!fromName || !toName || fromName === toName) { <del> return; <del> } <del> var from = this.add(fromName); <del> var to = this.add(toName); <del> if (to.incoming.hasOwnProperty(fromName)) { <del> return; <del> } <del> function checkCycle(vertex, path) { <del> if (vertex.name === toName) { <del> throw new EmberError("cycle detected: " + toName + " <- " + path.join(" <- ")); <del> } <del> } <del> visit(from, checkCycle); <del> from.hasOutgoing = true; <del> to.incoming[fromName] = from; <del> to.incomingNames.push(fromName); <del>}; <del> <del>/** <del> * Visits all the vertex of the graph calling the given function with each one, <del> * ensuring that the vertices are visited respecting their precedence. <del> * <del> * @method topsort <del> * @param {Function} fn The function to be invoked on each vertex. <del> */ <del>DAG.prototype.topsort = function(fn) { <del> var visited = {}; <del> var vertices = this.vertices; <del> var names = this.names; <del> var len = names.length; <del> var i, vertex; <del> <del> for (i = 0; i < len; i++) { <del> vertex = vertices[names[i]]; <del> if (!vertex.hasOutgoing) { <del> visit(vertex, fn, visited); <del> } <del> } <del>}; <del> <del>/** <del> * Adds a vertex with the given name and value to the graph and joins it with the <del> * vertices referenced in _before_ and _after_. If there isn't vertices with those <del> * names, they are added too. <del> * <del> * If either _before_ or _after_ are falsy/empty, the added vertex will not have <del> * an incoming/outgoing edge. <del> * <del> * @method addEdges <del> * @param {String} name The name of the vertex to be added. <del> * @param value The value of that vertex. <del> * @param before An string or array of strings with the names of the vertices before <del> * which this vertex must be visited. <del> * @param after An string or array of strings with the names of the vertex after <del> * which this vertex must be visited. <del> * <del> */ <del>DAG.prototype.addEdges = function(name, value, before, after) { <del> var i; <del> this.map(name, value); <del> if (before) { <del> if (typeof before === 'string') { <del> this.addEdge(name, before); <del> } else { <del> for (i = 0; i < before.length; i++) { <del> this.addEdge(name, before[i]); <del> } <del> } <del> } <del> if (after) { <del> if (typeof after === 'string') { <del> this.addEdge(after, name); <del> } else { <del> for (i = 0; i < after.length; i++) { <del> this.addEdge(after[i], name); <del> } <del> } <del> } <del>}; <del> <del>export default DAG;
1
Mixed
Ruby
remove deprecated `serialized_attributes`
82043ab53cb186d59b1b3be06122861758f814b2
<ide><path>activerecord/CHANGELOG.md <add>* Remove deprecated `serialized_attributes`. <add> <add> *Rafael Mendonรงa Franรงa* <add> <ide> * Remove deprecated automatic counter caches on `has_many :through`. <ide> <ide> *Rafael Mendonรงa Franรงa* <ide><path>activerecord/lib/active_record/attribute_methods/serialization.rb <ide> def serialize(attr_name, class_name_or_coder = Object) <ide> Type::Serialized.new(type, coder) <ide> end <ide> end <del> <del> def serialized_attributes <del> ActiveSupport::Deprecation.warn(<<-MSG.squish) <del> `serialized_attributes` is deprecated without replacement, and will <del> be removed in Rails 5.0. <del> MSG <del> <del> @serialized_attributes ||= Hash[ <del> columns.select { |t| t.cast_type.is_a?(Type::Serialized) }.map { |c| <del> [c.name, c.cast_type.coder] <del> } <del> ] <del> end <ide> end <ide> end <ide> end <ide><path>activerecord/test/cases/serialized_attribute_test.rb <ide> def test_serialize_does_not_eagerly_load_columns <ide> end <ide> end <ide> <del> def test_list_of_serialized_attributes <del> assert_deprecated do <del> assert_equal %w(content), Topic.serialized_attributes.keys <del> end <del> end <del> <ide> def test_serialized_attribute <ide> Topic.serialize("content", MyObject) <ide>
3
PHP
PHP
use types consistently
bbcddb3f7146686eb96e64d511a0788101da2abd
<ide><path>src/Console/Command/Task/ModelTask.php <ide> public function getBehaviors($model) { <ide> return []; <ide> } <ide> if (in_array('created', $fields) || in_array('modified', $fields)) { <del> $behaviors['Timestamp'] = ''; <add> $behaviors['Timestamp'] = []; <ide> } <ide> <ide> if (in_array('lft', $fields) && $schema->columnType('lft') === 'integer' && <ide> in_array('rght', $fields) && $schema->columnType('rght') === 'integer' && <ide> in_array('parent_id', $fields) <ide> ) { <del> $behaviors['Tree'] = ''; <add> $behaviors['Tree'] = []; <ide> } <ide> <ide> $counterCache = []; <ide><path>tests/TestCase/Console/Command/Task/ModelTaskTest.php <ide> public function testGetValidation() { <ide> public function testGetBehaviors() { <ide> $model = TableRegistry::get('NumberTrees'); <ide> $result = $this->Task->getBehaviors($model); <del> $this->assertEquals(['Tree' => ''], $result); <add> $this->assertEquals(['Tree' => []], $result); <ide> <ide> $model = TableRegistry::get('BakeArticles'); <ide> $result = $this->Task->getBehaviors($model); <del> $this->assertEquals(['Timestamp' => ''], $result); <add> $this->assertEquals(['Timestamp' => []], $result); <ide> <ide> $model = TableRegistry::get('CounterCacheUsers'); <ide> $result = $this->Task->getBehaviors($model);
2
Python
Python
update some note comments in numpy.array_api
7ed0189477ed4a7d2907d0728b3b8121722d8a2f
<ide><path>numpy/array_api/_array_object.py <ide> def _promote_scalar(self, scalar): <ide> integer that is too large to fit in a NumPy integer dtype, or <ide> TypeError when the scalar type is incompatible with the dtype of self. <ide> """ <add> # Note: Only Python scalar types that match the array dtype are <add> # allowed. <ide> if isinstance(scalar, bool): <ide> if self.dtype not in _boolean_dtypes: <ide> raise TypeError( <ide> def _promote_scalar(self, scalar): <ide> else: <ide> raise TypeError("'scalar' must be a Python scalar") <ide> <add> # Note: scalars are unconditionally cast to the same dtype as the <add> # array. <add> <ide> # Note: the spec only specifies integer-dtype/int promotion <ide> # behavior for integers within the bounds of the integer dtype. <ide> # Outside of those bounds we use the default NumPy behavior (either <ide><path>numpy/array_api/_data_type_functions.py <ide> def can_cast(from_: Union[Dtype, Array], to: Dtype, /) -> bool: <ide> raise TypeError(f"{from_=}, but should be an array_api array or dtype") <ide> if to not in _all_dtypes: <ide> raise TypeError(f"{to=}, but should be a dtype") <del> # Note: We avoid np.can_cast() as it has discrepancies with the array API. <add> # Note: We avoid np.can_cast() as it has discrepancies with the array API, <add> # since NumPy allows cross-kind casting (e.g., NumPy allows bool -> int8). <ide> # See https://github.com/numpy/numpy/issues/20870 <ide> try: <ide> # We promote `from_` and `to` together. We then check if the promoted
2
Go
Go
add riscv64 build tags
75bc82fe5c6351430e495ea1312803ea2b81b623
<add><path>libnetwork/drivers/bridge/netlink_deprecated_linux_rawsockaddr_data_int8.go <del><path>libnetwork/drivers/bridge/netlink_deprecated_linux_notarm.go <del>// +build !arm,!ppc64,!ppc64le <add>// +build !arm,!ppc64,!ppc64le,!riscv64 <ide> <ide> package bridge <ide> <add><path>libnetwork/drivers/bridge/netlink_deprecated_linux_rawsockaddr_data_uint8.go <del><path>libnetwork/drivers/bridge/netlink_deprecated_linux_armppc64.go <del>// +build arm ppc64 ppc64le <add>// +build arm ppc64 ppc64le riscv64 <ide> <ide> package bridge <ide>
2
PHP
PHP
remove a default helper from view
229c824da66a33dda7fe4aa3e8fe6e08e92a2c0d
<ide><path>lib/Cake/Test/Case/View/HelperTest.php <ide> public function testThatHelperHelpersAreNotAttached() { <ide> $Helper->OtherHelper; <ide> <ide> $result = $this->View->Helpers->enabled(); <del> $expected = array('Html'); <del> $this->assertEquals($expected, $result, 'Helper helpers were attached to the collection.'); <add> $this->assertEquals(array(), $result, 'Helper helpers were attached to the collection.'); <ide> } <ide> <ide> /** <ide><path>lib/Cake/View/View.php <ide> class View extends Object { <ide> * <ide> * @var mixed A single name as a string or a list of names as an array. <ide> */ <del> public $helpers = array('Html'); <add> public $helpers = array(); <ide> <ide> /** <ide> * Path to View.
2
Mixed
Text
allow use of minitest-rails gem with test runner
9ebda29135acde842e180169c69ce07076bbdd6b
<ide><path>railties/CHANGELOG.md <add>* Allow use of minitest-rails gem with Rails test runner. <add> <add> Fixes #22455. <add> <add> *Chris Kottom* <add> <ide> * Add `bin/test` script to rails plugin. <ide> <ide> `bin/test` can use the same API as `bin/rails test`. <ide><path>railties/lib/rails/test_unit/minitest_plugin.rb <ide> def aggregated_results <ide> SummaryReporter.prepend AggregatedResultSuppresion <ide> <ide> def self.plugin_rails_options(opts, options) <del> executable = Rails::TestUnitReporter.executable <add> executable = ::Rails::TestUnitReporter.executable <ide> opts.separator "" <ide> opts.separator "Usage: #{executable} [options] [files or directories]" <ide> opts.separator "You can run a single test by appending a line number to a filename:"
2
Javascript
Javascript
add quicksuggestions false to editor options
9e01ead291746c00e7f996ad85ece23f579307df
<ide><path>client/src/templates/Challenges/classic/Editor.js <ide> class Editor extends Component { <ide> dragAndDrop: true, <ide> lightbulb: { <ide> enabled: false <del> } <add> }, <add> quickSuggestions: false <ide> }; <ide> <ide> this._editor = null;
1
Python
Python
add example for shortcircuitoperator
f9f94672c12a138e0c6ee89f62e96eec7bcb3432
<ide><path>airflow/example_dags/example_short_circuit_operator.py <add>from airflow.operators import ShortCircuitOperator, DummyOperator <add>from airflow.models import DAG <add>import airflow.utils <add>from datetime import datetime, timedelta <add> <add>seven_days_ago = datetime.combine(datetime.today() - timedelta(7), <add> datetime.min.time()) <add>args = { <add> 'owner': 'airflow', <add> 'start_date': seven_days_ago, <add>} <add> <add>dag = DAG(dag_id='example_short_circuit_operator', default_args=args) <add> <add>cond_true = ShortCircuitOperator( <add> task_id='condition_is_True', python_callable=lambda: True, dag=dag) <add> <add>cond_false = ShortCircuitOperator( <add> task_id='condition_is_False', python_callable=lambda: False, dag=dag) <add> <add>ds_true = [DummyOperator(task_id='true_' + str(i), dag=dag) for i in [1, 2]] <add>ds_false = [DummyOperator(task_id='false_' + str(i), dag=dag) for i in [1, 2]] <add> <add>airflow.utils.chain(cond_true, *ds_true) <add>airflow.utils.chain(cond_false, *ds_false) <ide><path>tests/core.py <ide> from airflow.www.app import app <ide> from airflow.settings import Session <ide> <del>NUM_EXAMPLE_DAGS = 6 <add>NUM_EXAMPLE_DAGS = 7 <ide> DEV_NULL = '/dev/null' <ide> DEFAULT_DATE = datetime(2015, 1, 1) <ide> TEST_DAG_ID = 'unit_tests'
2
Text
Text
translate 11 to korean
2bc8a36ab991c48331737bc4dd8ffebfbbf248a5
<ide><path>docs/docs/11-advanced-performance.ko-KR.md <add>--- <add>id: advanced-performance-ko-KR <add>title: ์„ฑ๋Šฅ ์‹ฌํ™” <add>permalink: advanced-performance-ko-KR.html <add>prev: perf-ko-KR.html <add>--- <add> <add>React๋ฅผ ๋„์ž…ํ•˜๋ ค ํ•  ๋•Œ ๋งŽ์€ ์‚ฌ๋žŒ์ด ๋ฌป๋Š” ์ฒซ ๋ฒˆ์งธ ์งˆ๋ฌธ์€ React๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์„ ๋•Œ์ฒ˜๋Ÿผ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ๋น ๋ฅด๊ณ  ๋ฐ˜์‘์„ฑ๋„ ์ข‹์„ ๊ฒƒ์ด๋ƒ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋ชจ๋“  ์ƒํƒœ๋ณ€ํ™”์— ๋Œ€ํ•ด ์ปดํฌ๋„ŒํŠธ์˜ ํ•˜์œ„ ํŠธ๋ฆฌ๋ฅผ ์ „๋ถ€ ๋‹ค์‹œ ๋ Œ๋”๋งํ•˜๋Š” ์•„์ด๋””์–ด์— ๋Œ€ํ•ด ์‚ฌ๋žŒ๋“ค์€ ์ด ํ”„๋กœ์„ธ์Šค๊ฐ€ ์„ฑ๋Šฅ์— ๋ถ€์ •์ ์ธ ์˜ํ–ฅ์„ ์ค„ ๊ฒƒ์œผ๋กœ ์ƒ๊ฐํ•˜์ง€๋งŒ, React๋Š” ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ์˜๋ฆฌํ•œ ๋ฐฉ๋ฒ•์„ ํ†ตํ•ด UI๋ฅผ ์—…๋ฐ์ดํŠธํ•˜๋Š”๋ฐ ํ•„์š”ํ•œ ๋น„์‹ผ DOM ์กฐ์ž‘์„ ์ตœ์†Œํ™”ํ•ฉ๋‹ˆ๋‹ค. <add> <add>## DOM ์กฐ์ • ํšŒํ”ผ <add> <add>React๋Š” ๋ธŒ๋ผ์šฐ์ €์—์„œ ๋ Œ๋”๋œ DOM ํ•˜์œ„ ํŠธ๋ฆฌ์˜ ์„œ์ˆ ์ž ๊ฐœ๋…์ธ *๊ฐ€์ƒ์˜ DOM*์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ณ‘๋ ฌ์ ์ธ ์„œ์ˆ ์ฒด๋Š” React๊ฐ€ DOM ๋…ธ๋“œ๋ฅผ ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜ ์ด๋ฏธ ์กด์žฌํ•˜๋Š” DOM ๋…ธ๋“œ์— ์ ‘๊ทผํ•˜๋Š” ๊ฒƒ(JavaScript ๊ฐ์ฒด๋ฅผ ์กฐ์ž‘ํ•˜๋Š” ๊ฒƒ๋ณด๋‹ค ๋А๋ฆฌ์ฃ )์„ ํ”ผํ•˜๊ฒŒ ํ•ด ์ค๋‹ˆ๋‹ค. ์ปดํฌ๋„ŒํŠธ์˜ props๋‚˜ state๊ฐ€ ๋ณ€๊ฒฝ๋˜๋ฉด React๋Š” ์ƒˆ๋กœ์šด ๊ฐ€์ƒ์˜ DOM์„ ๊ตฌ์„ฑํ•ด ์ด์ „์˜ ๊ฒƒ๊ณผ ๋น„๊ตํ•ด์„œ ์‹ค์ œ DOM ์—…๋ฐ์ดํŠธ๊ฐ€ ํ•„์š”ํ•œ์ง€ ๊ฒฐ์ •ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ€๋Šฅํ•œ ์ ๊ฒŒ ๋ณ€ํ™”๋ฅผ ์ ์šฉํ•˜๊ธฐ ์œ„ํ•ด, React๋Š” ๋‘˜์ด ๋‹ค๋ฅผ ๊ฒฝ์šฐ์—๋งŒ DOM์„ [์กฐ์ •](/react/docs/reconciliation-ko-KR.html)ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค. <add> <add>์ด์— ๋”ํ•ด, React๋Š” ์ปดํฌ๋„ŒํŠธ ์ƒ๋ช…์ฃผ๊ธฐ ํ•จ์ˆ˜์ธ `shouldComponentUpdate`๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๋‹ค์‹œ ๋ Œ๋”๋งํ•˜๋Š” ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ผ์–ด๋‚˜๊ธฐ ์ง์ „์— ์ผ์–ด๋‚˜๋ฉฐ ๊ฐœ๋ฐœ์ž๊ฐ€ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ค‘๋‹จํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค. ์ด ํ•จ์ˆ˜์˜ ๊ธฐ๋ณธ๊ตฌํ˜„์€ `true`๋ฅผ ๋ฐ˜ํ™˜ํ•ด React๊ฐ€ ์—…๋ฐ์ดํŠธ๋ฅผ ์ˆ˜ํ–‰ํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. <add> <add>```javascript <add>shouldComponentUpdate: function(nextProps, nextState) { <add> return true; <add>} <add>``` <add> <add>React๊ฐ€ ์ด ํ•จ์ˆ˜๋ฅผ ์ž์ฃผ ํ˜ธ์ถœํ•œ๋‹ค๋Š” ๊ฒƒ์„ ๋ช…์‹ฌํ•˜์‹ญ์‹œ์˜ค. ๋”ฐ๋ผ์„œ ๊ตฌํ˜„์ฒด๋Š” ๋นจ๋ผ์•ผ ํ•ฉ๋‹ˆ๋‹ค. <add> <add>๋Œ€ํ™” ์Šค๋ ˆ๋“œ๊ฐ€ ์—ฌ๋Ÿฟ ๋Œ๊ณ  ์žˆ๋Š” ๋ฉ”์‹œ์ง€์ฒ˜๋ฆฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์ƒ๊ฐํ•ด ๋ด…์‹œ๋‹ค. ์˜ค์ง ํ•˜๋‚˜์˜ ์Šค๋ ˆ๋“œ๋งŒ์ด ๋ณ€๊ฒฝ๋˜์—ˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•ด ๋ณด์ฃ . `ChatThread`์— `shouldComponentUpdate`๋ฅผ ๊ตฌํ˜„ํ–ˆ๋‹ค๋ฉด React๋Š” ๋‹ค๋ฅธ ์Šค๋ ˆ๋“œ์˜ ๋ Œ๋”๋ง ํ”„๋กœ์„ธ์Šค๋ฅผ ๊ฑด๋„ˆ๋›ธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. <add> <add>```javascript <add>shouldComponentUpdate: function(nextProps, nextState) { <add> // TODO: ํ˜„์žฌ์˜ ๋Œ€ํ™” ์Šค๋ ˆ๋“œ๊ฐ€ ์ด์ „์˜ ๊ฒƒ๊ณผ ๋‹ค๋ฅธ์ง€ ์•„๋‹Œ์ง€๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค <add>} <add>``` <add> <add>์ •๋ฆฌํ•˜์ž๋ฉด, React๋Š” ์‚ฌ์šฉ์ž๊ฐ€ `shouldComponentUpdate`๋ฅผ ์‚ฌ์šฉํ•ด ๋ Œ๋”๋ง ํ”„๋กœ์„ธ์Šค๋ฅผ ์ค‘๋‹จํ•˜๊ณ  ๊ฐ€์ƒ์˜ DOM๊ณผ ๋น„๊ตํ•ด ์—…๋ฐ์ดํŠธ ์—ฌ๋ถ€๋ฅผ ๊ฒฐ์ •ํ•ด์„œ DOM์˜ ํ•˜์œ„ ํŠธ๋ฆฌ๋ฅผ ์กฐ์ •ํ•˜๋Š” ๋น„์‹ผ DOM ์กฐ์ž‘์„ ํ”ผํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. <add> <add>## shouldComponentUpdate ์‹ค์ „ <add> <add>๋‹ค์Œ์€ ์ปดํฌ๋„ŒํŠธ์˜ ํ•˜์œ„ ํŠธ๋ฆฌ์ž…๋‹ˆ๋‹ค. ๊ฐ๊ฐ์€ `shouldComponentUpdate`์˜ ๋ฐ˜ํ™˜๊ฐ’(SCU)๊ณผ ๊ฐ€์ƒ์˜ DOM๊ณผ์˜ ๋™์ผ์„ฑ(vDOMEq)์„ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ, ์›์˜ ์ƒ‰์€ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์กฐ์ •๋˜์—ˆ๋Š”์ง€๋ฅผ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. <add> <add><figure><img src="/react/img/docs/should-component-update.png" /></figure> <add> <add>์œ„์˜ ์˜ˆ์‹œ์—์„œ, C2๋ฅผ ๋ฃจํŠธ๋กœ ํ•˜๋Š” ํ•˜์œ„ ํŠธ๋ฆฌ์— ๋Œ€ํ•ด `shouldComponentUpdate`๊ฐ€ `false`๋ฅผ ๋ฐ˜ํ™˜ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— React๋Š” ์ƒˆ๋กœ์šด ๊ฐ€์ƒ์˜ DOM์„ ๋งŒ๋“ค ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ DOM์„ ์กฐ์ •ํ•  ํ•„์š”๋„ ์—†์Šต๋‹ˆ๋‹ค. React๊ฐ€ C4์™€ C5์—๋Š” `shouldComponentUpdate`๋ฅผ ์š”์ฒญํ•˜์ง€๋„ ์•Š์€ ๊ฒƒ์„ ํ™•์ธํ•˜์„ธ์š”. <add> <add>C1๊ณผ C3์˜ `shouldComponentUpdate`๊ฐ€ `true`๋ฅผ ๋ฐ˜ํ™˜ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— React๋Š” ํ•˜์œ„ ๋…ธ๋“œ๋กœ ๋‚ด๋ ค๊ฐ€ ๊ทธ๋“ค์„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. C6๋Š” `true`๋ฅผ ๋ฐ˜ํ™˜ํ–ˆ๋„ค์š”; ์ด๋Š” ๊ฐ€์ƒ์˜ DOM๊ณผ ๊ฐ™์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— DOM์˜ ์กฐ์ •์ด ์ผ์–ด๋‚ฌ์Šต๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ ํฅ๋ฏธ๋กœ์šด ์‚ฌ๋ก€๋Š” C8์ž…๋‹ˆ๋‹ค. React๊ฐ€ ์ด ๋…ธ๋“œ๋ฅผ ์œ„ํ•ด ๊ฐ€์ƒ์˜ DOM์„ ์ž‘๋™ํ–ˆ์ง€๋งŒ, ๋…ธ๋“œ๊ฐ€ ์ด์ „์˜ ๊ฒƒ๊ณผ ์ผ์น˜ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— DOM์˜ ์กฐ์ •์„ ์ผ์–ด๋‚˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. <add> <add>React๊ฐ€ C6์—๋งŒ DOM ๋ณ€๊ฒฝ์„ ์ˆ˜ํ–‰ํ•œ ๊ฒƒ์„ ํ™•์ธํ•˜์„ธ์š”. ์ด๋Š” ํ•„์—ฐ์ ์ด์—ˆ์Šต๋‹ˆ๋‹ค. C8์˜ ๊ฒฝ์šฐ๋Š” ๊ฐ€์ƒ์˜ DOM๊ณผ ๋น„๊ต๋ฅผ ํ•ด ์ œ์™ธ๋˜์—ˆ๊ณ , C2์˜ ํ•˜์œ„ ํŠธ๋ฆฌ์™€ C7์€ `shouldComponentUpdate` ๋‹จ๊ณ„์—์„œ ์ œ์™ธ๋˜์–ด ๊ฐ€์ƒ์˜ DOM์€ ๊ตฌ๋™์กฐ์ฐจ ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. <add> <add>์ž ๊ทธ๋Ÿผ, ์–ด๋–ป๊ฒŒ `shouldComponentUpdate`๋ฅผ ๊ตฌํ˜„ํ•ด์•ผ ํ• ๊นŒ์š”? ๋ฌธ์ž์—ด ๊ฐ’์„ ๋ Œ๋”ํ•˜๋Š” ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ƒ๊ฐํ•ด๋ณด์ฃ . <add> <add>```javascript <add>React.createClass({ <add> propsTypes: { <add> value: React.PropTypes.string.isRequired <add> }, <add> <add> render: function() { <add> return <div>this.props.value</div>; <add> } <add>}); <add>``` <add> <add>๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฐ„๋‹จํžˆ `shouldComponentUpdate`๋ฅผ ๊ตฌํ˜„ํ•ด ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: <add> <add>```javascript <add>shouldComponentUpdate: function(nextProps, nextState) { <add> return this.props.value !== nextProps.value; <add>} <add>``` <add> <add>์—ฌ๊ธฐ๊นŒ์ง€๋Š” ์ข‹์Šต๋‹ˆ๋‹ค. ๊ฐ„๋‹จํ•œ props/state ๊ตฌ์กฐ๋ฅผ ๋‹ค๋ฃจ๊ธฐ๋Š” ์‰ฝ์Šต๋‹ˆ๋‹ค. ๋‹จ์ˆœํ•œ ๋“ฑ์‹๋น„๊ต ๊ตฌํ˜„์„ ์ผ๋ฐ˜ํ™”ํ•˜๊ณ  ์ด๋ฅผ ์ปดํฌ๋„ŒํŠธ์— ํ˜ผํ•ฉํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์‚ฌ์‹ค, React๋Š” ์ด๋ฏธ ๊ทธ๋Ÿฐ ๊ตฌํ˜„์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค: [PureRenderMixin](/react/docs/pure-render-mixin-ko-KR.html). <add> <add>ํ•˜์ง€๋งŒ ๋งŒ์•ฝ ์ปดํฌ๋„ŒํŠธ์˜ props๋‚˜ state๊ฐ€ ๊ฐ€๋ณ€์ ์ธ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ๋กœ ๋˜์–ด ์žˆ๋‹ค๋ฉด ์–ด๋–จ๊นŒ์š”? ์ปดํฌ๋„ŒํŠธ์˜ prop์œผ๋กœ `'bar'`๊ฐ™์€ ๋ฌธ์ž์—ด ๋Œ€์‹ ์— `{ foo: 'bar' }`์ฒ˜๋Ÿผ ๋ฌธ์ž์—ด์„ ํฌํ•จํ•œ JavaScript ๊ฐ์ฒด๋ฅผ ์ „๋‹ฌ๋ฐ›๋Š”๋‹ค๊ณ  ํ•ด๋ด…์‹œ๋‹ค. <add> <add>```javascript <add>React.createClass({ <add> propsTypes: { <add> value: React.PropTypes.object.isRequired <add> }, <add> <add> render: function() { <add> return <div>this.props.value.foo</div>; <add> } <add>}); <add>``` <add> <add>์ „์— ๊ตฌํ˜„ํ–ˆ๋˜ `shouldComponentUpdate`๋Š” ์–ธ์ œ๋‚˜ ์˜ˆ์ƒ๋Œ€๋กœ ์ž‘๋™ํ•˜์ง€ ์•Š์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค: <add> <add>```javascript <add>// this.props.value๊ฐ€ { foo: 'bar' }๋ผ๊ณ  ๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค <add>// nextProps.value๋„ { foo: 'bar' }๋ผ๊ณ  ๊ฐ€์ •ํ•˜์ง€๋งŒ, <add>// ์ด ์ฐธ์กฐ๋Š” this.props.value์™€ ๋‹ค๋ฅธ ๊ฒƒ์ž…๋‹ˆ๋‹ค <add>this.props.value !== nextProps.value; // true <add>``` <add> <add>๋ฌธ์ œ๋Š” prop์ด ์‹ค์ œ๋กœ ๋ณ€๊ฒฝ๋˜์ง€ ์•Š์•˜์„ ๋•Œ๋„ `shouldComponentUpdate`๊ฐ€ `true`๋ฅผ ๋ฐ˜ํ™˜ํ•  ๊ฑฐ๋ผ๋Š” ๊ฒ๋‹ˆ๋‹ค. ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•œ ๋Œ€์•ˆ์œผ๋กœ ์•„๋ž˜์™€ ๊ฐ™์ด ๊ตฌํ˜„ํ•ด ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: <add> <add>```javascript <add>shouldComponentUpdate: function(nextProps, nextState) { <add> return this.props.value.foo !== nextProps.value.foo; <add>} <add>``` <add> <add>๊ธฐ๋ณธ์ ์œผ๋กœ, ์šฐ๋ฆฌ๋Š” ๋ณ€๊ฒฝ์„ ์ •ํ™•ํžˆ ์ถ”์ ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๊นŠ์€ ๋น„๊ต๋ฅผ ํ•ด์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด ๋ฐฉ๋ฒ•์€ ์„ฑ๋Šฅ ๋ฉด์—์„œ ์ œ๋ฒ• ๋น„์‹ธ๊ณ  ๊ฐ๊ฐ์˜ ๋ชจ๋ธ๋งˆ๋‹ค ๋‹ค๋ฅธ ๊นŠ์€ ๋“ฑ์‹ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด์•ผ ํ•˜๋ฏ€๋กœ ํ™•์žฅ์ด ํž˜๋“ค์–ด ์ง‘๋‹ˆ๋‹ค. ์‹ฌ์ง€์–ด ๊ฐ์ฒด ์ฐธ์กฐ๋ฅผ ์‹ ์ค‘ํžˆ ๊ด€๋ฆฌํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด ์ž‘๋™ํ•˜์ง€๋„ ์•Š์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋ถ€๋ชจ์— ์˜ํ•ด ๋‹ค๋ค„์ง€๋Š” ๊ฒฝ์šฐ๋ฅผ ์‚ดํŽด๋ณด์ฃ : <add> <add>```javascript <add>React.createClass({ <add> getInitialState: function() { <add> return { value: { foo: 'bar' } }; <add> }, <add> <add> onClick: function() { <add> var value = this.state.value; <add> value.foo += 'bar'; // ์•ˆํ‹ฐํŒจํ„ด ์ž…๋‹ˆ๋‹ค! <add> this.setState({ value: value }); <add> }, <add> <add> render: function() { <add> return ( <add> <div> <add> <InnerComponent value={this.state.value} /> <add> <a onClick={this.onClick}>ํด๋ฆญํ•˜์„ธ์š”</a> <add> </div> <add> ); <add> } <add>}); <add>``` <add> <add>์ฒ˜์Œ์—” ๋‚ด๋ถ€ ์ปดํฌ๋„ŒํŠธ(`<InnerComponent />`)๊ฐ€ `{ foo: 'bar' }`๋ฅผ value prop์œผ๋กœ ๊ฐ€์ง„ ์ฑ„ ๋ Œ๋”๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ ์•ต์ปค(`<a>`)๋ฅผ ํด๋ฆญํ•œ๋‹ค๋ฉด ๋ถ€๋ชจ ์ปดํฌ๋„ŒํŠธ์˜ state๋Š” `{ value: { foo: 'barbar' } }`๋กœ ์—…๋ฐ์ดํŠธ๋˜๊ณ , ๋‚ด๋ถ€ ์ปดํฌ๋„ŒํŠธ ๋˜ํ•œ `{ foo: 'barbar' }`๋ฅผ ์ƒˆ๋กœ์šด value prop์œผ๋กœ ์ „๋‹ฌ๋ฐ›์•„ ๋‹ค์‹œ ๋ Œ๋”๋ง ๋˜๋Š” ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ผ์–ด๋‚  ๊ฒƒ์ž…๋‹ˆ๋‹ค. <add> <add>์ด ๋ฌธ์ œ๋Š” ๋ถ€๋ชจ์™€ ๋‚ด๋ถ€ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๊ฐ™์€ ๊ฐ์ฒด์— ๋Œ€ํ•œ ์ฐธ์กฐ๋ฅผ ๊ณต์œ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. `onClick` ํ•จ์ˆ˜์˜ ๋‘ ๋ฒˆ์งธ ์ค„์—์„œ ๊ฐ์ฒด์— ๋Œ€ํ•œ ๋ณ€๊ฒฝ์ด ์ผ์–ด๋‚  ๋•Œ, ๋‚ด๋ถ€ ์ปดํฌ๋„ŒํŠธ์˜ prop๋„ ๋ณ€๊ฒฝ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๋‹ค์‹œ ๋ Œ๋”๋ง ๋˜๋Š” ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‹œ์ž‘๋  ๋•Œ `shouldComponentUpdate`๊ฐ€ ํ˜ธ์ถœ๋˜๊ณ  `this.props.value.foo`๊ฐ€ `nextProps.value.foo`์™€ ๊ฐ™๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์‹ค์ œ๋กœ `this.props.value`๋Š” `nextProps.value`์™€ ๊ฐ™์€ ๊ฐ์ฒด์ด๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. <add> <add>๊ทธ์—๋”ฐ๋ผ prop์˜ ๋ณ€๊ฒฝ์„ ๋†“์น˜๊ฒŒ ๋˜์–ด ๋‹ค์‹œ ๋ Œ๋”๋งํ•˜๋Š” ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ค‘๋‹จ๋˜๊ณ , UI๋Š” `'bar'`์—์„œ `'barbar'`๋กœ ์—…๋ฐ์ดํŠธ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. <add> <add>## ๊ตฌ์›์ž Immutable-js <add> <add>[Immutable-js](https://github.com/facebook/immutable-js)๋Š” Lee Byron์ด ๋งŒ๋“ค๊ณ  Facebook์ด ์˜คํ”ˆ์†Œ์Šคํ™” ํ•œ Javascript ์ปฌ๋ ‰์…˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค. ์ด๋Š” *๊ตฌ์กฐ์˜ ๊ณต์œ (structural sharing)*๋ฅผ ํ†ตํ•ด *๋ถˆ๋ณ€์˜ ์˜์†์ ์ธ(immutable persistent)* ์ปฌ๋ ‰์…˜์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์†์„ฑ์ด ๋ฌด์—‡์„ ์˜๋ฏธํ•˜๋Š”์ง€ ์‚ดํŽด๋ณด์ฃ : <add> <add>* *๋ถˆ๋ณ€์„ฑ(Immutable)*: ์ปฌ๋ ‰์…˜์ด ํ•œ๋ฒˆ ์ƒ์„ฑ๋˜๋ฉด, ์ด ํ›„ ๋‹ค๋ฅธ ์‹œ์ ์— ๋ณ€๊ฒฝ๋  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. <add>* *์˜์†์„ฑ(Persistent)*: ์ƒˆ๋กœ์šด ์ปฌ๋ ‰์…˜์ด ์ด์ „์˜ ์ปฌ๋ ‰์…˜์ด๋‚˜ ์…‹(set) ๊ฐ™์€ ๋ฎคํ…Œ์ด์…˜(mutation)์—์„œ ์ƒ์„ฑ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ธฐ์กด์˜ ์ปฌ๋ ‰์…˜์€ ์ƒˆ๋กœ์šด ์ปฌ๋ ‰์…˜์ด ์ƒ์„ฑ๋œ ํ›„์—๋„ ์—ฌ์ „ํžˆ ์œ ํšจํ•ฉ๋‹ˆ๋‹ค. <add>* *๊ตฌ์กฐ์˜ ๊ณต์œ (Structural Sharing)*: ์ƒˆ๋กœ์šด ์ปฌ๋ ‰์…˜์€ ๊ฐ€๋Šฅํ•œ ํ•œ ์›๋ž˜์˜ ์ปฌ๋ ‰์…˜๊ณผ ๊ฐ™์€ ๊ตฌ์กฐ๋ฅผ ์‚ฌ์šฉํ•ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค. ๊ณต๊ฐ„ ํšจ์œจ์„ฑ๊ณผ ์ ์ ˆํ•œ ์„ฑ๋Šฅ์„ ์œ„ํ•ด ๋ณต์‚ฌ๋ฅผ ์ตœ์†Œํ™”ํ•ฉ๋‹ˆ๋‹ค. <add> <add>๋ถˆ๋ณ€์„ฑ์€ ๋ณ€๊ฒฝ์˜ ์ถ”์ ์„ ๋น„์šฉ์„ ์ค„์—ฌ์ค๋‹ˆ๋‹ค; ๋ณ€๊ฒฝ์€ ํ•ญ์ƒ ์ƒˆ๋กœ์šด ๊ฐ์ฒด์—๋งŒ ๋ฐœ์ƒํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ์ฒด์— ๋Œ€ํ•œ ์ฐธ์กฐ๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ๋งŒ ํ™•์ธํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์ผ๋ฐ˜์ ์ธ JavaScript ์ฝ”๋“œ์—์„œ๋Š”: <add> <add>```javascript <add>var x = { foo: "bar" }; <add>var y = x; <add>y.foo = "baz"; <add>x === y; // true <add>``` <add> <add>`y`๊ฐ€ ์ˆ˜์ •๋˜๋”๋ผ๋„ ์—ฌ์ „ํžˆ ๊ฐ™์€ ๊ฐ์ฒด์ธ `x`๋ฅผ ์ฐธ์กฐํ•˜๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์—, ์ด ๋น„๊ต๋Š” `true`๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ด ์ฝ”๋“œ๋ฅผ immutable-js๋ฅผ ์‚ฌ์šฉํ•ด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: <add> <add>```javascript <add>var SomeRecord = Immutable.Record({ foo: null }); <add>var x = new SomeRecord({ foo: 'bar' }); <add>var y = x.set('foo', 'baz'); <add>x === y; // false <add>``` <add> <add>์ด ๊ฒฝ์šฐ, `x`๊ฐ€ ๋ณ€๊ฒฝ๋˜๋ฉด ์ƒˆ๋กœ์šด ์ฐธ์กฐ๊ฐ€ ๋ฐ˜ํ™˜๋˜๊ธฐ ๋•Œ๋ฌธ์—, ์šฐ๋ฆฌ๋Š” ์•ˆ์ „ํ•˜๊ฒŒ `x`๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์„ ๊ฒƒ์œผ๋กœ ์ถ”์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. <add> <add>๋ณ€๊ฒฝ์„ ํƒ์ง€ํ•  ์ˆ˜ ์žˆ๋Š” ๋˜ ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์€ ์„ธํ„ฐ(setter)์— ์˜ํ•ด ์„ค์ •๋œ ํ”Œ๋ž˜๊ทธ๋ฅผ ๋”ํ‹ฐ ์ฒดํ‚น(dirty checking)ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด ๋ฐฉ์‹์˜ ๋ฌธ์ œ๋Š” ๋‹น์‹ ์ด ์„ธํ„ฐ๋ฅผ ์‚ฌ์šฉํ•  ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์ˆ˜๋งŽ์€ ์ถ”๊ฐ€ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๊ฑฐ๋‚˜ ์–ด๋–ป๊ฒŒ๋“  ํด๋ž˜์Šค๋“ค์„ ์ธ์ŠคํŠธ๋ฃจ๋จผํŠธ(instrument) ํ•˜๋„๋ก ๊ฐ•์š”ํ•œ๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ํ˜น์€ ๋ณ€๊ฒฝ(mutations) ์ง์ „์— ๊ฐ์ฒด๋ฅผ ๊นŠ์€ ๋ณต์‚ฌ(deep copy) ํ•œ ๋’ค ๊นŠ์€ ๋น„๊ต(deep compare)๋ฅผ ์ˆ˜ํ–‰ํ•ด ๋ณ€๊ฒฝ ์—ฌ๋ถ€๋ฅผ ํŒ๋‹จํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋ฐฉ์‹์˜ ๋ฌธ์ œ์ ์€ deepCopy์™€ deepCompare ๋‘˜ ๋‹ค ๋น„์šฉ์ด ๋งŽ์ด ๋“œ๋Š” ์—ฐ์‚ฐ์ด๋ผ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. <add> <add>๊ทธ๋ž˜์„œ Immutable ์ž๋ฃŒ๊ตฌ์กฐ๋Š” `shouldComponentUpdate`์˜ ๊ตฌํ˜„์— ํ•„์š”ํ•œ ๊ฐ์ฒด์˜ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ถ”์ ํ•  ์ˆ˜ ์žˆ๋Š” ๋œ ์ž์„ธํ•˜์ง€๋งŒ ์ €๋ ดํ•œ ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๊ทธ์— ๋”ฐ๋ผ immutable-js๊ฐ€ ์ œ๊ณตํ•˜๋Š” ์ถ”์ƒํ™”๋ฅผ ์‚ฌ์šฉํ•ด props์™€ state ์–ดํŠธ๋ฆฌ๋ทฐํŠธ๋ฅผ ๋ชจ๋ธ๋งํ•œ๋‹ค๋ฉด, `PureRenderMixin`์„ ์‚ฌ์šฉํ•ด ์„ฑ๋Šฅ์„ ํ–ฅ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. <add> <add>## Immutable-js์™€ Flux <add> <add>[Flux](http://facebook.github.io/flux/)๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด immutable-js๋ฅผ ์‚ฌ์šฉํ•ด stores๋ฅผ ์ž‘์„ฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. [์ „์ฒด API](http://facebook.github.io/immutable-js/docs/#/)๋ฅผ ์‚ดํŽด๋ณด์„ธ์š”. <add> <add>Immutable ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ์ด์šฉํ•ด ์Šค๋ ˆ๋“œ๋ฅผ ๋ชจ๋ธ๋งํ•˜๋Š” ์˜ˆ์ œ๋ฅผ ์‚ดํŽด๋ด…์‹œ๋‹ค. ๋จผ์ € ๋ชจ๋ธ๋งํ•˜๋ ค๋Š” ์—”ํ‹ฐํ‹ฐ๋งˆ๋‹ค `Record`๋ฅผ ์ •์˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. Record๋Š” ํŠน์ • ํ•„๋“œ๋“ค์˜ ๊ฐ’์„ ์œ ์ง€ํ•˜๊ธฐ ์œ„ํ•œ ๋ถˆ๋ณ€์˜ ์ปจํ…Œ์ด๋„ˆ์ž…๋‹ˆ๋‹ค: <add> <add>```javascript <add>var User = Immutable.Record({ <add> id: undefined, <add> name: undefined, <add> email: undefined <add>}); <add> <add>var Message = Immutable.Record({ <add> timestamp: new Date(), <add> sender: undefined, <add> text: '' <add>}); <add>``` <add> <add>`Record` ํ•จ์ˆ˜๋Š” ํ•„๋“œ๋ณ„๋กœ ๊ธฐ๋ณธ๊ฐ’์ด ์„ ์–ธ๋œ ๊ฐ์ฒด์— ๋Œ€ํ•œ ์ •์˜๋ฅผ ๋„˜๊ฒจ๋ฐ›์Šต๋‹ˆ๋‹ค. <add> <add>๋ฉ”์‹œ์ง€ store๋Š” ๋‘ ๊ฐœ์˜ List๋ฅผ ํ†ตํ•ด users์™€ messages๋ฅผ ์ถ”์ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: <add> <add>```javascript <add>this.users = Immutable.List(); <add>this.messages = Immutable.List(); <add>``` <add> <add>๊ฐ๊ฐ์˜ *ํŽ˜์ด๋กœ๋“œ* ํƒ€์ž…์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์€ ๊ฝค ๊ฐ„๋‹จํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด, store๊ฐ€ ์ƒˆ ๋ฉ”์‹œ์ง€๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ํŽ˜์ด๋กœ๋“œ๋ฅผ ํ™•์ธํ•  ๋•Œ ๋ ˆ์ฝ”๋“œ๋ฅผ ์ƒˆ๋กœ ์ƒ์„ฑํ•˜๊ณ  ๋ฉ”์‹œ์ง€ ๋ฆฌ์ŠคํŠธ์— ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. <add> <add>```javascript <add>this.messages = this.messages.push(new Message({ <add> timestamp: payload.timestamp, <add> sender: payload.sender, <add> text: payload.text <add>}); <add>``` <add> <add>์ž๋ฃŒ๊ตฌ์กฐ๊ฐ€ ๋ถˆ๋ณ€์ด๊ธฐ ๋•Œ๋ฌธ์— push ํ•จ์ˆ˜์˜ ๊ฒฐ๊ณผ๋ฅผ this.messages์— ํ• ๋‹นํ•  ํ•„์š”๊ฐ€ ์žˆ์œผ๋‹ˆ ์ฃผ์˜ํ•˜์„ธ์š”. <add> <add>React ์ธก์—์„œ๋Š”, ์ปดํฌ๋„ŒํŠธ์˜ state๋ฅผ ๋ณด์กดํ•˜๊ธฐ ์œ„ํ•ด immutable-js ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด, ๋ชจ๋“  ์ปดํฌ๋„ŒํŠธ์— `PureRenderMixin`์„ ํ˜ผํ•ฉํ•ด ๋‹ค์‹œ ๋ Œ๋”๋งํ•˜๋Š” ํ”„๋กœ์„ธ์Šค๋ฅผ ์ค‘๋‹จํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
1
Go
Go
add environment variable to enable
fe5b34ba8828dc2f2f7db180a102cee360fec6e0
<ide><path>cmd/dockerd/daemon.go <ide> import ( <ide> "github.com/docker/docker/pkg/pidfile" <ide> "github.com/docker/docker/pkg/plugingetter" <ide> "github.com/docker/docker/pkg/signal" <add> "github.com/docker/docker/pkg/system" <ide> "github.com/docker/docker/plugin" <ide> "github.com/docker/docker/registry" <ide> "github.com/docker/docker/runconfig" <ide> func (cli *DaemonCli) start(opts *daemonOptions) (err error) { <ide> logrus.Fatalf("Error creating middlewares: %v", err) <ide> } <ide> <add> if system.LCOWSupported() { <add> logrus.Warnln("LCOW support is enabled - this feature is incomplete") <add> } <add> <ide> d, err := daemon.NewDaemon(cli.Config, registryService, containerdRemote, pluginStore) <ide> if err != nil { <ide> return fmt.Errorf("Error starting daemon: %v", err) <ide><path>distribution/config.go <ide> import ( <ide> "github.com/docker/docker/image" <ide> "github.com/docker/docker/layer" <ide> "github.com/docker/docker/pkg/progress" <add> "github.com/docker/docker/pkg/system" <ide> refstore "github.com/docker/docker/reference" <ide> "github.com/docker/docker/registry" <ide> "github.com/docker/libtrust" <ide> func (s *imageConfigStore) RootFSFromConfig(c []byte) (*image.RootFS, error) { <ide> } <ide> <ide> // fail immediately on Windows when downloading a non-Windows image <del> // and vice versa <del> if runtime.GOOS == "windows" && unmarshalledConfig.OS == "linux" { <add> // and vice versa. Exception on Windows if Linux Containers are enabled. <add> if runtime.GOOS == "windows" && unmarshalledConfig.OS == "linux" && !system.LCOWSupported() { <ide> return nil, fmt.Errorf("image operating system %q cannot be used on this platform", unmarshalledConfig.OS) <ide> } else if runtime.GOOS != "windows" && unmarshalledConfig.OS == "windows" { <ide> return nil, fmt.Errorf("image operating system %q cannot be used on this platform", unmarshalledConfig.OS) <ide><path>pkg/system/chtimes.go <ide> package system <ide> <ide> import ( <ide> "os" <del> "syscall" <ide> "time" <del> "unsafe" <ide> ) <ide> <del>var ( <del> maxTime time.Time <del>) <del> <del>func init() { <del> if unsafe.Sizeof(syscall.Timespec{}.Nsec) == 8 { <del> // This is a 64 bit timespec <del> // os.Chtimes limits time to the following <del> maxTime = time.Unix(0, 1<<63-1) <del> } else { <del> // This is a 32 bit timespec <del> maxTime = time.Unix(1<<31-1, 0) <del> } <del>} <del> <ide> // Chtimes changes the access time and modified time of a file at the given path <ide> func Chtimes(name string, atime time.Time, mtime time.Time) error { <ide> unixMinTime := time.Unix(0, 0) <ide><path>pkg/system/init.go <add>package system <add> <add>import ( <add> "syscall" <add> "time" <add> "unsafe" <add>) <add> <add>// Used by chtimes <add>var maxTime time.Time <add> <add>func init() { <add> // chtimes initialization <add> if unsafe.Sizeof(syscall.Timespec{}.Nsec) == 8 { <add> // This is a 64 bit timespec <add> // os.Chtimes limits time to the following <add> maxTime = time.Unix(0, 1<<63-1) <add> } else { <add> // This is a 32 bit timespec <add> maxTime = time.Unix(1<<31-1, 0) <add> } <add>} <ide><path>pkg/system/init_windows.go <add>package system <add> <add>import "os" <add> <add>// LCOWSupported determines if Linux Containers on Windows are supported. <add>// Note: This feature is in development (06/17) and enabled through an <add>// environment variable. At a future time, it will be enabled based <add>// on build number. @jhowardmsft <add>var lcowSupported = false <add> <add>func init() { <add> // LCOW initialization <add> if os.Getenv("LCOW_SUPPORTED") != "" { <add> lcowSupported = true <add> } <add> <add>} <ide><path>pkg/system/lcow.go <add>package system <add> <add>// LCOWSupported returns true if Linux containers on Windows are supported. <add>func LCOWSupported() bool { <add> return lcowSupported <add>}
6
Ruby
Ruby
make local bottle installation more robust
1bc460403bc690460eac6da739e50321642d5754
<ide><path>Library/Homebrew/formula.rb <ide> def self.factory name <ide> install_type = :from_url <ide> elsif name.match bottle_regex <ide> bottle_filename = Pathname(name).realpath <del> name = bottle_filename.basename.to_s.rpartition('-').first <add> version = Version.parse(bottle_filename).to_s <add> name = bottle_filename.basename.to_s.rpartition("-#{version}").first <ide> path = Formula.path(name) <ide> install_type = :from_local_bottle <ide> else
1
Ruby
Ruby
handle linux bottles
b0198d097e115d304d1169709c6029fa24e0f2fa
<ide><path>Library/Homebrew/compat.rb <add>require "compat/extend/os/mac/utils/bottles" <ide> require "compat/requirements/x11_requirement" <ide> require "compat/requirements/xcode_requirement" <ide> require "compat/cask" <ide><path>Library/Homebrew/compat/extend/os/mac/utils/bottles.rb <add>module Utils <add> class Bottles <add> class Collector <add> module Compat <add> private <add> <add> def tag_without_or_later(tag) <add> return super unless tag.to_s.end_with?("_or_later") <add> <add> odeprecated "`or_later` bottles", <add> "bottles without `or_later` (or_later is implied now)" <add> tag.to_s[/(\w+)_or_later$/, 1].to_sym <add> end <add> end <add> <add> prepend Compat <add> end <add> end <add>end <ide><path>Library/Homebrew/extend/os/mac/utils/bottles.rb <ide> def find_altivec_tag(tag) <ide> altivec_tag if key?(altivec_tag) <ide> end <ide> <add> def tag_without_or_later(tag) <add> tag <add> end <add> <ide> # Find a bottle built for a previous version of macOS. <ide> def find_older_compatible_tag(tag) <ide> begin <ide> def find_older_compatible_tag(tag) <ide> end <ide> <ide> keys.find do |key| <del> # TODO: move to compat? <del> key_tag_version = if key.to_s.end_with?("_or_later") <del> key.to_s[/(\w+)_or_later$/, 1].to_sym <del> else <del> key <add> key_tag_version = tag_without_or_later(key) <add> begin <add> MacOS::Version.from_symbol(key_tag_version) <= tag_version <add> rescue ArgumentError <add> false <ide> end <del> MacOS::Version.from_symbol(key_tag_version) <= tag_version <ide> end <ide> end <ide> end
3
Text
Text
fix typos in timers topic to aid readability
af61ebf6e261f479ed93ca3f3fd2f5cbaeb63b2f
<ide><path>doc/topics/the-event-loop-timers-and-nexttick.md <ide> ways depending on when they are called. <ide> * `setTimeout()` schedules a script to be run <ide> after a minimum threshold in ms has elapsed. <ide> <del>The order in which they are execute varies depending on the context in <del>which they are called. If both are called in the main module then you <del>are bound to how fast your process go, which is impacted by other <del>programs running on your machine. <del> <del>For example, if we run the following script which is not within a I/O <del>cycle (i.e. the main module), the order in which the two functions are <del>executed is non-deterministic as it is based upon how fast your process <del>goes (which is impacted by other programs running on your machine): <add>The order in which the timers are executed will vary depending on the <add>context in which they are called. If both are called from within the <add>main module, then timing will be bound by the performance of the process <add>(which can be impacted by other applications running on the machine). <add> <add>For example, if we run the following script which is not within an I/O <add>cycle (i.e. the main module), the order in which the two timers are <add>executed is non-deterministic, as it is bound by the performance of the <add>process: <ide> <ide> <ide> ```js
1
PHP
PHP
fix error handling
2e01c58f92761ac24f9feb759d6f46c539984668
<ide><path>laravel/error.php <ide> public static function exception($exception, $trace = true) <ide> { <ide> $response = Event::first('500'); <ide> <del> return Response::prepare($response)->send(); <add> echo Response::prepare($response)->render(); <ide> } <ide> <ide> exit(1);
1
Text
Text
replace incorrect symbols [ci skip]
f8e33fbc6ca62fc81f01c9dfff8b0cff02a3ad13
<ide><path>guides/source/i18n.md <ide> This means, that in the `:en` locale, the key _hello_ will map to the _Hello wor <ide> <ide> The I18n library will use **English** as a **default locale**, i.e. if a different locale is not set, `:en` will be used for looking up translations. <ide> <del>NOTE: The i18n library takes a **pragmatic approach** to locale keys (after [some discussion](https://groups.google.com/forum/#!topic/rails-i18n/FN7eLH2-lHA)), including only the _locale_ ("language") part, like `:en`, `:pl`, not the _region_ part, like `:en-US` or `:en-GB`, which are traditionally used for separating "languages" and "regional setting" or "dialects". Many international applications use only the "language" element of a locale such as `:cs`, `:th`, or `:es` (for Czech, Thai, and Spanish). However, there are also regional differences within different language groups that may be important. For instance, in the `:en-US` locale you would have $ as a currency symbol, while in `:en-GB`, you would have ยฃ. Nothing stops you from separating regional and other settings in this way: you just have to provide full "English - United Kingdom" locale in a `:en-GB` dictionary. <add>NOTE: The i18n library takes a **pragmatic approach** to locale keys (after [some discussion](https://groups.google.com/forum/#!topic/rails-i18n/FN7eLH2-lHA)), including only the _locale_ ("language") part, like `:en`, `:pl`, not the _region_ part, like `:"en-US"` or `:"en-GB"`, which are traditionally used for separating "languages" and "regional setting" or "dialects". Many international applications use only the "language" element of a locale such as `:cs`, `:th`, or `:es` (for Czech, Thai, and Spanish). However, there are also regional differences within different language groups that may be important. For instance, in the `:"en-US"` locale you would have $ as a currency symbol, while in `:"en-GB"`, you would have ยฃ. Nothing stops you from separating regional and other settings in this way: you just have to provide full "English - United Kingdom" locale in a `:"en-GB"` dictionary. <ide> <ide> The **translations load path** (`I18n.load_path`) is an array of paths to files that will be loaded automatically. Configuring this path allows for customization of translations directory structure and file naming scheme. <ide>
1
Java
Java
expose build method in sseeventbuilder
1c382be00e39060a0a4005d80098365f2bee45d4
<ide><path>spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitter.java <ide> interface Handler { <ide> <ide> <ide> /** <del> * Simple struct for a data entry. <add> * A simple holder of data to be written along with a MediaType hint for <add> * selecting a message converter to write with. <ide> */ <del> static class DataWithMediaType { <add> public static class DataWithMediaType { <ide> <ide> private final Object data; <ide> <ide><path>spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java <ide> public void send(Object object, MediaType mediaType) throws IOException { <ide> * @throws IOException raised when an I/O error occurs <ide> */ <ide> public void send(SseEventBuilder builder) throws IOException { <del> Set<DataWithMediaType> dataToSend = ((SseEventBuilderImpl) builder).build(); <add> Set<DataWithMediaType> dataToSend = builder.build(); <ide> synchronized (this) { <ide> for (DataWithMediaType entry : dataToSend) { <ide> super.send(entry.getData(), entry.getMediaType()); <ide> public interface SseEventBuilder { <ide> * Add an SSE "data" line. <ide> */ <ide> SseEventBuilder data(Object object, MediaType mediaType); <add> <add> /** <add> * Return one or more Object-MediaType pairs to write via <add> * {@link #send(Object, MediaType)}. <add> */ <add> Set<DataWithMediaType> build(); <add> <ide> } <ide> <ide> <ide> SseEventBuilderImpl append(String text) { <ide> return this; <ide> } <ide> <del> Set<DataWithMediaType> build() { <add> @Override <add> public Set<DataWithMediaType> build() { <ide> if ((this.sb == null || this.sb.length() == 0) && this.dataToSend.isEmpty()) { <ide> return Collections.<DataWithMediaType>emptySet(); <ide> }
2
Python
Python
fix a typo
58dfc295997d436e6f94f1fdf312a24f99d3744a
<ide><path>libcloud/storage/base.py <ide> <ide> __all__ = [ <ide> 'Object', <del> 'Contaner', <add> 'Container', <ide> 'StorageDriver' <ide> ] <ide>
1
Java
Java
remove @nonnull annotations in biconsumer
83d1a4f4eb66fbf6e2afd6045f96e31ced6aedfc
<ide><path>src/main/java/io/reactivex/functions/BiConsumer.java <ide> <ide> package io.reactivex.functions; <ide> <del>import io.reactivex.annotations.NonNull; <del> <ide> /** <ide> * A functional interface (callback) that accepts two values (of possibly different types). <ide> * @param <T1> the first value type <ide> * @param t2 the second value <ide> * @throws Exception on error <ide> */ <del> void accept(@NonNull T1 t1, @NonNull T2 t2) throws Exception; <add> void accept(T1 t1, T2 t2) throws Exception; <ide> }
1
PHP
PHP
fix doc block
04057caba52b304d846d306e7795a45dcd38d229
<ide><path>src/View/Helper/UrlHelper.php <ide> class UrlHelper extends Helper <ide> * @param string|array|null $url Either a relative string url like `/products/view/23` or <ide> * an array of URL parameters. Using an array for URLs will allow you to leverage <ide> * the reverse routing features of CakePHP. <del> * @param bool $options Array options; bool $full for BC reasons. <add> * @param array|bool $options Array of options; bool `full` for BC reasons. <ide> * @return string Full translated URL with base path. <ide> */ <ide> public function build($url = null, $options = false)
1
PHP
PHP
remove duplicated header
bacd8afde3d62ad212e7c68b7bf25493b93c50d9
<ide><path>lib/Cake/Console/Command/SchemaShell.php <ide> <?php <ide> /** <del> * Command-line database management utility to automate programmer chores. <del> * <del> * Schema is CakePHP's database management utility. This helps you maintain versions of <del> * of your database. <del> * <del> * PHP 5 <del> * <ide> * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) <ide> * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) <ide> *
1
Javascript
Javascript
add codementor to showcase
c9fa7c1ce8a5bdfbf3636e3cec1eb2850bb0a94e
<ide><path>website/src/react-native/showcase.js <ide> var apps = [ <ide> icon: 'http://a2.mzstatic.com/us/r30/Purple69/v4/7b/0c/a0/7b0ca007-885a-7cfc-9fa2-2ec4394c2ecc/icon175x175.png', <ide> link: 'https://play.google.com/store/apps/details?id=com.cbssports.fantasy.franchisefootball2015', <ide> author: 'CBS Sports', <del> }, <add> }, <add> { <add> name: 'Codementor - Live 1:1 Expert Developer Help', <add> icon: 'http://a1.mzstatic.com/us/r30/Purple3/v4/db/cf/35/dbcf3523-bac7-0f54-c6a8-a80bf4f43c38/icon175x175.jpeg', <add> link: 'https://www.codementor.io/downloads', <add> author: 'Codementor', <add> }, <ide> { <ide> name: 'Company name search', <ide> icon: 'http://a4.mzstatic.com/us/r30/Purple69/v4/fd/47/53/fd47537c-5861-e208-d1d1-1e26b5e45a36/icon350x350.jpeg',
1
Javascript
Javascript
favor strict equality in http tests
c89b6ee347f0247254fb08999d06301937a965fd
<ide><path>test/parallel/test-http-agent.js <ide> server.listen(0, function() { <ide> for (var j = 0; j < M; j++) { <ide> http.get({ port: port, path: '/' }, function(res) { <ide> console.log('%d %d', responses, res.statusCode); <del> if (++responses == N * M) { <add> if (++responses === N * M) { <ide> console.error('Received all responses, closing server'); <ide> server.close(); <ide> } <ide><path>test/parallel/test-http-allow-req-after-204-res.js <ide> function nextRequest() { <ide> path: '/' <ide> }, function(response) { <ide> response.on('end', function() { <del> if (methods.length == 0) { <add> if (methods.length === 0) { <ide> console.error('close server'); <ide> server.close(); <ide> } else { <ide><path>test/parallel/test-http-client-abort.js <ide> server.listen(0, function() { <ide> console.log('Client response code ' + res.statusCode); <ide> <ide> res.resume(); <del> if (++responses == N) { <add> if (++responses === N) { <ide> console.log('All clients connected, destroying.'); <ide> requests.forEach(function(outReq) { <ide> console.log('abort'); <ide><path>test/parallel/test-http-client-timeout-agent.js <ide> server.listen(0, options.host, function() { <ide> <ide> process.on('exit', function() { <ide> console.error('done=%j sent=%j', requests_done, requests_sent); <del> assert.ok(requests_done == requests_sent, <del> 'timeout on http request called too much'); <add> assert.strictEqual(requests_done, requests_sent, <add> 'timeout on http request called too much'); <ide> }); <ide><path>test/parallel/test-http-exceptions.js <ide> var exception_count = 0; <ide> process.on('uncaughtException', function(err) { <ide> console.log('Caught an exception: ' + err); <ide> if (err.name === 'AssertionError') throw err; <del> if (++exception_count == 4) process.exit(0); <add> if (++exception_count === 4) process.exit(0); <ide> }); <ide> <ide><path>test/parallel/test-http-expect-continue.js <ide> server.on('listening', function() { <ide> assert.equal(body, test_res_body, 'Response body doesn\'t match.'); <ide> assert.ok('abcd' in res.headers, 'Response headers missing.'); <ide> outstanding_reqs--; <del> if (outstanding_reqs == 0) { <add> if (outstanding_reqs === 0) { <ide> server.close(); <ide> process.exit(); <ide> } <ide><path>test/parallel/test-http-get-pipeline-problem.js <ide> var total = 10; <ide> var requests = 0, responses = 0; <ide> <ide> var server = http.Server(function(req, res) { <del> if (++requests == total) { <add> if (++requests === total) { <ide> server.close(); <ide> } <ide> <ide> server.listen(0, function() { <ide> <ide> s.on('finish', function() { <ide> console.error('done ' + x); <del> if (++responses == total) { <add> if (++responses === total) { <ide> checkFiles(); <ide> } <ide> }); <ide><path>test/parallel/test-http-incoming-pipelined-socket-destroy.js <ide> server.listen(0, function() { <ide> var client = net.connect({ port: this.address().port }); <ide> var done = 0; <ide> server.on('requestDone', function() { <del> if (++done == seeds.length) { <add> if (++done === seeds.length) { <ide> server.close(); <ide> } <ide> }); <ide><path>test/parallel/test-http-legacy.js <ide> var body0 = ''; <ide> var body1 = ''; <ide> <ide> var server = http.createServer(function(req, res) { <del> if (responses_sent == 0) { <add> if (responses_sent === 0) { <ide> assert.equal('GET', req.method); <ide> assert.equal('/hello', url.parse(req.url).pathname); <ide> <ide> var server = http.createServer(function(req, res) { <ide> assert.equal('bar', req.headers['foo']); <ide> } <ide> <del> if (responses_sent == 1) { <add> if (responses_sent === 1) { <ide> assert.equal('POST', req.method); <ide> assert.equal('/world', url.parse(req.url).pathname); <ide> this.close(); <ide><path>test/parallel/test-http-malformed-request.js <ide> var server = http.createServer(function(req, res) { <ide> res.write('Hello World'); <ide> res.end(); <ide> <del> if (++nrequests_completed == nrequests_expected) server.close(); <add> if (++nrequests_completed === nrequests_expected) server.close(); <ide> }); <ide> server.listen(0); <ide> <ide><path>test/parallel/test-http-response-multiheaders.js <ide> const norepeat = [ <ide> <ide> const server = http.createServer(function(req, res) { <ide> var num = req.headers['x-num']; <del> if (num == 1) { <add> if (num === '1') { <ide> for (const name of norepeat) { <ide> res.setHeader(name, ['A', 'B']); <ide> } <ide> res.setHeader('X-A', ['A', 'B']); <del> } else if (num == 2) { <add> } else if (num === '2') { <ide> const headers = {}; <ide> for (const name of norepeat) { <ide> headers[name] = ['A', 'B']; <ide><path>test/parallel/test-http-server.js <ide> var server = http.createServer(function(req, res) { <ide> res.id = request_number; <ide> req.id = request_number++; <ide> <del> if (req.id == 0) { <add> if (req.id === 0) { <ide> assert.equal('GET', req.method); <ide> assert.equal('/hello', url.parse(req.url).pathname); <ide> assert.equal('world', qs.parse(url.parse(req.url).query).hello); <ide> assert.equal('b==ar', qs.parse(url.parse(req.url).query).foo); <ide> } <ide> <del> if (req.id == 1) { <add> if (req.id === 1) { <ide> assert.equal('POST', req.method); <ide> assert.equal('/quit', url.parse(req.url).pathname); <ide> } <ide> <del> if (req.id == 2) { <add> if (req.id === 2) { <ide> assert.equal('foo', req.headers['x-x']); <ide> } <ide> <del> if (req.id == 3) { <add> if (req.id === 3) { <ide> assert.equal('bar', req.headers['x-x']); <ide> this.close(); <ide> } <ide> server.on('listening', function() { <ide> c.on('data', function(chunk) { <ide> server_response += chunk; <ide> <del> if (requests_sent == 1) { <add> if (requests_sent === 1) { <ide> c.write('POST /quit HTTP/1.1\r\n\r\n'); <ide> requests_sent += 1; <ide> } <ide> <del> if (requests_sent == 2) { <add> if (requests_sent === 2) { <ide> c.write('GET / HTTP/1.1\r\nX-X: foo\r\n\r\n' + <ide> 'GET / HTTP/1.1\r\nX-X: bar\r\n\r\n'); <ide> // Note: we are making the connection half-closed here <ide><path>test/parallel/test-http-set-cookies.js <ide> var http = require('http'); <ide> var nresponses = 0; <ide> <ide> var server = http.createServer(function(req, res) { <del> if (req.url == '/one') { <add> if (req.url === '/one') { <ide> res.writeHead(200, [['set-cookie', 'A'], <ide> ['content-type', 'text/plain']]); <ide> res.end('one\n'); <ide> server.on('listening', function() { <ide> }); <ide> <ide> res.on('end', function() { <del> if (++nresponses == 2) { <add> if (++nresponses === 2) { <ide> server.close(); <ide> } <ide> }); <ide> server.on('listening', function() { <ide> }); <ide> <ide> res.on('end', function() { <del> if (++nresponses == 2) { <add> if (++nresponses === 2) { <ide> server.close(); <ide> } <ide> }); <ide><path>test/parallel/test-http-set-trailers.js <ide> server.on('listening', function() { <ide> c.end(); <ide> assert.ok(!/x-foo/.test(res_buffer), 'Trailer in HTTP/1.0 response.'); <ide> outstanding_reqs--; <del> if (outstanding_reqs == 0) { <add> if (outstanding_reqs === 0) { <ide> server.close(); <ide> process.exit(); <ide> } <ide> server.on('listening', function() { <ide> /0\r\nx-foo: bar\r\n\r\n$/.test(res_buffer), <ide> 'No trailer in HTTP/1.1 response.' <ide> ); <del> if (outstanding_reqs == 0) { <add> if (outstanding_reqs === 0) { <ide> server.close(); <ide> process.exit(); <ide> } <ide> server.on('listening', function() { <ide> //console.log(res.trailers); <ide> assert.ok('x-foo' in res.trailers, 'Client doesn\'t see trailers.'); <ide> outstanding_reqs--; <del> if (outstanding_reqs == 0) { <add> if (outstanding_reqs === 0) { <ide> server.close(); <ide> process.exit(); <ide> } <ide><path>test/parallel/test-http-timeout.js <ide> server.listen(0, function() { <ide> res.on('end', function() { <ide> count++; <ide> <del> if (count == 11) { <add> if (count === 11) { <ide> server.close(); <ide> } <ide> }); <ide><path>test/parallel/test-http-upgrade-server.js <ide> function testServer() { <ide> <ide> socket.on('data', function(d) { <ide> var data = d.toString('utf8'); <del> if (data == 'kill') { <add> if (data === 'kill') { <ide> socket.end(); <ide> } else { <ide> socket.write(data, 'utf8'); <ide> function test_upgrade_with_listener() { <ide> <ide> assert.equal('string', typeof data); <ide> <del> if (state == 1) { <add> if (state === 1) { <ide> assert.equal('HTTP/1.1 101', data.substr(0, 12)); <ide> assert.equal('WjN}|M(6', request_upgradeHead.toString('utf8')); <ide> conn.write('test', 'utf8'); <del> } else if (state == 2) { <add> } else if (state === 2) { <ide> assert.equal('test', data); <ide> conn.write('kill', 'utf8'); <ide> } <ide><path>test/pummel/test-http-upload-timeout.js <ide> server.on('request', function(req, res) { <ide> connections--; <ide> res.writeHead(200); <ide> res.end('done\n'); <del> if (connections == 0) { <add> if (connections === 0) { <ide> server.close(); <ide> } <ide> });
17
Javascript
Javascript
remove useless internalfs
3681ddd96744e46f12e11e3d5154ab4070e7290c
<ide><path>lib/fs.js <ide> const { <ide> } = errors.codes; <ide> <ide> const { FSReqCallback, statValues } = binding; <del>const internalFS = require('internal/fs/utils'); <ide> const { toPathIfFileURL } = require('internal/url'); <ide> const internalUtil = require('internal/util'); <ide> const { <ide> const { <ide> validateOffsetLengthRead, <ide> validateOffsetLengthWrite, <ide> validatePath <del>} = internalFS; <add>} = require('internal/fs/utils'); <ide> const { <ide> CHAR_FORWARD_SLASH, <ide> CHAR_BACKWARD_SLASH,
1
Ruby
Ruby
update queue_classic details
76056c627c1b3fa804f45a38a7af824b48791b33
<ide><path>activejob/lib/active_job/queue_adapters.rb <ide> module ActiveJob <ide> # * {Delayed Job}[https://github.com/collectiveidea/delayed_job] <ide> # * {Qu}[https://github.com/bkeepers/qu] <ide> # * {Que}[https://github.com/chanks/que] <del> # * {QueueClassic 2.x}[https://github.com/ryandotsmith/queue_classic/tree/v2.2.3] <add> # * {queue_classic}[https://github.com/QueueClassic/queue_classic] <ide> # * {Resque 1.x}[https://github.com/resque/resque/tree/1-x-stable] <ide> # * {Sidekiq}[http://sidekiq.org] <ide> # * {Sneakers}[https://github.com/jondot/sneakers] <ide> module ActiveJob <ide> # | Backburner | Yes | Yes | Yes | Yes | Job | Global | <ide> # | Delayed Job | Yes | Yes | Yes | Job | Global | Global | <ide> # | Que | Yes | Yes | Yes | Job | No | Job | <del> # | Queue Classic | Yes | Yes | No* | No | No | No | <add> # | queue_classic | Yes | Yes | No* | No | No | No | <ide> # | Resque | Yes | Yes | Yes (Gem) | Queue | Global | Yes | <ide> # | Sidekiq | Yes | Yes | Yes | Queue | No | Job | <ide> # | Sneakers | Yes | Yes | No | Queue | Queue | No | <ide> module ActiveJob <ide> # | Active Job | Yes | Yes | Yes | No | No | No | <ide> # <ide> # NOTE: <del> # Queue Classic does not support Job scheduling. However you can implement this <add> # queue_classic does not support Job scheduling. However you can implement this <ide> # yourself or you can use the queue_classic-later gem. See the documentation for <ide> # ActiveJob::QueueAdapters::QueueClassicAdapter. <ide> # <ide><path>activejob/lib/active_job/queue_adapters/queue_classic_adapter.rb <ide> <ide> module ActiveJob <ide> module QueueAdapters <del> # == Queue Classic adapter for Active Job <add> # == queue_classic adapter for Active Job <ide> # <ide> # queue_classic provides a simple interface to a PostgreSQL-backed message <ide> # queue. queue_classic specializes in concurrent locking and minimizing <ide> module QueueAdapters <ide> # production environment and that adding another dependency (e.g. redis, <ide> # beanstalkd, 0mq) is undesirable. <ide> # <del> # Read more about Queue Classic {here}[https://github.com/ryandotsmith/queue_classic]. <add> # Read more about queue_classic {here}[https://github.com/QueueClassic/queue_classic]. <ide> # <del> # To use Queue Classic set the queue_adapter config to +:queue_classic+. <add> # To use queue_classic set the queue_adapter config to +:queue_classic+. <ide> # <ide> # Rails.application.config.active_job.queue_adapter = :queue_classic <ide> class QueueClassicAdapter <ide> def enqueue(job) #:nodoc: <ide> def enqueue_at(job, timestamp) #:nodoc: <ide> queue = build_queue(job.queue_name) <ide> unless queue.respond_to?(:enqueue_at) <del> raise NotImplementedError, 'To be able to schedule jobs with Queue Classic ' \ <add> raise NotImplementedError, 'To be able to schedule jobs with queue_classic ' \ <ide> 'the QC::Queue needs to respond to `enqueue_at(timestamp, method, *args)`. ' <ide> 'You can implement this yourself or you can use the queue_classic-later gem.' <ide> end
2
PHP
PHP
use new uuid factory
b90fa4eeb1338b3d871c2b0f54cffff5265a061a
<ide><path>src/Illuminate/Support/Str.php <ide> namespace Illuminate\Support; <ide> <ide> use Ramsey\Uuid\Uuid; <add>use Ramsey\Uuid\UuidFactory; <ide> use Illuminate\Support\Traits\Macroable; <ide> use Ramsey\Uuid\Generator\CombGenerator; <ide> use Ramsey\Uuid\Codec\TimestampFirstCombCodec; <ide> public static function orderedUuid() <ide> return call_user_func(static::$uuidFactory); <ide> } <ide> <del> $factory = Uuid::getFactory(); <add> $factory = new UuidFactory(); <ide> <ide> $factory->setRandomGenerator(new CombGenerator( <ide> $factory->getRandomGenerator(),
1
Ruby
Ruby
fix logic in `check_binary_arches`
1678a3785e1e04a6976e723a9e176defd2ab41f4
<ide><path>Library/Homebrew/formula_cellar_checks.rb <ide> def check_binary_arches(formula) <ide> mismatches = keg.binary_executable_or_library_files.reject do |file| <ide> file.arch == Hardware::CPU.arch <ide> end <add> return if mismatches.empty? <ide> <ide> compatible_universal_binaries = mismatches.select do |file| <ide> file.arch == :universal && file.archs.include?(Hardware::CPU.arch) <ide> end <ide> mismatches -= compatible_universal_binaries <ide> <del> return if mismatches.empty? && compatible_universal_binaries.empty? <del> return if mismatches.empty? && tap_audit_exception(:universal_binary_allowlist, formula.name) <add> universal_binaries_expected = tap_audit_exception(:universal_binary_allowlist, formula.name) <add> return if mismatches.empty? && universal_binaries_expected <ide> <ide> s = "" <ide> <ide> def check_binary_arches(formula) <ide> EOS <ide> end <ide> <del> unless compatible_universal_binaries.empty? <add> if !compatible_universal_binaries.empty? && !universal_binaries_expected <ide> s += <<~EOS <ide> Unexpected universal binaries were found. <ide> The offending files are:
1
Python
Python
remove messy handling of output tuple in np.unique
3c05221dd443323e7948eadf8105c0b52e760f70
<ide><path>numpy/lib/arraysetops.py <ide> def ediff1d(ary, to_end=None, to_begin=None): <ide> return result <ide> <ide> <add>def _unpack_tuple(x): <add> """ Unpacks one-element tuples for use as return values """ <add> if len(x) == 1: <add> return x[0] <add> else: <add> return x <add> <add> <ide> def unique(ar, return_index=False, return_inverse=False, <ide> return_counts=False, axis=None): <ide> """ <ide> def unique(ar, return_index=False, return_inverse=False, <ide> """ <ide> ar = np.asanyarray(ar) <ide> if axis is None: <del> return _unique1d(ar, return_index, return_inverse, return_counts) <add> ret = _unique1d(ar, return_index, return_inverse, return_counts) <add> return _unpack_tuple(ret) <add> <ide> if not (-ar.ndim <= axis < ar.ndim): <ide> raise ValueError('Invalid axis kwarg specified for unique') <ide> <ide> def reshape_uniq(uniq): <ide> <ide> output = _unique1d(consolidated, return_index, <ide> return_inverse, return_counts) <del> if not (return_index or return_inverse or return_counts): <del> return reshape_uniq(output) <del> else: <del> uniq = reshape_uniq(output[0]) <del> return (uniq,) + output[1:] <add> output = (reshape_uniq(output[0]),) + output[1:] <add> return _unpack_tuple(output) <add> <ide> <ide> def _unique1d(ar, return_index=False, return_inverse=False, <ide> return_counts=False): <ide> def _unique1d(ar, return_index=False, return_inverse=False, <ide> ar = np.asanyarray(ar).flatten() <ide> <ide> optional_indices = return_index or return_inverse <del> optional_returns = optional_indices or return_counts <ide> <ide> if ar.size == 0: <del> if not optional_returns: <del> ret = ar <del> else: <del> ret = (ar,) <del> if return_index: <del> ret += (np.empty(0, np.intp),) <del> if return_inverse: <del> ret += (np.empty(0, np.intp),) <del> if return_counts: <del> ret += (np.empty(0, np.intp),) <add> ret = (ar,) <add> if return_index: <add> ret += (np.empty(0, np.intp),) <add> if return_inverse: <add> ret += (np.empty(0, np.intp),) <add> if return_counts: <add> ret += (np.empty(0, np.intp),) <ide> return ret <ide> <ide> if optional_indices: <ide> def _unique1d(ar, return_index=False, return_inverse=False, <ide> aux = ar <ide> flag = np.concatenate(([True], aux[1:] != aux[:-1])) <ide> <del> if not optional_returns: <del> ret = aux[flag] <del> else: <del> ret = (aux[flag],) <del> if return_index: <del> ret += (perm[flag],) <del> if return_inverse: <del> iflag = np.cumsum(flag) - 1 <del> inv_idx = np.empty(ar.shape, dtype=np.intp) <del> inv_idx[perm] = iflag <del> ret += (inv_idx,) <del> if return_counts: <del> idx = np.concatenate(np.nonzero(flag) + ([ar.size],)) <del> ret += (np.diff(idx),) <add> ret = (aux[flag],) <add> if return_index: <add> ret += (perm[flag],) <add> if return_inverse: <add> iflag = np.cumsum(flag) - 1 <add> inv_idx = np.empty(ar.shape, dtype=np.intp) <add> inv_idx[perm] = iflag <add> ret += (inv_idx,) <add> if return_counts: <add> idx = np.concatenate(np.nonzero(flag) + ([ar.size],)) <add> ret += (np.diff(idx),) <ide> return ret <ide> <add> <ide> def intersect1d(ar1, ar2, assume_unique=False): <ide> """ <ide> Find the intersection of two arrays.
1
PHP
PHP
update version constant
e405c532a06f8de4503d78fcdab77046177497cc
<ide><path>src/Illuminate/Foundation/Application.php <ide> class Application extends Container implements HttpKernelInterface, ResponsePrep <ide> * <ide> * @var string <ide> */ <del> const VERSION = '4.0.7'; <add> const VERSION = '4.1-dev'; <ide> <ide> /** <ide> * Indicates if the application has "booted".
1
Text
Text
update widget examples.
4731a00c3e23bb5c4dd8d0e43a95e777a8a8f02a
<ide><path>model_cards/ethanyt/guwenbert-base/README.md <ide> license: "apache-2.0" <ide> pipeline_tag: "fill-mask" <ide> widget: <ide> - text: "[MASK]ๅคชๅ…ƒไธญ๏ผŒๆญฆ้™ตไบบๆ•้ฑผไธบไธšใ€‚" <del>- text: "ๅฑฑไธๅœจ[MASK]๏ผŒๆœ‰ไป™ๅˆ™ๅใ€‚" <add>- text: "้—ฎๅพๅคซไปฅๅ‰่ทฏ๏ผŒๆจๆ™จๅ…‰ไน‹[MASK]ๅพฎใ€‚" <ide> - text: "ๆต”้˜ณๆฑŸๅคดๅคœ้€ๅฎข๏ผŒๆžซๅถ[MASK]่Šฑ็ง‹็‘Ÿ็‘Ÿใ€‚" <ide> --- <ide> <ide><path>model_cards/ethanyt/guwenbert-large/README.md <ide> license: "apache-2.0" <ide> pipeline_tag: "fill-mask" <ide> widget: <ide> - text: "[MASK]ๅคชๅ…ƒไธญ๏ผŒๆญฆ้™ตไบบๆ•้ฑผไธบไธšใ€‚" <del>- text: "ๅฑฑไธๅœจ[MASK]๏ผŒๆœ‰ไป™ๅˆ™ๅใ€‚" <add>- text: "้—ฎๅพๅคซไปฅๅ‰่ทฏ๏ผŒๆจๆ™จๅ…‰ไน‹[MASK]ๅพฎใ€‚" <ide> - text: "ๆต”้˜ณๆฑŸๅคดๅคœ้€ๅฎข๏ผŒๆžซๅถ[MASK]่Šฑ็ง‹็‘Ÿ็‘Ÿใ€‚" <ide> --- <ide>
2
Python
Python
fix typos in percentile
eb12b7106fb2962167627af21bc0bef24f6f650d
<ide><path>numpy/lib/function_base.py <ide> def percentile(a, q, axis=None, out=None, <ide> Notes <ide> ----- <ide> Given a vector ``V`` of length ``N``, the ``q``-th percentile of <del> ``V`` is the value ``q/100`` of the way from the mimumum to the <del> maximum in in a sorted copy of ``V``. The values and distances of <add> ``V`` is the value ``q/100`` of the way from the minimum to the <add> maximum in a sorted copy of ``V``. The values and distances of <ide> the two nearest neighbors as well as the `interpolation` parameter <ide> will determine the percentile if the normalized ranking does not <ide> match the location of ``q`` exactly. This function is the same as <ide><path>numpy/lib/nanfunctions.py <ide> def nanpercentile(a, q, axis=None, out=None, overwrite_input=False, <ide> Notes <ide> ----- <ide> Given a vector ``V`` of length ``N``, the ``q``-th percentile of <del> ``V`` is the value ``q/100`` of the way from the mimumum to the <del> maximum in in a sorted copy of ``V``. The values and distances of <add> ``V`` is the value ``q/100`` of the way from the minimum to the <add> maximum in a sorted copy of ``V``. The values and distances of <ide> the two nearest neighbors as well as the `interpolation` parameter <ide> will determine the percentile if the normalized ranking does not <ide> match the location of ``q`` exactly. This function is the same as
2
Javascript
Javascript
add disconnectoutlet method to controller
933b2b4a6eb4f82884c4ec5c567890ffb458beab
<ide><path>packages/ember-views/lib/system/controller.js <ide> Ember.ControllerMixin.reopen(/** @scope Ember.ControllerMixin.prototype */ { <ide> Ember.assert("The name you supplied " + name + " did not resolve to a controller " + name + 'Controller', (!!controller && !!context) || !context); <ide> } <ide> <del> if (controller && context) { controller.set('content', context); } <del> view = viewClass.create(); <add> if (controller && context) { set(controller, 'content', context); } <add> <add> view = this.createOutletView(outletName, viewClass); <add> <ide> if (controller) { set(view, 'controller', controller); } <ide> set(this, outletName, view); <ide> <ide> Ember.ControllerMixin.reopen(/** @scope Ember.ControllerMixin.prototype */ { <ide> controllerName = controllerNames[i] + 'Controller'; <ide> set(this, controllerName, get(controllers, controllerName)); <ide> } <add> }, <add> <add> /** <add> `disconnectOutlet` removes previously attached view from given outlet. <add> <add> @param {String} outletName the outlet name. (optional) <add> */ <add> disconnectOutlet: function(outletName) { <add> outletName = outletName || 'view'; <add> <add> set(this, outletName, null); <add> }, <add> <add> /** <add> `createOutletView` is a hook you may want to override if you need to do <add> something special with the view created for the outlet. For example <add> you may want to implement views sharing across outlets. <add> */ <add> createOutletView: function(outletName, viewClass) { <add> return viewClass.create(); <ide> } <ide> }); <del> <ide><path>packages/ember-views/tests/system/controller_test.js <ide> test("connectControllers injects other controllers", function() { <ide> equal(controller.get('postController'), postController, "should connect postController"); <ide> equal(controller.get('commentController'), commentController, "should connect commentController"); <ide> }); <add> <add>test("can disconnect outlet from controller", function() { <add> var appController = TestApp.ApplicationController.create({ <add> controllers: {}, <add> namespace: TestApp <add> }); <add> <add> var view = appController.connectOutlet('post'); <add> <add> equal(appController.get('view'), view, "the app controller's view is set"); <add> <add> appController.disconnectOutlet(); <add> <add> equal(appController.get('view'), null, "the app controller's view is null"); <add> <add> view = appController.connectOutlet({outletName: 'master', name: 'post'}); <add> <add> equal(appController.get('master'), view, "the app controller's master view is set"); <add> <add> appController.disconnectOutlet('master'); <add> <add> equal(appController.get('master'), null, "the app controller's master view is null"); <add>});
2
Ruby
Ruby
add check for osx-gcc-installer
ef054a2d029199a1a67c45c7e44ee82f0f6a828c
<ide><path>Library/Homebrew/cmd/doctor.rb <ide> def __check_clt_up_to_date <ide> end <ide> end <ide> <add>def check_for_osx_gcc_installer <add> if (MacOS.version < 10.7 || MacOS::Xcode.version < "4.1") && \ <add> MacOS.clang_version == "2.1" then <<-EOS.undent <add> You have osx-gcc-installer installed. <add> Homebrew doesn't support osx-gcc-installer, and it is known to cause <add> some builds to fail. <add> Please install Xcode #{MacOS::Xcode.latest_version}. <add> EOS <add> end <add>end <add> <ide> def check_for_stray_developer_directory <ide> # if the uninstaller script isn't there, it's a good guess neither are <ide> # any troublesome leftover Xcode files
1
Ruby
Ruby
rename some variables
12ceb4581aeef1638b9e38545210bd0004adbb8f
<ide><path>activerecord/lib/active_record/fixtures.rb <ide> class FixtureClassNotFound < ActiveRecord::ActiveRecordError #:nodoc: <ide> # <ide> # Any fixture labeled "DEFAULTS" is safely ignored. <ide> class Fixtures <add> #-- <add> # NOTE: an instance of Fixtures can be called fixture_set, it is normally stored in a single YAML file and possibly in a folder with the same name. <add> #++ <ide> MAX_ID = 2 ** 30 - 1 <ide> <ide> @@all_cached_fixtures = Hash.new { |h,k| h[k] = {} } <ide> <del> def self.default_fixture_model_name(fixture_name) # :nodoc: <add> def self.default_fixture_model_name(fixture_set_name) # :nodoc: <ide> ActiveRecord::Base.pluralize_table_names ? <del> fixture_name.singularize.camelize : <del> fixture_name.camelize <add> fixture_set_name.singularize.camelize : <add> fixture_set_name.camelize <ide> end <ide> <del> def self.default_fixture_table_name(fixture_name) # :nodoc: <del> "#{ActiveRecord::Base.table_name_prefix}"\ <del> "#{fixture_name.tr('/', '_')}#{ActiveRecord::Base.table_name_suffix}".to_sym <add> def self.default_fixture_table_name(fixture_set_name) # :nodoc: <add> "#{ ActiveRecord::Base.table_name_prefix }"\ <add> "#{ fixture_set_name.tr('/', '_') }"\ <add> "#{ ActiveRecord::Base.table_name_suffix }".to_sym <ide> end <ide> <ide> def self.reset_cache <ide> def self.cache_fixtures(connection, fixtures_map) <ide> cache_for_connection(connection).update(fixtures_map) <ide> end <ide> <del> def self.instantiate_fixtures(object, fixtures, load_instances = true) <add> def self.instantiate_fixtures(object, fixture_set, load_instances = true) <ide> if load_instances <del> fixtures.each do |name, fixture| <add> fixture_set.each do |fixture_name, fixture| <ide> begin <del> object.instance_variable_set "@#{name}", fixture.find <add> object.instance_variable_set "@#{fixture_name}", fixture.find <ide> rescue FixtureClassNotFound <ide> nil <ide> end <ide> def self.instantiate_fixtures(object, fixtures, load_instances = true) <ide> end <ide> <ide> def self.instantiate_all_loaded_fixtures(object, load_instances = true) <del> all_loaded_fixtures.each_value do |fixtures| <del> instantiate_fixtures(object, fixtures, load_instances) <add> all_loaded_fixtures.each_value do |fixture_set| <add> instantiate_fixtures(object, fixture_set, load_instances) <ide> end <ide> end <ide> <ide> cattr_accessor :all_loaded_fixtures <ide> self.all_loaded_fixtures = {} <ide> <del> def self.create_fixtures(fixtures_directory, table_names, class_names = {}) <del> table_names = Array(table_names).map(&:to_s) <add> def self.create_fixtures(fixtures_directory, fixture_set_names, class_names = {}) <add> fixture_set_names = Array(fixture_set_names).map(&:to_s) <ide> class_names = class_names.stringify_keys <ide> <ide> # FIXME: Apparently JK uses this. <ide> connection = block_given? ? yield : ActiveRecord::Base.connection <ide> <del> files_to_read = table_names.reject { |table_name| <del> fixture_is_cached?(connection, table_name) <add> files_to_read = fixture_set_names.reject { |fs_name| <add> fixture_is_cached?(connection, fs_name) <ide> } <ide> <ide> unless files_to_read.empty? <ide> connection.disable_referential_integrity do <ide> fixtures_map = {} <ide> <del> fixture_files = files_to_read.map do |path| <del> fixture_name = path <del> <del> fixtures_map[fixture_name] = new( # ActiveRecord::Fixtures.new <add> fixture_sets = files_to_read.map do |fs_name| <add> fixtures_map[fs_name] = new( # ActiveRecord::Fixtures.new <ide> connection, <del> fixture_name, <del> class_names[fixture_name.to_s] || default_fixture_model_name(fixture_name), <del> ::File.join(fixtures_directory, path)) <add> fs_name, <add> class_names[fs_name] || default_fixture_model_name(fs_name), <add> ::File.join(fixtures_directory, fs_name)) <ide> end <ide> <ide> all_loaded_fixtures.update(fixtures_map) <ide> <ide> connection.transaction(:requires_new => true) do <del> fixture_files.each do |ff| <del> conn = ff.model_class.respond_to?(:connection) ? ff.model_class.connection : connection <del> table_rows = ff.table_rows <add> fixture_sets.each do |fs| <add> conn = fs.model_class.respond_to?(:connection) ? fs.model_class.connection : connection <add> table_rows = fs.table_rows <ide> <ide> table_rows.keys.each do |table| <ide> conn.delete "DELETE FROM #{conn.quote_table_name(table)}", 'Fixture Delete' <ide> end <ide> <del> table_rows.each do |table_name,rows| <add> table_rows.each do |fixture_set_name, rows| <ide> rows.each do |row| <del> conn.insert_fixture(row, table_name) <add> conn.insert_fixture(row, fixture_set_name) <ide> end <ide> end <ide> end <ide> <ide> # Cap primary key sequences to max(pk). <ide> if connection.respond_to?(:reset_pk_sequence!) <del> fixture_files.each do |ff| <del> connection.reset_pk_sequence!(ff.table_name) <add> fixture_sets.each do |fs| <add> connection.reset_pk_sequence!(fs.table_name) <ide> end <ide> end <ide> end <ide> <ide> cache_fixtures(connection, fixtures_map) <ide> end <ide> end <del> cached_fixtures(connection, table_names) <add> cached_fixtures(connection, fixture_set_names) <ide> end <ide> <ide> # Returns a consistent, platform-independent identifier for +label+. <ide> def self.identify(label) <ide> <ide> attr_reader :table_name, :name, :fixtures, :model_class <ide> <del> def initialize(connection, fixture_name, class_name, fixture_path) <del> @connection = connection <del> @fixture_path = fixture_path <del> @name = fixture_name <del> @class_name = class_name <del> <del> @fixtures = {} <add> def initialize(connection, name, class_name, path) <add> @fixtures = {} # Ordered hash <add> @name = name <add> @path = path <ide> <del> # Should be an AR::Base type class <del> if class_name.is_a?(Class) <add> if class_name.is_a?(Class) # TODO: Should be an AR::Base type class, or any? <ide> @model_class = class_name <ide> else <ide> @model_class = class_name.constantize rescue nil <ide> end <ide> <del> @connection = model_class.connection if model_class && model_class.respond_to?(:connection) <add> @connection = ( model_class.respond_to?(:connection) ? <add> model_class.connection : connection ) <ide> <ide> @table_name = ( model_class.respond_to?(:table_name) ? <ide> model_class.table_name : <del> self.class.default_fixture_table_name(fixture_name) ) <add> self.class.default_fixture_table_name(name) ) <ide> <ide> read_fixture_files <ide> end <ide> def table_rows <ide> if model_class && model_class < ActiveRecord::Model <ide> # fill in timestamp columns if they aren't specified and the model is set to record_timestamps <ide> if model_class.record_timestamps <del> timestamp_column_names.each do |name| <del> row[name] = now unless row.key?(name) <add> timestamp_column_names.each do |c_name| <add> row[c_name] = now unless row.key?(c_name) <ide> end <ide> end <ide> <ide> def column_names <ide> end <ide> <ide> def read_fixture_files <del> yaml_files = Dir["#{@fixture_path}/**/*.yml"].select { |f| <add> yaml_files = Dir["#{@path}/**/*.yml"].select { |f| <ide> ::File.file?(f) <ide> } + [yaml_file_path] <ide> <ide> yaml_files.each do |file| <ide> Fixtures::File.open(file) do |fh| <del> fh.each do |name, row| <del> fixtures[name] = ActiveRecord::Fixture.new(row, model_class) <add> fh.each do |fixture_name, row| <add> fixtures[fixture_name] = ActiveRecord::Fixture.new(row, model_class) <ide> end <ide> end <ide> end <ide> end <ide> <ide> def yaml_file_path <del> "#{@fixture_path}.yml" <add> "#{@path}.yml" <ide> end <ide> <ide> end <ide> module TestFixtures <ide> class_attribute :fixture_table_names <ide> class_attribute :fixture_class_names <ide> class_attribute :use_transactional_fixtures <del> class_attribute :use_instantiated_fixtures # true, false, or :no_instances <add> class_attribute :use_instantiated_fixtures # true, false, or :no_instances <ide> class_attribute :pre_loaded_fixtures <ide> <ide> self.fixture_table_names = [] <ide> self.use_transactional_fixtures = true <ide> self.use_instantiated_fixtures = false <ide> self.pre_loaded_fixtures = false <ide> <del> self.fixture_class_names = Hash.new do |h, fixture_name| <del> fixture_name = fixture_name.to_s <del> h[fixture_name] = ActiveRecord::Fixtures.default_fixture_model_name(fixture_name) <add> self.fixture_class_names = Hash.new do |h, fixture_set_name| <add> h[fixture_set_name] = ActiveRecord::Fixtures.default_fixture_model_name(fixture_set_name) <ide> end <ide> end <ide> <ide> def set_fixture_class(class_names = {}) <ide> self.fixture_class_names = self.fixture_class_names.merge(class_names.stringify_keys) <ide> end <ide> <del> def fixtures(*fixture_names) <del> if fixture_names.first == :all <del> fixture_names = Dir["#{fixture_path}/**/*.yml"].map { |f| <add> def fixtures(*fixture_set_names) <add> if fixture_set_names.first == :all <add> fixture_set_names = Dir["#{fixture_path}/**/*.yml"].map { |f| <ide> File.basename f, '.yml' <ide> } <ide> else <del> fixture_names = fixture_names.flatten.map { |n| n.to_s } <add> fixture_set_names = fixture_set_names.flatten.map { |n| n.to_s } <ide> end <ide> <del> self.fixture_table_names |= fixture_names <del> require_fixture_classes(fixture_names) <del> setup_fixture_accessors(fixture_names) <add> self.fixture_table_names |= fixture_set_names <add> require_fixture_classes(fixture_set_names) <add> setup_fixture_accessors(fixture_set_names) <ide> end <ide> <ide> def try_to_load_dependency(file_name) <ide> def try_to_load_dependency(file_name) <ide> end <ide> end <ide> <del> def require_fixture_classes(fixture_names = nil) <del> (fixture_names || fixture_table_names).each do |fixture_name| <del> file_name = fixture_name.to_s <add> def require_fixture_classes(fixture_set_names = nil) <add> if fixture_set_names <add> fixture_set_names = fixture_set_names.map { |n| n.to_s } <add> else <add> fixture_set_names = fixture_table_names <add> end <add> <add> fixture_set_names.each do |file_name| <ide> file_name = file_name.singularize if ActiveRecord::Base.pluralize_table_names <ide> try_to_load_dependency(file_name) <ide> end <ide> end <ide> <del> def setup_fixture_accessors(fixture_names = nil) <del> fixture_names = Array(fixture_names || fixture_table_names) <add> def setup_fixture_accessors(fixture_set_names = nil) <add> fixture_set_names = Array(fixture_set_names || fixture_table_names) <ide> methods = Module.new do <del> fixture_names.each do |fixture_name| <del> fixture_name = fixture_name.to_s <del> accessor_name = fixture_name.tr('/', '_').to_sym <add> fixture_set_names.each do |fs_name| <add> fs_name = fs_name.to_s <add> accessor_name = fs_name.tr('/', '_').to_sym <ide> <del> define_method(accessor_name) do |*fixtures| <del> force_reload = fixtures.pop if fixtures.last == true || fixtures.last == :reload <add> define_method(accessor_name) do |*fixture_names| <add> force_reload = fixture_names.pop if fixture_names.last == true || fixture_names.last == :reload <ide> <del> @fixture_cache[fixture_name] ||= {} <add> @fixture_cache[fs_name] ||= {} <ide> <del> instances = fixtures.map do |fixture| <del> @fixture_cache[fixture_name].delete(fixture) if force_reload <add> instances = fixture_names.map do |f_name| <add> f_name = f_name.to_s <add> @fixture_cache[fs_name].delete(f_name) if force_reload <ide> <del> if @loaded_fixtures[fixture_name][fixture.to_s] <del> @fixture_cache[fixture_name][fixture] ||= @loaded_fixtures[fixture_name][fixture.to_s].find <add> if @loaded_fixtures[fs_name][f_name] <add> @fixture_cache[fs_name][f_name] ||= @loaded_fixtures[fs_name][f_name].find <ide> else <del> raise StandardError, "No entry named '#{fixture}' found for fixture collection '#{fixture_name}'" <add> raise StandardError, "No fixture named '#{f_name}' found for fixture set '#{fs_name}'" <ide> end <ide> end <ide> <ide> def instantiate_fixtures <ide> ActiveRecord::Fixtures.instantiate_all_loaded_fixtures(self, load_instances?) <ide> else <ide> raise RuntimeError, 'Load fixtures before instantiating them.' if @loaded_fixtures.nil? <del> @loaded_fixtures.each_value do |fixtures| <del> ActiveRecord::Fixtures.instantiate_fixtures(self, fixtures, load_instances?) <add> @loaded_fixtures.each_value do |fixture_set| <add> ActiveRecord::Fixtures.instantiate_fixtures(self, fixture_set, load_instances?) <ide> end <ide> end <ide> end <ide><path>activerecord/test/cases/helper.rb <ide> class ActiveSupport::TestCase <ide> self.use_instantiated_fixtures = false <ide> self.use_transactional_fixtures = true <ide> <del> def create_fixtures(*table_names, &block) <del> ActiveRecord::Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names, fixture_class_names, &block) <add> def create_fixtures(*fixture_set_names, &block) <add> ActiveRecord::Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, fixture_set_names, fixture_class_names, &block) <ide> end <ide> end <ide>
2
Python
Python
improve ndarray.shape property documentation
db59c45e5d02877bb246838a7cb277e5e3eed48c
<ide><path>numpy/add_newdocs.py <ide> def luf(lamdaexpr, *args, **kwargs): <ide> """ <ide> Tuple of array dimensions. <ide> <add> As with `numpy.reshape`, one shape dimension can be -1. In this case, the value is <add> inferred from the length of the array and remaining dimensions. <ide> Notes <ide> ----- <ide> May be used to "reshape" the array, as long as this would not <ide> require a change in the total number of elements <del> <add> Using `numpy.reshape` or `ndarray.reshape` should always be preferred. <add> Setting the shape directly is not really a safe thing to do. <ide> Examples <ide> -------- <ide> >>> x = np.array([1, 2, 3, 4]) <ide> def luf(lamdaexpr, *args, **kwargs): <ide> Traceback (most recent call last): <ide> File "<stdin>", line 1, in <module> <ide> ValueError: total size of new array must be unchanged <add> See Also <add> -------- <add> numpy.reshape : equivalent function <add> ndarray.reshape : equivalent function <ide> <ide> """)) <ide>
1
Text
Text
add release date of rails 3.2.0 to documentation
6d426b103580c80902ab64849cce7960107d7d70
<ide><path>actionpack/CHANGELOG.md <ide> This is a behavior change, previously the hidden tag had a value of the disabled checkbox. <ide> *Tadas Tamosauskas* <ide> <del>## Rails 3.2.0 (unreleased) ## <add>## Rails 3.2.0 (January 20, 2012) ## <ide> <ide> * Add `config.action_dispatch.default_charset` to configure default charset for ActionDispatch::Response. *Carlos Antonio da Silva* <ide> <ide><path>activemodel/CHANGELOG.md <del>## Rails 3.2.0 (unreleased) ## <add>## Rails 3.2.0 (January 20, 2012) ## <ide> <ide> * Deprecated `define_attr_method` in `ActiveModel::AttributeMethods`, because this only existed to <ide> support methods like `set_table_name` in Active Record, which are themselves being deprecated. <ide><path>activerecord/CHANGELOG.md <ide> <ide> * PostgreSQL hstore types are automatically deserialized from the database. <ide> <del>## Rails 3.2.0 (unreleased) ## <add>## Rails 3.2.0 (January 20, 2012) ## <ide> <ide> * Added a `with_lock` method to ActiveRecord objects, which starts <ide> a transaction, locks the object (pessimistically) and yields to the block. <ide><path>activeresource/CHANGELOG.md <del>## Rails 3.2.0 (unreleased) ## <add>## Rails 3.2.0 (January 20, 2012) ## <ide> <ide> * Redirect responses: 303 See Other and 307 Temporary Redirect now behave like <ide> 301 Moved Permanently and 302 Found. GH #3302. <ide><path>activesupport/CHANGELOG.md <ide> * BufferedLogger is deprecated. Use ActiveSupport::Logger, or the logger <ide> from Ruby stdlib. <ide> <del>## Rails 3.2.0 (unreleased) ## <add>## Rails 3.2.0 (January 20, 2012) ## <ide> <ide> * Add ActiveSupport::Cache::NullStore for use in development and testing. *Brian Durand* <ide> <ide><path>railties/CHANGELOG.md <ide> <ide> * Rails::Plugin has gone. Instead of adding plugins to vendor/plugins use gems or bundler with path or git dependencies. *Santiago Pastorino* <ide> <del>## Rails 3.2.0 (unreleased) ## <add>## Rails 3.2.0 (January 20, 2012) ## <ide> <ide> * Turn gem has been removed from default Gemfile. We still looking for a best presentation for tests output. *Guillermo Iguaran* <ide>
6
Javascript
Javascript
fix hash returning 0 for large strings
f443e2df3785a2a54abc49811e29ed8ca83d4803
<ide><path>dist/Immutable.dev.js <ide> function cachedHashString(string) { <ide> function hashString(string) { <ide> var hash = 0; <ide> for (var ii = 0; ii < string.length; ii++) { <del> hash = (31 * hash + string.charCodeAt(ii)); <add> hash = (31 * hash + string.charCodeAt(ii)) % HASH_MAX_VAL; <ide> } <del> return hash % HASH_MAX_VAL; <add> return hash; <ide> } <ide> var HASH_MAX_VAL = 0x100000000; <ide> var STRING_HASH_CACHE_MIN_STRLEN = 16; <ide><path>dist/Immutable.js <ide> * of patent rights can be found in the PATENTS file in the same directory. <ide> */ <ide> function t(){function t(t,e,r,n){var i;if(n){var u=n.prototype;i=$.create(u)}else i=t.prototype;return $.keys(e).forEach(function(t){i[t]=e[t]}),$.keys(r).forEach(function(e){t[e]=r[e]}),i.constructor=t,t.prototype=i,t}function e(t,e,r,n){return $.getPrototypeOf(e)[r].apply(t,n)}function r(t,r,n){e(t,r,"constructor",n)}function n(){return Object.create(ne)}function i(t){var e=Object.create(se);return e.__reversedIndices=t?t.__reversedIndices:!1,e}function u(t,e,r,n){var i=t.get?t.get(e[n],ve):ve;return i===ve?r:++n===e.length?i:u(i,e,r,n)}function s(t,e,r){return(0===t||null!=r&&-r>=t)&&(null==e||null!=r&&e>=r)}function a(t,e){return 0>t?Math.max(0,e+t):e?Math.min(e,t):t}function h(t,e){return null==t?e:0>t?Math.max(0,e+t):e?Math.min(e,t):t}function o(t){return t}function c(t,e){return[e,t]}function f(){return!0}function l(){return this}function _(t){return(t||0)+1}function v(t,e,r,n,i){var u=t.__makeSequence();return u.__iterateUncached=function(u,s,a){var h=0,o=t.__iterate(function(t,i,s){if(e.call(r,t,i,s)){if(u(t,n?i:h,s)===!1)return!1;h++}},s,a);return i?o:h},u}function g(t){return function(){return!t.apply(this,arguments)}}function p(t){return"string"==typeof t?JSON.stringify(t):t}function m(t,e){for(var r="";e;)1&e&&(r+=t),(e>>=1)&&(t+=t);return r}function d(t,e){return t>e?1:e>t?-1:0}function y(t){I(1/0!==t,"Cannot perform this action with an infinite sequence.")}function w(t,e){return t===e?0!==t||0!==e||1/t===1/e:t!==t?e!==e:t instanceof ee?t.equals(e):!1}function I(t,e){if(!t)throw Error(e)}function D(t,e,r){var n=t._rootData.updateIn(t._keyPath,e),i=t._keyPath||[];return t._onChange&&t._onChange.call(void 0,n,t._rootData,r?i.concat(r):i),new oe(n,t._keyPath,t._onChange)}function O(){}function b(t){for(var e=t.length,r=Array(e),n=0;e>n;n++)r[n]=t[n];return r}function M(t){return Se.value=t,Se}function k(t,e,r){var n=Object.create(me);return n.length=t,n._root=e,n.__ownerID=r,n}function S(t,e,r){var n=M(),i=x(t._root,t.__ownerID,0,W(e),e,r,n),u=t.length+(n.value?r===ve?-1:1:0);return t.__ownerID?(t.length=u,t._root=i,t):i?i===t._root?t:k(u,i):ge.empty() <del>}function x(t,e,r,n,i,u,s){return t?t.update(e,r,n,i,u,s):u===ve?t:(s&&(s.value=!0),new be(e,n,[i,u]))}function E(t){return t.constructor===be||t.constructor===De}function C(t,e,r,n,i){if(t.hash===n)return new De(e,n,[t.entry,i]);var u,s=t.hash>>>r&_e,a=n>>>r&_e,h=s===a?[C(t,e,r+fe,n,i)]:(u=new be(e,n,i),a>s?[t,u]:[u,t]);return new de(e,1<<s|1<<a,h)}function A(t,e,r){for(var n=[],i=0;r.length>i;i++){var u=r[i];u&&n.push(Array.isArray(u)?ee(u).fromEntries():ee(u))}return j(t,e,n)}function q(t){return function(e,r){return e&&e.mergeDeepWith?e.mergeDeepWith(t,r):t?t(e,r):r}}function j(t,e,r){return 0===r.length?t:t.withMutations(function(t){for(var n=e?function(r,n){var i=t.get(n,ve);t.set(n,i===ve?r:e(i,r))}:function(e,r){t.set(r,e)},i=0;r.length>i;i++)r[i].forEach(n)})}function P(t,e,r,n){var i=e[n],u=t.get?t.get(i,ve):ve;return u===ve&&(u=ge.empty()),I(t.set,"updateIn with invalid keyPath"),t.set(i,++n===e.length?r(u):P(u,e,r,n))}function U(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,127&t}function z(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var u=Array(i),s=0,a=0;i>a;a++)a===e?(u[a]=r,s=-1):u[a]=t[a+s];return u}function R(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),u=0,s=0;n>s;s++)s===e&&(u=1),i[s]=t[s+u];return i}function W(t){if(!t)return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if((0|t)===t)return t%xe;t=""+t,e="string"}if("string"===e)return t.length>Ee?J(t):B(t);if(t.hashCode&&"function"==typeof t.hashCode)return t.hashCode();throw Error("Unable to hash: "+t)}function J(t){var e=qe[t];return null==e&&(e=B(t),Ae===Ce&&(Ae=0,qe={}),Ae++,qe[t]=e),e}function B(t){for(var e=0,r=0;t.length>r;r++)e=31*e+t.charCodeAt(r);return e%xe}function L(t,e,r,n,i,u){var s=Object.create(Re);return s.length=e-t,s._origin=t,s._size=e,s._level=r,s._root=n,s._tail=i,s.__ownerID=u,s}function V(t,e){if(e>=G(t._size))return t._tail;if(1<<t._level+fe>e){for(var r=t._root,n=t._level;r&&n>0;)r=r.array[e>>>n&_e],n-=fe;return r <add>}function x(t,e,r,n,i,u,s){return t?t.update(e,r,n,i,u,s):u===ve?t:(s&&(s.value=!0),new be(e,n,[i,u]))}function E(t){return t.constructor===be||t.constructor===De}function C(t,e,r,n,i){if(t.hash===n)return new De(e,n,[t.entry,i]);var u,s=t.hash>>>r&_e,a=n>>>r&_e,h=s===a?[C(t,e,r+fe,n,i)]:(u=new be(e,n,i),a>s?[t,u]:[u,t]);return new de(e,1<<s|1<<a,h)}function A(t,e,r){for(var n=[],i=0;r.length>i;i++){var u=r[i];u&&n.push(Array.isArray(u)?ee(u).fromEntries():ee(u))}return j(t,e,n)}function q(t){return function(e,r){return e&&e.mergeDeepWith?e.mergeDeepWith(t,r):t?t(e,r):r}}function j(t,e,r){return 0===r.length?t:t.withMutations(function(t){for(var n=e?function(r,n){var i=t.get(n,ve);t.set(n,i===ve?r:e(i,r))}:function(e,r){t.set(r,e)},i=0;r.length>i;i++)r[i].forEach(n)})}function P(t,e,r,n){var i=e[n],u=t.get?t.get(i,ve):ve;return u===ve&&(u=ge.empty()),I(t.set,"updateIn with invalid keyPath"),t.set(i,++n===e.length?r(u):P(u,e,r,n))}function U(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,127&t}function z(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var u=Array(i),s=0,a=0;i>a;a++)a===e?(u[a]=r,s=-1):u[a]=t[a+s];return u}function R(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),u=0,s=0;n>s;s++)s===e&&(u=1),i[s]=t[s+u];return i}function W(t){if(!t)return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if((0|t)===t)return t%xe;t=""+t,e="string"}if("string"===e)return t.length>Ee?J(t):B(t);if(t.hashCode&&"function"==typeof t.hashCode)return t.hashCode();throw Error("Unable to hash: "+t)}function J(t){var e=qe[t];return null==e&&(e=B(t),Ae===Ce&&(Ae=0,qe={}),Ae++,qe[t]=e),e}function B(t){for(var e=0,r=0;t.length>r;r++)e=(31*e+t.charCodeAt(r))%xe;return e}function L(t,e,r,n,i,u){var s=Object.create(Re);return s.length=e-t,s._origin=t,s._size=e,s._level=r,s._root=n,s._tail=i,s.__ownerID=u,s}function V(t,e){if(e>=G(t._size))return t._tail;if(1<<t._level+fe>e){for(var r=t._root,n=t._level;r&&n>0;)r=r.array[e>>>n&_e],n-=fe;return r <ide> }}function K(t,e,r){var n=t.__ownerID||new O,i=t._origin,u=t._size,s=i+e,a=null==r?u:0>r?u+r:i+r;if(s===i&&a===u)return t;if(s>=a)return t.clear();for(var h=t._level,o=t._root,c=0;0>s+c;)o=new We(o.array.length?[,o]:[],n),h+=fe,c+=1<<h;c&&(s+=c,i+=c,a+=c,u+=c);for(var f=G(u),l=G(a);l>=1<<h+fe;)o=new We(o.array.length?[o]:[],n),h+=fe;var _=t._tail,v=f>l?V(t,a-1):l>f?new We([],n):_;if(l>f&&u>s&&_.array.length){o=o.ensureOwner(n);for(var g=o,p=h;p>fe;p-=fe){var m=f>>>p&_e;g=g.array[m]=g.array[m]?g.array[m].ensureOwner(n):new We([],n)}g.array[f>>>fe&_e]=_}if(u>a&&(v=v.removeAfter(n,0,a)),s>=l)s-=l,a-=l,h=fe,o=Ve,v=v.removeBefore(n,0,s);else if(s>i||f>l){var d,y;c=0;do d=s>>>h&_e,y=l-1>>>h&_e,d===y&&(d&&(c+=(1<<h)*d),h-=fe,o=o&&o.array[d]);while(o&&d===y);o&&s>i&&(o=o.removeBefore(n,h,s-c)),o&&f>l&&(o=o.removeAfter(n,h,l-c)),c&&(s-=c,a-=c),o=o||Ve}return t.__ownerID?(t.length=a-s,t._origin=s,t._size=a,t._level=h,t._root=o,t._tail=v,t):L(s,a,h,o,v)}function N(t,e,r){for(var n=[],i=0;r.length>i;i++){var u=r[i];u&&n.push(u.forEach?u:ee(u))}var s=Math.max.apply(null,n.map(function(t){return t.length||0}));return s>t.length&&(t=t.setLength(s)),j(t,e,n)}function F(t,e){return I(t>=0,"Index out of bounds"),t+e}function G(t){return le>t?0:t-1>>>fe<<fe}function H(t,e){var r=Object.create(Fe);return r.length=t?t.length:0,r._map=t,r.__ownerID=e,r}function Q(t,e,r){var n=Object.create(He.prototype);return n.length=t?t.length:0,n._map=t,n._vector=e,n.__ownerID=r,n}function T(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._map=e,n.__ownerID=r,n}function X(t,e){return e?Y(e,t,"",{"":t}):Z(t)}function Y(t,e,r,n){return e&&(Array.isArray(e)||e.constructor===Object)?t.call(n,r,ee(e).map(function(r,n){return Y(t,r,n,e)})):e}function Z(t){if(t){if(Array.isArray(t))return ee(t).map(Z).toVector();if(t.constructor===Object)return ee(t).map(Z).toMap()}return t}var $=Object,te={};te.createClass=t,te.superCall=e,te.defaultSuperCall=r;var ee=function(t){return re.from(1===arguments.length?t:Array.prototype.slice.call(arguments))},re=ee; <ide> te.createClass(ee,{toString:function(){return this.__toString("Seq {","}")},__toString:function(t,e){return 0===this.length?t+e:t+" "+this.map(this.__toStringMapper).join(", ")+" "+e},__toStringMapper:function(t,e){return e+": "+p(t)},toJS:function(){return this.map(function(t){return t instanceof re?t.toJS():t}).__toJS()},toArray:function(){y(this.length);var t=Array(this.length||0);return this.values().forEach(function(e,r){t[r]=e}),t},toObject:function(){y(this.length);var t={};return this.forEach(function(e,r){t[r]=e}),t},toVector:function(){return y(this.length),Ue.from(this)},toMap:function(){return y(this.length),ge.from(this)},toOrderedMap:function(){return y(this.length),He.from(this)},toSet:function(){return y(this.length),Ke.from(this)},equals:function(t){if(this===t)return!0;if(!(t instanceof re))return!1;if(null!=this.length&&null!=t.length){if(this.length!==t.length)return!1;if(0===this.length&&0===t.length)return!0}return this.__deepEquals(t)},__deepEquals:function(t){var e=this.cacheResult().entries().toArray(),r=0;return t.every(function(t,n){var i=e[r++];return w(n,i[0])&&w(t,i[1])})},join:function(t){t=t||",";var e="",r=!0;return this.forEach(function(n){r?(r=!1,e+=n):e+=t+n}),e},count:function(t,e){return t?this.filter(t,e).count():(null==this.length&&(this.length=this.forEach(f)),this.length)},countBy:function(t){var e=this;return He.empty().withMutations(function(r){e.forEach(function(e,n,i){r.update(t(e,n,i),_)})})},concat:function(){for(var t=[],e=0;arguments.length>e;e++)t[e]=arguments[e];var r=[this].concat(t.map(function(t){return re(t)})),n=this.__makeSequence();return n.length=r.reduce(function(t,e){return null!=t&&null!=e.length?t+e.length:void 0},0),n.__iterateUncached=function(t,e){for(var n,i=0,u=r.length-1,s=0;u>=s&&!n;s++){var a=r[e?u-s:s];i+=a.__iterate(function(e,r,i){return t(e,r,i)===!1?(n=!0,!1):void 0},e)}return i},n},reverse:function(){var t=this,e=t.__makeSequence();return e.length=t.length,e.__iterateUncached=function(e,r){return t.__iterate(e,!r)},e.reverse=function(){return t <ide> },e},keys:function(){return this.flip().values()},values:function(){var t=this,e=i(t);return e.length=t.length,e.values=l,e.__iterateUncached=function(e,r,n){if(n&&null==this.length)return this.cacheResult().__iterate(e,r,n);var i,u=0;return n?(u=this.length-1,i=function(t,r,n){return e(t,u--,n)!==!1}):i=function(t,r,n){return e(t,u++,n)!==!1},t.__iterate(i,r),n?this.length:u},e},entries:function(){var t=this;if(t._cache)return re(t._cache);var e=t.map(c).values();return e.fromEntries=function(){return t},e},forEach:function(t,e){return this.__iterate(e?t.bind(e):t)},reduce:function(t,e,r){var n=e;return this.forEach(function(e,i,u){n=t.call(r,n,e,i,u)}),n},reduceRight:function(t,e,r){return this.reverse(!0).reduce(t,e,r)},every:function(t,e){var r=!0;return this.forEach(function(n,i,u){return t.call(e,n,i,u)?void 0:(r=!1,!1)}),r},some:function(t,e){return!this.every(g(t),e)},first:function(){return this.find(f)},last:function(){return this.findLast(f)},rest:function(){return this.slice(1)},butLast:function(){return this.slice(0,-1)},has:function(t){return this.get(t,ve)!==ve},get:function(t,e){return this.find(function(e,r){return w(r,t)},null,e)},getIn:function(t,e){return t&&0!==t.length?u(this,t,e,0):this},contains:function(t){return this.find(function(e){return w(e,t)},null,ve)!==ve},find:function(t,e,r){var n=r;return this.forEach(function(r,i,u){return t.call(e,r,i,u)?(n=r,!1):void 0}),n},findKey:function(t,e){var r;return this.forEach(function(n,i,u){return t.call(e,n,i,u)?(r=i,!1):void 0}),r},findLast:function(t,e,r){return this.reverse(!0).find(t,e,r)},findLastKey:function(t,e){return this.reverse(!0).findKey(t,e)},flip:function(){var t=this,e=n();return e.length=t.length,e.flip=function(){return t},e.__iterateUncached=function(e,r){return t.__iterate(function(t,r,n){return e(r,t,n)!==!1},r)},e},map:function(t,e){var r=this,n=r.__makeSequence();return n.length=r.length,n.__iterateUncached=function(n,i){return r.__iterate(function(r,i,u){return n(t.call(e,r,i,u),i,u)!==!1},i)},n},mapKeys:function(t,e){var r=this,n=r.__makeSequence(); <ide><path>src/Map.js <ide> function hashString(string) { <ide> // (exclusive). <ide> var hash = 0; <ide> for (var ii = 0; ii < string.length; ii++) { <del> hash = (31 * hash + string.charCodeAt(ii)); <add> hash = (31 * hash + string.charCodeAt(ii)) % HASH_MAX_VAL; <ide> } <del> return hash % HASH_MAX_VAL; <add> return hash; <ide> } <ide> <ide> var HASH_MAX_VAL = 0x100000000; // 2^32
3
PHP
PHP
add optional priority to eloquent observer
eeb0f30b07ff0614384129b5498daad9f9e3e689
<ide><path>src/Illuminate/Database/Eloquent/Model.php <ide> public function getGlobalScopes() <ide> * Register an observer with the Model. <ide> * <ide> * @param object|string $class <add> * @param int $priority <ide> * @return void <ide> */ <del> public static function observe($class) <add> public static function observe($class, $priority = 0) <ide> { <ide> $instance = new static; <ide> <ide> public static function observe($class) <ide> // it into the model's event system, making it convenient to watch these. <ide> foreach ($instance->getObservableEvents() as $event) { <ide> if (method_exists($class, $event)) { <del> static::registerModelEvent($event, $className.'@'.$event); <add> static::registerModelEvent($event, $className.'@'.$event, $priority); <ide> } <ide> } <ide> }
1
Javascript
Javascript
fix log scale when value is 0
939756c26083d5fbd7c8ae2ed7981696566684eb
<ide><path>src/scales/scale.logarithmic.js <ide> module.exports = function(Chart) { <ide> getPixelForTick: function(index) { <ide> return this.getPixelForValue(this.tickValues[index]); <ide> }, <add> /** <add> * Returns the value of the first tick. <add> * @param {Number} value - The minimum not zero value. <add> * @return {Number} The first tick value. <add> * @private <add> */ <add> _getFirstTickValue: function(value) { <add> var exp = Math.floor(helpers.log10(value)); <add> var significand = Math.floor(value / Math.pow(10, exp)); <add> <add> return significand * Math.pow(10, exp); <add> }, <ide> getPixelForValue: function(value) { <ide> var me = this; <del> var start = me.start; <del> var newVal = +me.getRightValue(value); <del> var opts = me.options; <del> var tickOpts = opts.ticks; <del> var innerDimension, pixel, range; <add> var reverse = me.options.ticks.reverse; <add> var log10 = helpers.log10; <add> var firstTickValue = me._getFirstTickValue(me.minNotZero); <add> var offset = 0; <add> var innerDimension, pixel, start, end, sign; <ide> <add> value = +me.getRightValue(value); <add> if (reverse) { <add> start = me.end; <add> end = me.start; <add> sign = -1; <add> } else { <add> start = me.start; <add> end = me.end; <add> sign = 1; <add> } <ide> if (me.isHorizontal()) { <del> range = helpers.log10(me.end) - helpers.log10(start); // todo: if start === 0 <del> if (newVal === 0) { <del> pixel = me.left; <del> } else { <del> innerDimension = me.width; <del> pixel = me.left + (innerDimension / range * (helpers.log10(newVal) - helpers.log10(start))); <del> } <add> innerDimension = me.width; <add> pixel = reverse ? me.right : me.left; <ide> } else { <del> // Bottom - top since pixels increase downward on a screen <ide> innerDimension = me.height; <del> if (start === 0 && !tickOpts.reverse) { <del> range = helpers.log10(me.end) - helpers.log10(me.minNotZero); <del> if (newVal === start) { <del> pixel = me.bottom; <del> } else if (newVal === me.minNotZero) { <del> pixel = me.bottom - innerDimension * 0.02; <del> } else { <del> pixel = me.bottom - innerDimension * 0.02 - (innerDimension * 0.98 / range * (helpers.log10(newVal) - helpers.log10(me.minNotZero))); <del> } <del> } else if (me.end === 0 && tickOpts.reverse) { <del> range = helpers.log10(me.start) - helpers.log10(me.minNotZero); <del> if (newVal === me.end) { <del> pixel = me.top; <del> } else if (newVal === me.minNotZero) { <del> pixel = me.top + innerDimension * 0.02; <del> } else { <del> pixel = me.top + innerDimension * 0.02 + (innerDimension * 0.98 / range * (helpers.log10(newVal) - helpers.log10(me.minNotZero))); <del> } <del> } else if (newVal === 0) { <del> pixel = tickOpts.reverse ? me.top : me.bottom; <del> } else { <del> range = helpers.log10(me.end) - helpers.log10(start); <del> innerDimension = me.height; <del> pixel = me.bottom - (innerDimension / range * (helpers.log10(newVal) - helpers.log10(start))); <add> sign *= -1; // invert, since the upper-left corner of the canvas is at pixel (0, 0) <add> pixel = reverse ? me.top : me.bottom; <add> } <add> if (value !== start) { <add> if (start === 0) { // include zero tick <add> offset = helpers.getValueOrDefault( <add> me.options.ticks.fontSize, <add> Chart.defaults.global.defaultFontSize <add> ); <add> innerDimension -= offset; <add> start = firstTickValue; <ide> } <add> if (value !== 0) { <add> offset += innerDimension / (log10(end) - log10(start)) * (log10(value) - log10(start)); <add> } <add> pixel += sign * offset; <ide> } <ide> return pixel; <ide> }, <ide> getValueForPixel: function(pixel) { <ide> var me = this; <del> var range = helpers.log10(me.end) - helpers.log10(me.start); <del> var value, innerDimension; <add> var reverse = me.options.ticks.reverse; <add> var log10 = helpers.log10; <add> var firstTickValue = me._getFirstTickValue(me.minNotZero); <add> var innerDimension, start, end, value; <ide> <add> if (reverse) { <add> start = me.end; <add> end = me.start; <add> } else { <add> start = me.start; <add> end = me.end; <add> } <ide> if (me.isHorizontal()) { <ide> innerDimension = me.width; <del> value = me.start * Math.pow(10, (pixel - me.left) * range / innerDimension); <del> } else { // todo: if start === 0 <add> value = reverse ? me.right - pixel : pixel - me.left; <add> } else { <ide> innerDimension = me.height; <del> value = Math.pow(10, (me.bottom - pixel) * range / innerDimension) / me.start; <add> value = reverse ? pixel - me.top : me.bottom - pixel; <add> } <add> if (value !== start) { <add> if (start === 0) { // include zero tick <add> var offset = helpers.getValueOrDefault( <add> me.options.ticks.fontSize, <add> Chart.defaults.global.defaultFontSize <add> ); <add> value -= offset; <add> innerDimension -= offset; <add> start = firstTickValue; <add> } <add> value *= log10(end) - log10(start); <add> value /= innerDimension; <add> value = Math.pow(10, log10(start) + value); <ide> } <ide> return value; <ide> } <ide><path>test/specs/scale.logarithmic.tests.js <ide> describe('Logarithmic Scale tests', function() { <ide> expect(yScale.getValueForPixel(246)).toBeCloseTo(10, 1e-4); <ide> }); <ide> <del> it('should get the correct pixel value for a point when 0 values are present', function() { <del> var chart = window.acquireChart({ <del> type: 'bar', <del> data: { <del> datasets: [{ <del> yAxisID: 'yScale', <del> data: [0.063, 4, 0, 63, 10, 0.5] <del> }], <del> labels: [] <add> it('should get the correct pixel value for a point when 0 values are present or min: 0', function() { <add> var config = [ <add> { <add> dataset: [{x: 0, y: 0}, {x: 10, y: 10}, {x: 1.2, y: 1.2}, {x: 25, y: 25}, {x: 78, y: 78}], <add> firstTick: 1, // value of the first tick <add> lastTick: 80 <ide> }, <del> options: { <del> scales: { <del> yAxes: [{ <del> id: 'yScale', <del> type: 'logarithmic', <del> ticks: { <del> reverse: false <del> } <del> }] <add> { <add> dataset: [{x: 0, y: 0}, {x: 10, y: 10}, {x: 6.3, y: 6.3}, {x: 25, y: 25}, {x: 78, y: 78}], <add> firstTick: 6, <add> lastTick: 80 <add> }, <add> { <add> dataset: [{x: 10, y: 10}, {x: 1.2, y: 1.2}, {x: 25, y: 25}, {x: 78, y: 78}], <add> scale: {ticks: {min: 0}}, <add> firstTick: 1, <add> lastTick: 80 <add> }, <add> { <add> dataset: [{x: 10, y: 10}, {x: 6.3, y: 6.3}, {x: 25, y: 25}, {x: 78, y: 78}], <add> scale: {ticks: {min: 0}}, <add> firstTick: 6, <add> lastTick: 80 <add> }, <add> ]; <add> Chart.helpers.each(config, function(setup) { <add> var xScaleConfig = { <add> type: 'logarithmic' <add> }; <add> var yScaleConfig = { <add> type: 'logarithmic' <add> }; <add> Chart.helpers.extend(xScaleConfig, setup.scale); <add> Chart.helpers.extend(yScaleConfig, setup.scale); <add> var chart = window.acquireChart({ <add> type: 'line', <add> data: { <add> datasets: [{ <add> data: setup.dataset <add> }], <add> }, <add> options: { <add> scales: { <add> xAxes: [xScaleConfig], <add> yAxes: [yScaleConfig] <add> } <ide> } <del> } <add> }); <add> <add> var chartArea = chart.chartArea; <add> var expectations = [ <add> { <add> id: 'x-axis-0', // horizontal scale <add> axis: 'xAxes', <add> start: chartArea.left, <add> end: chartArea.right <add> }, <add> { <add> id: 'y-axis-0', // vertical scale <add> axis: 'yAxes', <add> start: chartArea.bottom, <add> end: chartArea.top <add> } <add> ]; <add> Chart.helpers.each(expectations, function(expectation) { <add> var scale = chart.scales[expectation.id]; <add> var firstTick = setup.firstTick; <add> var lastTick = setup.lastTick; <add> var fontSize = chart.options.defaultFontSize; <add> var start = expectation.start; <add> var end = expectation.end; <add> var sign = scale.isHorizontal() ? 1 : -1; <add> <add> expect(scale.getPixelForValue(0, 0, 0)).toBeCloseToPixel(start); <add> expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(end); <add> expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(start + sign * fontSize); <add> <add> expect(scale.getValueForPixel(start)).toBeCloseTo(0); <add> expect(scale.getValueForPixel(end)).toBeCloseTo(lastTick); <add> expect(scale.getValueForPixel(start + sign * fontSize)).toBeCloseTo(firstTick); <add> <add> chart.options.scales[expectation.axis][0].ticks.reverse = true; // Reverse mode <add> chart.update(); <add> <add> expect(scale.getPixelForValue(0, 0, 0)).toBeCloseToPixel(end); <add> expect(scale.getPixelForValue(lastTick, 0, 0)).toBeCloseToPixel(start); <add> expect(scale.getPixelForValue(firstTick, 0, 0)).toBeCloseToPixel(end - sign * fontSize); <add> <add> expect(scale.getValueForPixel(end)).toBeCloseTo(0); <add> expect(scale.getValueForPixel(start)).toBeCloseTo(lastTick); <add> expect(scale.getValueForPixel(end - sign * fontSize)).toBeCloseTo(firstTick); <add> }); <ide> }); <del> <del> var yScale = chart.scales.yScale; <del> expect(yScale.getPixelForValue(70, 0, 0)).toBeCloseToPixel(32); // top + paddingTop <del> expect(yScale.getPixelForValue(0, 0, 0)).toBeCloseToPixel(484); // bottom - paddingBottom <del> expect(yScale.getPixelForValue(0.063, 0, 0)).toBeCloseToPixel(475); // minNotZero 2% from range <del> expect(yScale.getPixelForValue(0.5, 0, 0)).toBeCloseToPixel(344); <del> expect(yScale.getPixelForValue(4, 0, 0)).toBeCloseToPixel(213); <del> expect(yScale.getPixelForValue(10, 0, 0)).toBeCloseToPixel(155); <del> expect(yScale.getPixelForValue(63, 0, 0)).toBeCloseToPixel(38.5); <del> <del> chart.options.scales.yAxes[0].ticks.reverse = true; // Reverse mode <del> chart.update(); <del> <del> expect(yScale.getPixelForValue(70, 0, 0)).toBeCloseToPixel(484); // bottom - paddingBottom <del> expect(yScale.getPixelForValue(0, 0, 0)).toBeCloseToPixel(32); // top + paddingTop <del> expect(yScale.getPixelForValue(0.063, 0, 0)).toBeCloseToPixel(41); // minNotZero 2% from range <del> expect(yScale.getPixelForValue(0.5, 0, 0)).toBeCloseToPixel(172); <del> expect(yScale.getPixelForValue(4, 0, 0)).toBeCloseToPixel(303); <del> expect(yScale.getPixelForValue(10, 0, 0)).toBeCloseToPixel(361); <del> expect(yScale.getPixelForValue(63, 0, 0)).toBeCloseToPixel(477); <ide> }); <add> <ide> });
2
Javascript
Javascript
adjust error emit in core, add tests
ccd3afc84303247b32c011fea7630d150f07849d
<ide><path>lib/internal/http2/core.js <ide> const { <ide> } = constants; <ide> <ide> // Top level to avoid creating a closure <del>function emit() { <del> this.emit.apply(this, arguments); <add>function emit(self, ...args) { <add> self.emit(...args); <ide> } <ide> <ide> // Called when a new block of headers has been received for a given <ide> function onSessionHeaders(id, cat, flags, headers) { <ide> stream = new ClientHttp2Stream(owner, id, { readable: !endOfStream }); <ide> } <ide> streams.set(id, stream); <del> process.nextTick(emit.bind(owner, 'stream', stream, obj, flags, headers)); <add> process.nextTick(emit, owner, 'stream', stream, obj, flags, headers); <ide> } else { <ide> let event; <ide> const status = obj[HTTP2_HEADER_STATUS]; <ide> function onSessionHeaders(id, cat, flags, headers) { <ide> } <ide> } <ide> debug(`[${sessionName(owner[kType])}] emitting stream '${event}' event`); <del> process.nextTick(emit.bind(stream, event, obj, flags, headers)); <add> process.nextTick(emit, stream, event, obj, flags, headers); <ide> } <ide> if (endOfStream) { <ide> stream.push(null); <ide> function onSessionTrailers(id) { <ide> getTrailers.call(stream, trailers); <ide> const headersList = mapToHeaders(trailers, assertValidPseudoHeaderTrailer); <ide> if (!Array.isArray(headersList)) { <del> process.nextTick(() => stream.emit('error', headersList)); <add> process.nextTick(emit, stream, 'error', headersList); <ide> return; <ide> } <ide> return headersList; <ide> function onSessionStreamClose(id, code) { <ide> <ide> function afterFDClose(err) { <ide> if (err) <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, this, 'error', err); <ide> } <ide> <ide> // Called when an error event needs to be triggered <ide> function onSessionError(error) { <ide> const owner = this[kOwner]; <ide> _unrefActive(owner); <del> process.nextTick(() => owner.emit('error', error)); <add> process.nextTick(emit, owner, 'error', error); <ide> } <ide> <ide> // Receives a chunk of data for a given stream and forwards it on <ide> function onSettings(ack) { <ide> if (owner.listenerCount(event) > 0) { <ide> const settings = event === 'localSettings' ? <ide> owner.localSettings : owner.remoteSettings; <del> process.nextTick(emit.bind(owner, event, settings)); <add> process.nextTick(emit, owner, event, settings); <ide> } <ide> } <ide> <ide> function onPriority(id, parent, weight, exclusive) { <ide> const streams = owner[kState].streams; <ide> const stream = streams.get(id); <ide> const emitter = stream === undefined ? owner : stream; <del> process.nextTick( <del> emit.bind(emitter, 'priority', id, parent, weight, exclusive)); <add> process.nextTick(emit, emitter, 'priority', id, parent, weight, exclusive); <ide> } <ide> <del>function emitFrameError(id, type, code) { <del> if (!this.emit('frameError', type, code, id)) { <add>function emitFrameError(self, id, type, code) { <add> if (!self.emit('frameError', type, code, id)) { <ide> const err = new errors.Error('ERR_HTTP2_FRAME_ERROR', type, code, id); <ide> err.errno = code; <del> this.emit('error', err); <add> self.emit('error', err); <ide> } <ide> } <ide> <ide> function onFrameError(id, type, code) { <ide> const streams = owner[kState].streams; <ide> const stream = streams.get(id); <ide> const emitter = stream !== undefined ? stream : owner; <del> process.nextTick(emitFrameError.bind(emitter, id, type, code)); <add> process.nextTick(emitFrameError, emitter, id, type, code); <ide> } <ide> <del>function emitGoaway(state, code, lastStreamID, buf) { <del> this.emit('goaway', code, lastStreamID, buf); <add>function emitGoaway(self, code, lastStreamID, buf) { <add> self.emit('goaway', code, lastStreamID, buf); <ide> // Tear down the session or destroy <add> const state = self[kState]; <ide> if (state.destroying || state.destroyed) <ide> return; <ide> if (!state.shuttingDown && !state.shutdown) { <del> this.shutdown({}, this.destroy.bind(this)); <add> self.shutdown({}, self.destroy.bind(self)); <ide> } else { <del> this.destroy(); <add> self.destroy(); <ide> } <ide> } <ide> <ide> // Called by the native layer when a goaway frame has been received <ide> function onGoawayData(code, lastStreamID, buf) { <ide> const owner = this[kOwner]; <del> const state = owner[kState]; <ide> debug(`[${sessionName(owner[kType])}] goaway data received`); <del> process.nextTick(emitGoaway.bind(owner, state, code, lastStreamID, buf)); <add> process.nextTick(emitGoaway, owner, code, lastStreamID, buf); <ide> } <ide> <ide> // Returns the padding to use per frame. The selectPadding callback is set <ide> function requestOnConnect(headers, options) { <ide> <ide> const headersList = mapToHeaders(headers); <ide> if (!Array.isArray(headersList)) { <del> process.nextTick(() => this.emit('error', headersList)); <add> process.nextTick(emit, this, 'error', headersList); <ide> return; <ide> } <ide> <ide> function requestOnConnect(headers, options) { <ide> switch (ret) { <ide> case NGHTTP2_ERR_NOMEM: <ide> err = new errors.Error('ERR_OUTOFMEMORY'); <del> process.nextTick(() => session.emit('error', err)); <add> process.nextTick(emit, session, 'error', err); <ide> break; <ide> case NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE: <ide> err = new errors.Error('ERR_HTTP2_OUT_OF_STREAMS'); <del> process.nextTick(() => session.emit('error', err)); <add> process.nextTick(emit, session, 'error', err); <ide> break; <ide> case NGHTTP2_ERR_INVALID_ARGUMENT: <ide> err = new errors.Error('ERR_HTTP2_STREAM_SELF_DEPENDENCY'); <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, this, 'error', err); <ide> break; <ide> default: <ide> // Some other, unexpected error was returned. Emit on the session. <ide> if (ret < 0) { <ide> err = new NghttpError(ret); <del> process.nextTick(() => session.emit('error', err)); <add> process.nextTick(emit, session, 'error', err); <ide> break; <ide> } <ide> debug(`[${sessionName(session[kType])}] stream ${ret} initialized`); <ide> function setupHandle(session, socket, type, options) { <ide> options.settings : Object.create(null); <ide> <ide> session.settings(settings); <del> process.nextTick(emit.bind(session, 'connect', session, socket)); <add> process.nextTick(emit, session, 'connect', session, socket); <ide> }; <ide> } <ide> <ide> function submitSettings(settings) { <ide> switch (ret) { <ide> case NGHTTP2_ERR_NOMEM: <ide> err = new errors.Error('ERR_OUTOFMEMORY'); <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, this, 'error', err); <ide> break; <ide> default: <ide> // Some other unexpected error was reported. <ide> if (ret < 0) { <ide> err = new NghttpError(ret); <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, this, 'error', err); <ide> } <ide> } <ide> debug(`[${sessionName(this[kType])}] settings complete`); <ide> function submitPriority(stream, options) { <ide> switch (ret) { <ide> case NGHTTP2_ERR_NOMEM: <ide> err = new errors.Error('ERR_OUTOFMEMORY'); <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, this, 'error', err); <ide> break; <ide> default: <ide> // Some other unexpected error was reported. <ide> if (ret < 0) { <ide> err = new NghttpError(ret); <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, stream, 'error', err); <ide> } <ide> } <ide> debug(`[${sessionName(this[kType])}] priority complete`); <ide> function submitRstStream(stream, code) { <ide> switch (ret) { <ide> case NGHTTP2_ERR_NOMEM: <ide> err = new errors.Error('ERR_OUTOFMEMORY'); <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, this, 'error', err); <ide> break; <ide> default: <ide> // Some other unexpected error was reported. <ide> if (ret < 0) { <ide> err = new NghttpError(ret); <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, stream, 'error', err); <ide> break; <ide> } <ide> stream.destroy(); <ide> } <ide> debug(`[${sessionName(this[kType])}] rststream complete`); <ide> } <ide> <del>function doShutdown(options) { <del> const handle = this[kHandle]; <del> const state = this[kState]; <add>function doShutdown(self, options) { <add> const handle = self[kHandle]; <add> const state = self[kState]; <ide> if (handle === undefined || state.shutdown) <ide> return; // Nothing to do, possibly because the session shutdown already. <ide> const ret = handle.submitGoaway(options.errorCode | 0, <ide> function doShutdown(options) { <ide> state.shuttingDown = false; <ide> state.shutdown = true; <ide> if (ret < 0) { <del> debug(`[${sessionName(this[kType])}] shutdown failed! code: ${ret}`); <add> debug(`[${sessionName(self[kType])}] shutdown failed! code: ${ret}`); <ide> const err = new NghttpError(ret); <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, self, 'error', err); <ide> return; <ide> } <del> process.nextTick(emit.bind(this, 'shutdown', options)); <del> debug(`[${sessionName(this[kType])}] shutdown is complete`); <add> process.nextTick(emit, self, 'shutdown', options); <add> debug(`[${sessionName(self[kType])}] shutdown is complete`); <ide> } <ide> <ide> // Submit a graceful or immediate shutdown request for the Http2Session. <ide> function submitShutdown(options) { <ide> // first send a shutdown notice <ide> handle.submitShutdownNotice(); <ide> // then, on flip of the event loop, do the actual shutdown <del> setImmediate(doShutdown.bind(this, options)); <add> setImmediate(doShutdown, this, options); <ide> } else { <del> doShutdown.call(this, options); <add> doShutdown(this, options); <ide> } <ide> } <ide> <del>function finishSessionDestroy(socket) { <del> const state = this[kState]; <add>function finishSessionDestroy(self, socket) { <add> const state = self[kState]; <ide> if (state.destroyed) <ide> return; <ide> <ide> function finishSessionDestroy(socket) { <ide> state.destroyed = true; <ide> <ide> // Destroy the handle <del> const handle = this[kHandle]; <add> const handle = self[kHandle]; <ide> if (handle !== undefined) { <ide> handle.destroy(state.skipUnconsume); <del> debug(`[${sessionName(this[kType])}] nghttp2session handle destroyed`); <add> debug(`[${sessionName(self[kType])}] nghttp2session handle destroyed`); <ide> } <del> this[kHandle] = undefined; <add> self[kHandle] = undefined; <ide> <del> process.nextTick(emit.bind(this, 'close')); <del> debug(`[${sessionName(this[kType])}] nghttp2session destroyed`); <add> process.nextTick(emit, self, 'close'); <add> debug(`[${sessionName(self[kType])}] nghttp2session destroyed`); <ide> } <ide> <ide> // Upon creation, the Http2Session takes ownership of the socket. The session <ide> class Http2Session extends EventEmitter { <ide> if (this[kHandle] !== undefined) <ide> this[kHandle].destroying(); <ide> <del> setImmediate(finishSessionDestroy.bind(this, socket)); <add> setImmediate(finishSessionDestroy, this, socket); <ide> } <ide> <ide> // Graceful or immediate shutdown of the Http2Session. Graceful shutdown <ide> class Http2Session extends EventEmitter { <ide> } <ide> <ide> _onTimeout() { <del> process.nextTick(emit.bind(this, 'timeout')); <add> process.nextTick(emit, this, 'timeout'); <ide> } <ide> } <ide> <ide> function onHandleFinish() { <ide> const session = this[kSession]; <ide> if (session === undefined) return; <ide> if (this[kID] === undefined) { <del> this.once('ready', onHandleFinish.bind(this)); <add> this.once('ready', onHandleFinish); <ide> } else { <ide> const handle = session[kHandle]; <ide> if (handle !== undefined) { <ide> function streamOnResume() { <ide> if (this._paused) <ide> return this.pause(); <ide> if (this[kID] === undefined) { <del> this.once('ready', streamOnResume.bind(this)); <add> this.once('ready', streamOnResume); <ide> return; <ide> } <ide> const session = this[kSession]; <ide> function streamOnSessionConnect() { <ide> debug(`[${sessionName(session[kType])}] session connected. emiting stream ` + <ide> 'connect'); <ide> this[kState].connecting = false; <del> process.nextTick(emit.bind(this, 'connect')); <add> process.nextTick(emit, this, 'connect'); <ide> } <ide> <ide> function streamOnceReady() { <ide> class Http2Stream extends Duplex { <ide> } <ide> <ide> _onTimeout() { <del> process.nextTick(emit.bind(this, 'timeout')); <add> process.nextTick(emit, this, 'timeout'); <ide> } <ide> <ide> // true if the Http2Stream was aborted abornomally. <ide> class Http2Stream extends Duplex { <ide> // * Then cleans up the resources on the js side <ide> _destroy(err, callback) { <ide> const session = this[kSession]; <del> const handle = session[kHandle]; <ide> if (this[kID] === undefined) { <ide> debug(`[${sessionName(session[kType])}] queuing destroy for new stream`); <ide> this.once('ready', this._destroy.bind(this, err, callback)); <ide> class Http2Stream extends Duplex { <ide> server.emit('streamError', err, this); <ide> } <ide> <del> process.nextTick(() => { <del> debug(`[${sessionName(session[kType])}] destroying stream ${this[kID]}`); <add> process.nextTick(continueStreamDestroy, this, err, callback); <add> } <add>} <ide> <del> // Submit RST-STREAM frame if one hasn't been sent already and the <del> // stream hasn't closed normally... <del> if (!this[kState].rst && !session.destroyed) { <del> const code = <del> err instanceof Error ? <del> NGHTTP2_INTERNAL_ERROR : NGHTTP2_NO_ERROR; <del> this[kSession].rstStream(this, code); <del> } <add>function continueStreamDestroy(self, err, callback) { <add> const session = self[kSession]; <add> const handle = session[kHandle]; <add> const state = self[kState]; <ide> <del> // Remove the close handler on the session <del> session.removeListener('close', this[kState].closeHandler); <add> debug(`[${sessionName(session[kType])}] destroying stream ${self[kID]}`); <ide> <del> // Unenroll the timer <del> this.setTimeout(0); <add> // Submit RST-STREAM frame if one hasn't been sent already and the <add> // stream hasn't closed normally... <add> if (!state.rst && !session.destroyed) { <add> const code = <add> err instanceof Error ? <add> NGHTTP2_INTERNAL_ERROR : NGHTTP2_NO_ERROR; <add> session.rstStream(self, code); <add> } <ide> <del> setImmediate(finishStreamDestroy.bind(this, handle)); <add> // Remove the close handler on the session <add> session.removeListener('close', state.closeHandler); <ide> <del> // All done <del> const rst = this[kState].rst; <del> const code = rst ? this[kState].rstCode : NGHTTP2_NO_ERROR; <del> if (!err && code !== NGHTTP2_NO_ERROR) { <del> err = new errors.Error('ERR_HTTP2_STREAM_ERROR', code); <del> } <del> process.nextTick(emit.bind(this, 'streamClosed', code)); <del> debug(`[${sessionName(session[kType])}] stream ${this[kID]} destroyed`); <del> callback(err); <del> }); <add> // Unenroll the timer <add> self.setTimeout(0); <add> <add> setImmediate(finishStreamDestroy, self, handle); <add> <add> // All done <add> const rst = state.rst; <add> const code = rst ? state.rstCode : NGHTTP2_NO_ERROR; <add> if (!err && code !== NGHTTP2_NO_ERROR) { <add> err = new errors.Error('ERR_HTTP2_STREAM_ERROR', code); <ide> } <add> process.nextTick(emit, self, 'streamClosed', code); <add> debug(`[${sessionName(session[kType])}] stream ${self[kID]} destroyed`); <add> callback(err); <ide> } <ide> <del>function finishStreamDestroy(handle) { <del> const id = this[kID]; <del> const session = this[kSession]; <add>function finishStreamDestroy(self, handle) { <add> const id = self[kID]; <add> const session = self[kSession]; <ide> session[kState].streams.delete(id); <del> delete this[kSession]; <add> delete self[kSession]; <ide> if (handle !== undefined) <ide> handle.destroyStream(id); <del> this.emit('destroy'); <add> self.emit('destroy'); <ide> } <ide> <ide> function processHeaders(headers) { <ide> function processRespondWithFD(fd, headers, offset = 0, length = -1, <ide> switch (ret) { <ide> case NGHTTP2_ERR_NOMEM: <ide> err = new errors.Error('ERR_OUTOFMEMORY'); <del> process.nextTick(() => session.emit('error', err)); <add> process.nextTick(emit, session, 'error', err); <ide> break; <ide> default: <ide> if (ret < 0) { <ide> err = new NghttpError(ret); <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, this, 'error', err); <ide> } <ide> } <ide> } <ide> function doSendFD(session, options, fd, headers, getTrailers, err, stat) { <ide> return; <ide> } <ide> if (err) { <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, this, 'error', err); <ide> return; <ide> } <ide> <ide> function doSendFD(session, options, fd, headers, getTrailers, err, stat) { <ide> const headersList = mapToHeaders(headers, <ide> assertValidPseudoHeaderResponse); <ide> if (!Array.isArray(headersList)) { <del> process.nextTick(() => this.emit('error', headersList)); <add> process.nextTick(emit, this, 'error', headersList); <add> return; <ide> } <ide> <ide> processRespondWithFD.call(this, fd, headersList, <ide> function doSendFileFD(session, options, fd, headers, getTrailers, err, stat) { <ide> const headersList = mapToHeaders(headers, <ide> assertValidPseudoHeaderResponse); <ide> if (!Array.isArray(headersList)) { <del> process.nextTick(() => this.emit('error', headersList)); <add> process.nextTick(emit, this, 'error', headersList); <add> return; <ide> } <ide> <ide> processRespondWithFD.call(this, fd, headersList, <ide> class ServerHttp2Stream extends Http2Stream { <ide> switch (ret) { <ide> case NGHTTP2_ERR_NOMEM: <ide> err = new errors.Error('ERR_OUTOFMEMORY'); <del> process.nextTick(() => session.emit('error', err)); <add> process.nextTick(emit, session, 'error', err); <ide> break; <ide> case NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE: <ide> err = new errors.Error('ERR_HTTP2_OUT_OF_STREAMS'); <del> process.nextTick(() => session.emit('error', err)); <add> process.nextTick(emit, session, 'error', err); <ide> break; <ide> case NGHTTP2_ERR_STREAM_CLOSED: <ide> err = new errors.Error('ERR_HTTP2_STREAM_CLOSED'); <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, this, 'error', err); <ide> break; <ide> default: <ide> if (ret <= 0) { <ide> err = new NghttpError(ret); <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, this, 'error', err); <ide> break; <ide> } <ide> debug(`[${sessionName(session[kType])}] push stream ${ret} created`); <ide> class ServerHttp2Stream extends Http2Stream { <ide> switch (ret) { <ide> case NGHTTP2_ERR_NOMEM: <ide> err = new errors.Error('ERR_OUTOFMEMORY'); <del> process.nextTick(() => session.emit('error', err)); <add> process.nextTick(emit, session, 'error', err); <ide> break; <ide> default: <ide> if (ret < 0) { <ide> err = new NghttpError(ret); <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, this, 'error', err); <ide> } <ide> } <ide> } <ide> class ServerHttp2Stream extends Http2Stream { <ide> const headersList = mapToHeaders(headers, <ide> assertValidPseudoHeaderResponse); <ide> if (!Array.isArray(headersList)) { <del> process.nextTick(() => this.emit('error', headersList)); <add> process.nextTick(emit, this, 'error', headersList); <add> return; <ide> } <ide> <ide> processRespondWithFD.call(this, fd, headersList, <ide> class ServerHttp2Stream extends Http2Stream { <ide> switch (ret) { <ide> case NGHTTP2_ERR_NOMEM: <ide> err = new errors.Error('ERR_OUTOFMEMORY'); <del> process.nextTick(() => this[kSession].emit('error', err)); <add> process.nextTick(emit, this[kSession], 'error', err); <ide> break; <ide> default: <ide> if (ret < 0) { <ide> err = new NghttpError(ret); <del> process.nextTick(() => this.emit('error', err)); <add> process.nextTick(emit, this, 'error', err); <ide> } <ide> } <ide> } <ide> function connectionListener(socket) { <ide> <ide> socket[kServer] = this; <ide> <del> process.nextTick(emit.bind(this, 'session', session)); <add> process.nextTick(emit, this, 'session', session); <ide> } <ide> <ide> function initializeOptions(options) { <ide><path>test/parallel/test-http2-info-headers-errors.js <add>'use strict'; <add> <add>const common = require('../common'); <add>if (!common.hasCrypto) <add> common.skip('missing crypto'); <add>const http2 = require('http2'); <add>const { <add> constants, <add> Http2Session, <add> nghttp2ErrorString <add>} = process.binding('http2'); <add> <add>// tests error handling within additionalHeaders <add>// - NGHTTP2_ERR_NOMEM (should emit session error) <add>// - every other NGHTTP2 error from binding (should emit stream error) <add> <add>const specificTestKeys = [ <add> 'NGHTTP2_ERR_NOMEM' <add>]; <add> <add>const specificTests = [ <add> { <add> ngError: constants.NGHTTP2_ERR_NOMEM, <add> error: { <add> code: 'ERR_OUTOFMEMORY', <add> type: Error, <add> message: 'Out of memory' <add> }, <add> type: 'session' <add> } <add>]; <add> <add>const genericTests = Object.getOwnPropertyNames(constants) <add> .filter((key) => ( <add> key.indexOf('NGHTTP2_ERR') === 0 && specificTestKeys.indexOf(key) < 0 <add> )) <add> .map((key) => ({ <add> ngError: constants[key], <add> error: { <add> code: 'ERR_HTTP2_ERROR', <add> type: Error, <add> message: nghttp2ErrorString(constants[key]) <add> }, <add> type: 'stream' <add> })); <add> <add> <add>const tests = specificTests.concat(genericTests); <add> <add>let currentError; <add> <add>// mock sendHeaders because we only care about testing error handling <add>Http2Session.prototype.sendHeaders = () => currentError.ngError; <add> <add>const server = http2.createServer(); <add>server.on('stream', common.mustCall((stream, headers) => { <add> const errorMustCall = common.expectsError(currentError.error); <add> const errorMustNotCall = common.mustNotCall( <add> `${currentError.error.code} should emit on ${currentError.type}` <add> ); <add> <add> if (currentError.type === 'stream') { <add> stream.session.on('error', errorMustNotCall); <add> stream.on('error', errorMustCall); <add> stream.on('error', common.mustCall(() => { <add> stream.respond(); <add> stream.end(); <add> })); <add> } else { <add> stream.session.once('error', errorMustCall); <add> stream.on('error', errorMustNotCall); <add> } <add> <add> stream.additionalHeaders({ ':status': 100 }); <add>}, tests.length)); <add> <add>server.listen(0, common.mustCall(() => runTest(tests.shift()))); <add> <add>function runTest(test) { <add> const port = server.address().port; <add> const url = `http://localhost:${port}`; <add> const headers = { <add> ':path': '/', <add> ':method': 'POST', <add> ':scheme': 'http', <add> ':authority': `localhost:${port}` <add> }; <add> <add> const client = http2.connect(url); <add> const req = client.request(headers); <add> <add> currentError = test; <add> req.resume(); <add> req.end(); <add> <add> req.on('end', common.mustCall(() => { <add> client.destroy(); <add> <add> if (!tests.length) { <add> server.close(); <add> } else { <add> runTest(tests.shift()); <add> } <add> })); <add>} <ide><path>test/parallel/test-http2-info-headers.js <ide> function onStream(stream, headers, flags) { <ide> message: status101regex <ide> })); <ide> <add> common.expectsError( <add> () => stream.additionalHeaders({ ':method': 'POST' }), <add> { <add> code: 'ERR_HTTP2_INVALID_PSEUDOHEADER', <add> type: Error, <add> message: '":method" is an invalid pseudoheader or is used incorrectly' <add> } <add> ); <add> <ide> // Can send more than one <ide> stream.additionalHeaders({ ':status': 100 }); <ide> stream.additionalHeaders({ ':status': 100 }); <ide><path>test/parallel/test-http2-priority-errors.js <add>'use strict'; <add> <add>const common = require('../common'); <add>if (!common.hasCrypto) <add> common.skip('missing crypto'); <add>const http2 = require('http2'); <add>const { <add> constants, <add> Http2Session, <add> nghttp2ErrorString <add>} = process.binding('http2'); <add> <add>// tests error handling within priority <add>// - NGHTTP2_ERR_NOMEM (should emit session error) <add>// - every other NGHTTP2 error from binding (should emit stream error) <add> <add>const specificTestKeys = [ <add> 'NGHTTP2_ERR_NOMEM' <add>]; <add> <add>const specificTests = [ <add> { <add> ngError: constants.NGHTTP2_ERR_NOMEM, <add> error: { <add> code: 'ERR_OUTOFMEMORY', <add> type: Error, <add> message: 'Out of memory' <add> }, <add> type: 'session' <add> } <add>]; <add> <add>const genericTests = Object.getOwnPropertyNames(constants) <add> .filter((key) => ( <add> key.indexOf('NGHTTP2_ERR') === 0 && specificTestKeys.indexOf(key) < 0 <add> )) <add> .map((key) => ({ <add> ngError: constants[key], <add> error: { <add> code: 'ERR_HTTP2_ERROR', <add> type: Error, <add> message: nghttp2ErrorString(constants[key]) <add> }, <add> type: 'stream' <add> })); <add> <add> <add>const tests = specificTests.concat(genericTests); <add> <add>let currentError; <add> <add>// mock submitPriority because we only care about testing error handling <add>Http2Session.prototype.submitPriority = () => currentError.ngError; <add> <add>const server = http2.createServer(); <add>server.on('stream', common.mustCall((stream, headers) => { <add> const errorMustCall = common.expectsError(currentError.error); <add> const errorMustNotCall = common.mustNotCall( <add> `${currentError.error.code} should emit on ${currentError.type}` <add> ); <add> <add> if (currentError.type === 'stream') { <add> stream.session.on('error', errorMustNotCall); <add> stream.on('error', errorMustCall); <add> stream.on('error', common.mustCall(() => { <add> stream.respond(); <add> stream.end(); <add> })); <add> } else { <add> stream.session.once('error', errorMustCall); <add> stream.on('error', errorMustNotCall); <add> } <add> <add> stream.priority({ <add> parent: 0, <add> weight: 1, <add> exclusive: false <add> }); <add>}, tests.length)); <add> <add>server.listen(0, common.mustCall(() => runTest(tests.shift()))); <add> <add>function runTest(test) { <add> const port = server.address().port; <add> const url = `http://localhost:${port}`; <add> const headers = { <add> ':path': '/', <add> ':method': 'POST', <add> ':scheme': 'http', <add> ':authority': `localhost:${port}` <add> }; <add> <add> const client = http2.connect(url); <add> const req = client.request(headers); <add> <add> currentError = test; <add> req.resume(); <add> req.end(); <add> <add> req.on('end', common.mustCall(() => { <add> client.destroy(); <add> <add> if (!tests.length) { <add> server.close(); <add> } else { <add> runTest(tests.shift()); <add> } <add> })); <add>} <ide><path>test/parallel/test-http2-respond-errors.js <add>'use strict'; <add> <add>const common = require('../common'); <add>if (!common.hasCrypto) <add> common.skip('missing crypto'); <add>const http2 = require('http2'); <add>const { <add> constants, <add> Http2Session, <add> nghttp2ErrorString <add>} = process.binding('http2'); <add> <add>// tests error handling within respond <add>// - NGHTTP2_ERR_NOMEM (should emit session error) <add>// - every other NGHTTP2 error from binding (should emit stream error) <add> <add>const specificTestKeys = [ <add> 'NGHTTP2_ERR_NOMEM' <add>]; <add> <add>const specificTests = [ <add> { <add> ngError: constants.NGHTTP2_ERR_NOMEM, <add> error: { <add> code: 'ERR_OUTOFMEMORY', <add> type: Error, <add> message: 'Out of memory' <add> }, <add> type: 'session' <add> } <add>]; <add> <add>const genericTests = Object.getOwnPropertyNames(constants) <add> .filter((key) => ( <add> key.indexOf('NGHTTP2_ERR') === 0 && specificTestKeys.indexOf(key) < 0 <add> )) <add> .map((key) => ({ <add> ngError: constants[key], <add> error: { <add> code: 'ERR_HTTP2_ERROR', <add> type: Error, <add> message: nghttp2ErrorString(constants[key]) <add> }, <add> type: 'stream' <add> })); <add> <add> <add>const tests = specificTests.concat(genericTests); <add> <add>let currentError; <add> <add>// mock submitResponse because we only care about testing error handling <add>Http2Session.prototype.submitResponse = () => currentError.ngError; <add> <add>const server = http2.createServer(); <add>server.on('stream', common.mustCall((stream, headers) => { <add> const errorMustCall = common.expectsError(currentError.error); <add> const errorMustNotCall = common.mustNotCall( <add> `${currentError.error.code} should emit on ${currentError.type}` <add> ); <add> <add> if (currentError.type === 'stream') { <add> stream.session.on('error', errorMustNotCall); <add> stream.on('error', errorMustCall); <add> stream.on('error', common.mustCall(() => { <add> stream.destroy(); <add> })); <add> } else { <add> stream.session.once('error', errorMustCall); <add> stream.on('error', errorMustNotCall); <add> } <add> <add> stream.respond(); <add>}, tests.length)); <add> <add>server.listen(0, common.mustCall(() => runTest(tests.shift()))); <add> <add>function runTest(test) { <add> const port = server.address().port; <add> const url = `http://localhost:${port}`; <add> const headers = { <add> ':path': '/', <add> ':method': 'POST', <add> ':scheme': 'http', <add> ':authority': `localhost:${port}` <add> }; <add> <add> const client = http2.connect(url); <add> const req = client.request(headers); <add> <add> currentError = test; <add> req.resume(); <add> req.end(); <add> <add> req.on('end', common.mustCall(() => { <add> client.destroy(); <add> <add> if (!tests.length) { <add> server.close(); <add> } else { <add> runTest(tests.shift()); <add> } <add> })); <add>} <ide><path>test/parallel/test-http2-respond-file-errors.js <ide> if (!common.hasCrypto) <ide> const http2 = require('http2'); <ide> const path = require('path'); <ide> <add>const { <add> HTTP2_HEADER_CONTENT_TYPE, <add> HTTP2_HEADER_METHOD <add>} = http2.constants; <add> <ide> const optionsWithTypeError = { <ide> offset: 'number', <ide> length: 'number', <ide> server.on('stream', common.mustCall((stream) => { <ide> // Should throw if :status 204, 205 or 304 <ide> [204, 205, 304].forEach((status) => common.expectsError( <ide> () => stream.respondWithFile(fname, { <del> [http2.constants.HTTP2_HEADER_CONTENT_TYPE]: 'text/plain', <add> [HTTP2_HEADER_CONTENT_TYPE]: 'text/plain', <ide> ':status': status, <ide> }), <ide> { <ide> server.on('stream', common.mustCall((stream) => { <ide> } <ide> )); <ide> <add> // should emit an error on the stream if headers aren't valid <add> stream.respondWithFile(fname, { <add> [HTTP2_HEADER_METHOD]: 'POST' <add> }, { <add> statCheck: common.mustCall(() => { <add> // give time to the current test case to finish <add> process.nextTick(continueTest, stream); <add> return true; <add> }) <add> }); <add> stream.once('error', common.expectsError({ <add> code: 'ERR_HTTP2_INVALID_PSEUDOHEADER', <add> type: Error, <add> message: '":method" is an invalid pseudoheader or is used incorrectly' <add> })); <add>})); <add> <add>function continueTest(stream) { <ide> // Should throw if headers already sent <ide> stream.respond({ <ide> ':status': 200, <ide> }); <ide> common.expectsError( <ide> () => stream.respondWithFile(fname, { <del> [http2.constants.HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' <add> [HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' <ide> }), <ide> { <ide> code: 'ERR_HTTP2_HEADERS_SENT', <ide> server.on('stream', common.mustCall((stream) => { <ide> stream.destroy(); <ide> common.expectsError( <ide> () => stream.respondWithFile(fname, { <del> [http2.constants.HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' <add> [HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' <ide> }), <ide> { <ide> code: 'ERR_HTTP2_INVALID_STREAM', <ide> message: 'The stream has been destroyed' <ide> } <ide> ); <del>})); <add>} <ide> <ide> server.listen(0, common.mustCall(() => { <ide> const client = http2.connect(`http://localhost:${server.address().port}`); <ide><path>test/parallel/test-http2-respond-file-fd-errors.js <ide> const http2 = require('http2'); <ide> const path = require('path'); <ide> const fs = require('fs'); <ide> <add>const { <add> HTTP2_HEADER_CONTENT_TYPE, <add> HTTP2_HEADER_METHOD <add>} = http2.constants; <add> <ide> const optionsWithTypeError = { <ide> offset: 'number', <ide> length: 'number', <ide> server.on('stream', common.mustCall((stream) => { <ide> <ide> common.expectsError( <ide> () => stream.respondWithFD(types[type], { <del> [http2.constants.HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' <add> [HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' <ide> }), <ide> { <ide> type: TypeError, <ide> server.on('stream', common.mustCall((stream) => { <ide> <ide> common.expectsError( <ide> () => stream.respondWithFD(fd, { <del> [http2.constants.HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' <add> [HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' <ide> }, { <ide> [option]: types[type] <ide> }), <ide> server.on('stream', common.mustCall((stream) => { <ide> // Should throw if :status 204, 205 or 304 <ide> [204, 205, 304].forEach((status) => common.expectsError( <ide> () => stream.respondWithFD(fd, { <del> [http2.constants.HTTP2_HEADER_CONTENT_TYPE]: 'text/plain', <add> [HTTP2_HEADER_CONTENT_TYPE]: 'text/plain', <ide> ':status': status, <ide> }), <ide> { <ide> code: 'ERR_HTTP2_PAYLOAD_FORBIDDEN', <add> type: Error, <ide> message: `Responses with ${status} status must not have a payload` <ide> } <ide> )); <ide> <add> // should emit an error on the stream if headers aren't valid <add> stream.respondWithFD(fd, { <add> [HTTP2_HEADER_METHOD]: 'POST' <add> }, { <add> statCheck() { <add> return true; <add> } <add> }); <add> stream.once('error', common.expectsError({ <add> code: 'ERR_HTTP2_INVALID_PSEUDOHEADER', <add> type: Error, <add> message: '":method" is an invalid pseudoheader or is used incorrectly' <add> })); <add> stream.respondWithFD(fd, { <add> [HTTP2_HEADER_METHOD]: 'POST' <add> }); <add> stream.once('error', common.expectsError({ <add> code: 'ERR_HTTP2_INVALID_PSEUDOHEADER', <add> type: Error, <add> message: '":method" is an invalid pseudoheader or is used incorrectly' <add> })); <add> <ide> // Should throw if headers already sent <ide> stream.respond({ <ide> ':status': 200, <ide> }); <ide> common.expectsError( <ide> () => stream.respondWithFD(fd, { <del> [http2.constants.HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' <add> [HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' <ide> }), <ide> { <ide> code: 'ERR_HTTP2_HEADERS_SENT', <add> type: Error, <ide> message: 'Response has already been initiated.' <ide> } <ide> ); <ide> server.on('stream', common.mustCall((stream) => { <ide> stream.destroy(); <ide> common.expectsError( <ide> () => stream.respondWithFD(fd, { <del> [http2.constants.HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' <add> [HTTP2_HEADER_CONTENT_TYPE]: 'text/plain' <ide> }), <ide> { <ide> code: 'ERR_HTTP2_INVALID_STREAM', <add> type: Error, <ide> message: 'The stream has been destroyed' <ide> } <ide> ); <ide><path>test/parallel/test-http2-respond-with-fd-errors.js <add>'use strict'; <add> <add>const common = require('../common'); <add>if (!common.hasCrypto) <add> common.skip('missing crypto'); <add>const http2 = require('http2'); <add>const path = require('path'); <add> <add>const { <add> constants, <add> Http2Session, <add> nghttp2ErrorString <add>} = process.binding('http2'); <add> <add>// tests error handling within processRespondWithFD <add>// (called by respondWithFD & respondWithFile) <add>// - NGHTTP2_ERR_NOMEM (should emit session error) <add>// - every other NGHTTP2 error from binding (should emit stream error) <add> <add>const fname = path.resolve(common.fixturesDir, 'elipses.txt'); <add> <add>const specificTestKeys = [ <add> 'NGHTTP2_ERR_NOMEM' <add>]; <add> <add>const specificTests = [ <add> { <add> ngError: constants.NGHTTP2_ERR_NOMEM, <add> error: { <add> code: 'ERR_OUTOFMEMORY', <add> type: Error, <add> message: 'Out of memory' <add> }, <add> type: 'session' <add> } <add>]; <add> <add>const genericTests = Object.getOwnPropertyNames(constants) <add> .filter((key) => ( <add> key.indexOf('NGHTTP2_ERR') === 0 && specificTestKeys.indexOf(key) < 0 <add> )) <add> .map((key) => ({ <add> ngError: constants[key], <add> error: { <add> code: 'ERR_HTTP2_ERROR', <add> type: Error, <add> message: nghttp2ErrorString(constants[key]) <add> }, <add> type: 'stream' <add> })); <add> <add> <add>const tests = specificTests.concat(genericTests); <add> <add>let currentError; <add> <add>// mock submitFile because we only care about testing error handling <add>Http2Session.prototype.submitFile = () => currentError.ngError; <add> <add>const server = http2.createServer(); <add>server.on('stream', common.mustCall((stream, headers) => { <add> const errorMustCall = common.expectsError(currentError.error); <add> const errorMustNotCall = common.mustNotCall( <add> `${currentError.error.code} should emit on ${currentError.type}` <add> ); <add> <add> if (currentError.type === 'stream') { <add> stream.session.on('error', errorMustNotCall); <add> stream.on('error', errorMustCall); <add> stream.on('error', common.mustCall(() => { <add> stream.destroy(); <add> })); <add> } else { <add> stream.session.once('error', errorMustCall); <add> stream.on('error', errorMustNotCall); <add> } <add> <add> stream.respondWithFile(fname); <add>}, tests.length)); <add> <add>server.listen(0, common.mustCall(() => runTest(tests.shift()))); <add> <add>function runTest(test) { <add> const port = server.address().port; <add> const url = `http://localhost:${port}`; <add> const headers = { <add> ':path': '/', <add> ':method': 'POST', <add> ':scheme': 'http', <add> ':authority': `localhost:${port}` <add> }; <add> <add> const client = http2.connect(url); <add> const req = client.request(headers); <add> <add> currentError = test; <add> req.resume(); <add> req.end(); <add> <add> req.on('end', common.mustCall(() => { <add> client.destroy(); <add> <add> if (!tests.length) { <add> server.close(); <add> } else { <add> runTest(tests.shift()); <add> } <add> })); <add>} <ide><path>test/parallel/test-http2-rststream-errors.js <add>'use strict'; <add> <add>const common = require('../common'); <add>if (!common.hasCrypto) <add> common.skip('missing crypto'); <add>const http2 = require('http2'); <add>const { <add> constants, <add> Http2Session, <add> nghttp2ErrorString <add>} = process.binding('http2'); <add> <add>// tests error handling within rstStream <add>// - NGHTTP2_ERR_NOMEM (should emit session error) <add>// - every other NGHTTP2 error from binding (should emit stream error) <add> <add>const specificTestKeys = [ <add> 'NGHTTP2_ERR_NOMEM' <add>]; <add> <add>const specificTests = [ <add> { <add> ngError: constants.NGHTTP2_ERR_NOMEM, <add> error: { <add> code: 'ERR_OUTOFMEMORY', <add> type: Error, <add> message: 'Out of memory' <add> }, <add> type: 'session' <add> } <add>]; <add> <add>const genericTests = Object.getOwnPropertyNames(constants) <add> .filter((key) => ( <add> key.indexOf('NGHTTP2_ERR') === 0 && specificTestKeys.indexOf(key) < 0 <add> )) <add> .map((key) => ({ <add> ngError: constants[key], <add> error: { <add> code: 'ERR_HTTP2_ERROR', <add> type: Error, <add> message: nghttp2ErrorString(constants[key]) <add> }, <add> type: 'stream' <add> })); <add> <add> <add>const tests = specificTests.concat(genericTests); <add> <add>let currentError; <add> <add>// mock submitRstStream because we only care about testing error handling <add>Http2Session.prototype.submitRstStream = () => currentError.ngError; <add> <add>const server = http2.createServer(); <add>server.on('stream', common.mustCall((stream, headers) => { <add> const errorMustCall = common.expectsError(currentError.error); <add> const errorMustNotCall = common.mustNotCall( <add> `${currentError.error.code} should emit on ${currentError.type}` <add> ); <add> <add> if (currentError.type === 'stream') { <add> stream.session.on('error', errorMustNotCall); <add> stream.on('error', errorMustCall); <add> stream.on('error', common.mustCall(() => { <add> stream.session.destroy(); <add> })); <add> } else { <add> stream.session.once('error', errorMustCall); <add> stream.on('error', errorMustNotCall); <add> } <add> <add> stream.rstStream(); <add>}, tests.length)); <add> <add>server.listen(0, common.mustCall(() => runTest(tests.shift()))); <add> <add>function runTest(test) { <add> const port = server.address().port; <add> const url = `http://localhost:${port}`; <add> const headers = { <add> ':path': '/', <add> ':method': 'POST', <add> ':scheme': 'http', <add> ':authority': `localhost:${port}` <add> }; <add> <add> const client = http2.connect(url); <add> const req = client.request(headers); <add> <add> currentError = test; <add> req.resume(); <add> req.end(); <add> <add> if (currentError.type === 'stream') { <add> req.on('error', common.mustCall()); <add> } <add> <add> req.on('end', common.mustCall(() => { <add> client.destroy(); <add> <add> if (!tests.length) { <add> server.close(); <add> } else { <add> runTest(tests.shift()); <add> } <add> })); <add>} <ide><path>test/parallel/test-http2-server-push-stream-errors.js <ide> server.on('stream', common.mustCall((stream, headers) => { <ide> const errorMustNotCall = common.mustNotCall( <ide> `${currentError.error.code} should emit on ${currentError.type}` <ide> ); <del> console.log(currentError); <ide> <ide> if (currentError.type === 'stream') { <ide> stream.session.on('error', errorMustNotCall); <ide><path>test/parallel/test-http2-shutdown-errors.js <add>'use strict'; <add> <add>const common = require('../common'); <add>if (!common.hasCrypto) <add> common.skip('missing crypto'); <add>const http2 = require('http2'); <add>const { <add> constants, <add> Http2Session, <add> nghttp2ErrorString <add>} = process.binding('http2'); <add> <add>// tests error handling within shutdown <add>// - should emit ERR_HTTP2_ERROR on session for all errors <add> <add>const tests = Object.getOwnPropertyNames(constants) <add> .filter((key) => ( <add> key.indexOf('NGHTTP2_ERR') === 0 <add> )) <add> .map((key) => ({ <add> ngError: constants[key], <add> error: { <add> code: 'ERR_HTTP2_ERROR', <add> type: Error, <add> message: nghttp2ErrorString(constants[key]) <add> } <add> })); <add> <add>let currentError; <add> <add>// mock submitGoaway because we only care about testing error handling <add>Http2Session.prototype.submitGoaway = () => currentError.ngError; <add> <add>const server = http2.createServer(); <add>server.on('stream', common.mustCall((stream, headers) => { <add> const errorMustCall = common.expectsError(currentError.error); <add> const errorMustNotCall = common.mustNotCall( <add> `${currentError.error.code} should emit on session` <add> ); <add> <add> stream.session.once('error', errorMustCall); <add> stream.on('error', errorMustNotCall); <add> <add> stream.session.shutdown(); <add>}, tests.length)); <add> <add>server.listen(0, common.mustCall(() => runTest(tests.shift()))); <add> <add>function runTest(test) { <add> const port = server.address().port; <add> const url = `http://localhost:${port}`; <add> const headers = { <add> ':path': '/', <add> ':method': 'POST', <add> ':scheme': 'http', <add> ':authority': `localhost:${port}` <add> }; <add> <add> const client = http2.connect(url); <add> const req = client.request(headers); <add> <add> currentError = test; <add> req.resume(); <add> req.end(); <add> <add> req.on('end', common.mustCall(() => { <add> client.destroy(); <add> <add> if (!tests.length) { <add> server.close(); <add> } else { <add> runTest(tests.shift()); <add> } <add> })); <add>}
11
Ruby
Ruby
remove unneeded reject
093c4eedd0296b6297ab4359d7d873cdf0daf43e
<ide><path>activerecord/lib/active_record/relation/query_methods.rb <ide> def includes(*args) <ide> end <ide> <ide> def eager_load(*args) <del> args.reject! { |a| a.blank? } <ide> clone.tap { |r| r.eager_load_values += args if args.present? } <ide> end <ide> <ide> def preload(*args) <del> args.reject! { |a| a.blank? } <ide> clone.tap { |r| r.preload_values += args if args.present? } <ide> end <ide> <ide> def select(*args) <ide> if block_given? <ide> to_a.select { |*block_args| yield(*block_args) } <ide> else <del> args.reject! { |a| a.blank? } <ide> clone.tap { |r| r.select_values += args if args.present? } <ide> end <ide> end <ide> <ide> def group(*args) <del> args.reject! { |a| a.blank? } <ide> clone.tap { |r| r.group_values += args if args.present? } <ide> end <ide> <ide> def order(*args) <del> args.reject! { |a| a.blank? } <ide> clone.tap { |r| r.order_values += args if args.present? } <ide> end <ide> <ide> def reorder(*args) <del> args.reject! { |a| a.blank? } <ide> clone.tap { |r| r.order_values = args if args.present? } <ide> end <ide> <ide> def joins(*args) <ide> args.flatten! <del> args.reject! { |a| a.blank? } <ide> clone.tap { |r| r.joins_values += args if args.present? } <ide> end <ide> <ide> def build_joins(relation, joins) <ide> <ide> stashed_association_joins = joins.select {|j| j.is_a?(ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation)} <ide> <del> non_association_joins = (joins - association_joins - stashed_association_joins).reject {|j| j.blank?} <add> non_association_joins = (joins - association_joins - stashed_association_joins) <ide> custom_joins = custom_join_sql(*non_association_joins) <ide> <ide> join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(@klass, association_joins, custom_joins)
1
Javascript
Javascript
remove ternary, add unit test
697203b545f6fd459b15f3159ab023a53c454ac1
<ide><path>src/lib/moment/to-type.js <ide> export function unix () { <ide> } <ide> <ide> export function toDate () { <del> return this._offset ? new Date(this.valueOf()) : new Date(this._d); <add> return new Date(this.valueOf()); <ide> } <ide> <ide> export function toArray () { <ide><path>src/test/moment/to_type.js <ide> test('toArray', function (assert) { <ide> var expected = [2014, 11, 26, 11, 46, 58, 17]; <ide> assert.deepEqual(moment(expected).toArray(), expected, 'toArray invalid'); <ide> }); <add> <add>test('toDate returns a copy of the internal date', function (assert) { <add> var m = moment(); <add> var d = m.toDate(); <add> m.year(0); <add> assert.notEqual(d, m.toDate()); <add>});
2
Ruby
Ruby
handle error when 'brew search' can't reach github
296d48ba7af0daf010fdb412288b395ea2422bfb
<ide><path>Library/Homebrew/cmd/search.rb <ide> def search_taps(query, silent: false) <ide> end <ide> <ide> valid_dirnames = ["Formula", "HomebrewFormula", "Casks", "."].freeze <del> matches = GitHub.search_code(user: ["Homebrew", "caskroom"], filename: query, extension: "rb") <del> <add> matches = begin <add> GitHub.search_code( <add> user: ["Homebrew", "caskroom"], <add> filename: query, <add> extension: "rb", <add> ) <add> rescue GitHub::Error => error <add> opoo "Error searching on GitHub: #{error}\n" <add> [] <add> end <ide> matches.map do |match| <ide> dirname, filename = File.split(match["path"]) <ide> next unless valid_dirnames.include?(dirname)
1
Javascript
Javascript
remove redundant code directive
b517f49a802a721ce903c751fa293b26f915c3b0
<ide><path>docs/app/src/directives.js <ide> angular.module('directives', []) <ide> <del>.directive('code', function() { <del> return { restrict:'E', terminal: true }; <del>}) <del> <ide> /** <ide> * backToTop Directive <ide> * @param {Function} $anchorScroll
1
Javascript
Javascript
revise argument processing
4069e7eddb4bdefebcf1e2be2bbcd0f3d35f64b1
<ide><path>lib/child_process.js <ide> const MAX_BUFFER = 1024 * 1024; <ide> * }} [options] <ide> * @returns {ChildProcess} <ide> */ <del>function fork(modulePath /* , args, options */) { <add>function fork(modulePath, args = [], options) { <ide> modulePath = getValidatedPath(modulePath, 'modulePath'); <ide> <ide> // Get options and args arguments. <ide> let execArgv; <del> let options = {}; <del> let args = []; <del> let pos = 1; <del> if (pos < arguments.length && ArrayIsArray(arguments[pos])) { <del> args = arguments[pos++]; <del> } <ide> <del> if (pos < arguments.length && arguments[pos] == null) { <del> pos++; <add> if (args == null) { <add> args = []; <add> } else if (typeof args !== 'object') { <add> throw new ERR_INVALID_ARG_VALUE('args', args); <add> } else if (!ArrayIsArray(args)) { <add> options = args; <add> args = []; <ide> } <ide> <del> if (pos < arguments.length && arguments[pos] != null) { <del> if (typeof arguments[pos] !== 'object') { <del> throw new ERR_INVALID_ARG_VALUE(`arguments[${pos}]`, arguments[pos]); <del> } <del> <del> options = { ...arguments[pos++] }; <add> if (options == null) { <add> options = {}; <add> } else if (typeof options !== 'object') { <add> throw new ERR_INVALID_ARG_VALUE('options', options); <add> } else { <add> options = { ...options }; <ide> } <ide> <ide> // Prepare arguments for fork: <ide> ObjectDefineProperty(exec, promisify.custom, { <ide> * ) => any} [callback] <ide> * @returns {ChildProcess} <ide> */ <del>function execFile(file /* , args, options, callback */) { <del> let args = []; <del> let callback; <del> let options; <del> <del> // Parse the optional positional parameters. <del> let pos = 1; <del> if (pos < arguments.length && ArrayIsArray(arguments[pos])) { <del> args = arguments[pos++]; <del> } else if (pos < arguments.length && arguments[pos] == null) { <del> pos++; <del> } <del> <del> if (pos < arguments.length && typeof arguments[pos] === 'object') { <del> options = arguments[pos++]; <del> } else if (pos < arguments.length && arguments[pos] == null) { <del> pos++; <add>function execFile(file, args = [], options, callback) { <add> if (args == null) { <add> args = []; <add> } else if (typeof args === 'object') { <add> if (!ArrayIsArray(args)) { <add> callback = options; <add> options = args; <add> args = []; <add> } <add> } else if (typeof args === 'function') { <add> callback = args; <add> options = {}; <add> args = []; <add> } else { <add> throw new ERR_INVALID_ARG_VALUE('args', args); <ide> } <ide> <del> if (pos < arguments.length && typeof arguments[pos] === 'function') { <del> callback = arguments[pos++]; <add> if (options == null) { <add> options = {}; <add> } else if (typeof options === 'function') { <add> callback = options; <add> options = {}; <add> } else if (typeof options !== 'object') { <add> throw new ERR_INVALID_ARG_VALUE('options', options); <ide> } <ide> <del> if (!callback && pos < arguments.length && arguments[pos] != null) { <del> throw new ERR_INVALID_ARG_VALUE('args', arguments[pos]); <add> if (callback && typeof callback !== 'function') { <add> throw new ERR_INVALID_ARG_VALUE('callback', callback); <ide> } <ide> <ide> options = {
1
Ruby
Ruby
remove useless ivar clearing
889a4a3da025e52d0f044d9b1b832a45fcc88c01
<ide><path>actionpack/lib/action_controller/test_case.rb <ide> def assign_parameters(routes, controller_path, action, parameters = {}) <ide> path_parameters[:action] = action <ide> <ide> self.path_parameters = path_parameters <del> <del> # Clear the combined params hash in case it was already referenced. <del> @env.delete("action_dispatch.request.parameters") <del> <del> # Clear the filter cache variables so they're not stale <del> @filtered_parameters = @filtered_env = @filtered_path = nil <ide> end <ide> <ide> ENCODER = Class.new do
1
Ruby
Ruby
implement bottles again
6ac0a285239d5fbd7943f070eac0e68847046ff8
<ide><path>Library/Homebrew/download_strategy.rb <ide> def _fetch <ide> class CurlBottleDownloadStrategy <CurlDownloadStrategy <ide> def initialize url, name, version, specs <ide> super <del> HOMEBREW_CACHE_BOTTLES.mkpath <del> @tarball_path=HOMEBREW_CACHE_BOTTLES+("#{name}-#{version}"+ext) <add> @tarball_path = HOMEBREW_CACHE/"#{name}-#{version}.bottle#{ext}" <ide> end <ide> def stage <ide> ohai "Pouring #{File.basename(@tarball_path)}" <ide><path>Library/Homebrew/formula.rb <ide> def detect_version <ide> end <ide> end <ide> <del>class BottleSoftwareSpecification < SoftwareSpecification <del> def download_strategy <del> return CurlBottleDownloadStrategy if @using.nil? <del> raise "Strategies cannot be used with bottles." <del> end <del>end <del> <ide> <ide> # Used to annotate formulae that duplicate OS X provided software <ide> # or cause conflicts when linked in. <ide> def initialize name='__UNKNOWN__', path=nil <ide> @url = @head <ide> @version = 'HEAD' <ide> @spec_to_use = @unstable <del> elsif pourable? <del> @spec_to_use = BottleSoftwareSpecification.new(@bottle, @specs) <ide> else <ide> if @stable.nil? <ide> @spec_to_use = SoftwareSpecification.new(@url, @specs) <ide> def self.expand_deps f <ide> end <ide> end <ide> <del> def pourable? <del> @bottle and not ARGV.build_from_source? <del> end <del> <ide> protected <ide> # Pretty titles the command and buffers stdout/stderr <ide> # Throws if there's an error <ide> def mktemp <ide> <ide> CHECKSUM_TYPES=[:md5, :sha1, :sha256].freeze <ide> <del> def verify_download_integrity fn <add> public # for FormulaInstaller <add> <add> def verify_download_integrity fn, *args <ide> require 'digest' <del> if not pourable? <add> if args.count != 2 <ide> type=CHECKSUM_TYPES.detect { |type| instance_variable_defined?("@#{type}") } <ide> type ||= :md5 <ide> supplied=instance_variable_get("@#{type}") <ide> type=type.to_s.upcase <ide> else <del> supplied=instance_variable_get("@bottle_sha1") <del> type="SHA1" <add> supplied, type = args <ide> end <ide> <ide> hasher = Digest.const_get(type) <ide> def verify_download_integrity fn <ide> end <ide> end <ide> <add> private <add> <ide> def stage <ide> HOMEBREW_CACHE.mkpath <ide> fetched = @downloader.fetch <ide> verify_download_integrity fetched if fetched.kind_of? Pathname <del> <del> if not pourable? <del> mktemp do <del> @downloader.stage <del> yield <del> end <del> else <del> HOMEBREW_CELLAR.cd do <del> @downloader.stage <del> yield <del> end <add> mktemp do <add> @downloader.stage <add> yield <ide> end <ide> end <ide> <ide> def patch <del> return if patches.nil? or pourable? <add> return if patches.nil? <ide> <ide> if not patches.kind_of? Hash <ide> # We assume -p1 <ide><path>Library/Homebrew/formula_installer.rb <ide> def initialize ff <ide> @f = ff <ide> @show_header = true <ide> @ignore_deps = ARGV.include? '--ignore-dependencies' || ARGV.interactive? <del> @install_bottle = ff.pourable? #TODO better <add> @install_bottle = !ff.bottle.nil? && !ARGV.build_from_source? <ide> end <ide> <ide> def install <ide> def fix_install_names <ide> <ide> def clean <ide> require 'cleaner' <del> Cleaner.new f if not f.pourable? <add> Cleaner.new f <ide> rescue Exception => e <ide> opoo "The cleaning step did not complete successfully" <ide> puts "Still, the installation was successful, so we will link it into your prefix" <ide> ohai e, e.backtrace if ARGV.debug? <ide> @show_summary_heading = true <ide> end <ide> <add> def pour <add> HOMEBREW_CACHE.mkpath <add> downloader = CurlBottleDownloadStrategy.new f.bottle, f.name, f.version, nil <add> downloader.fetch <add> f.verify_download_integrity downloader.tarball_path, f.bottle_sha1, "SHA1" <add> HOMEBREW_CELLAR.cd do <add> downloader.stage <add> end <add> end <add> <add> ## checks <add> <ide> def paths <ide> @paths ||= ENV['PATH'].split(':').map{ |p| File.expand_path p } <ide> end
3
Java
Java
promote anonymous observables to top-level types.
5273cf05e6e4d12bf3e4bd716d036600a80c4919
<ide><path>src/main/java/io/reactivex/Observable.java <ide> import io.reactivex.disposables.*; <ide> import io.reactivex.exceptions.Exceptions; <ide> import io.reactivex.functions.*; <del>import io.reactivex.internal.disposables.EmptyDisposable; <ide> import io.reactivex.internal.functions.Functions; <ide> import io.reactivex.internal.functions.Objects; <ide> import io.reactivex.internal.operators.flowable.FlowableFromObservable; <ide> public abstract class Observable<T> implements ObservableSource<T> { <ide> static final Object OBJECT = new Object(); <ide> <del> /** An empty observable instance as there is no need to instantiate this more than once. */ <del> static final Observable<Object> EMPTY = new Observable<Object>() { <del> @Override <del> protected void subscribeActual(Observer<? super Object> o) { <del> o.onSubscribe(EmptyDisposable.INSTANCE); <del> o.onComplete(); <del> } <del> }; <del> <del> /** A never observable instance as there is no need to instantiate this more than once. */ <del> static final Observable<Object> NEVER = new Observable<Object>() { <del> @Override <del> protected void subscribeActual(Observer<? super Object> o) { <del> o.onSubscribe(EmptyDisposable.INSTANCE); <del> } <del> }; <del> <ide> public static <T> Observable<T> amb(Iterable<? extends ObservableSource<? extends T>> sources) { <ide> Objects.requireNonNull(sources, "sources is null"); <ide> return new ObservableAmb<T>(null, sources); <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>)EMPTY; <add> return (Observable<T>) ObservableEmpty.INSTANCE; <ide> } <ide> <ide> @SchedulerSupport(SchedulerSupport.NONE) <ide> public static <T> Observable<T> fromIterable(Iterable<? extends T> source) { <ide> <ide> public static <T> Observable<T> fromPublisher(final Publisher<? extends T> publisher) { <ide> Objects.requireNonNull(publisher, "publisher is null"); <del> return new Observable<T>() { <del> @Override <del> protected void subscribeActual(final Observer<? super T> o) { <del> publisher.subscribe(new Subscriber<T>() { <del> <del> @Override <del> public void onComplete() { <del> o.onComplete(); <del> } <del> <del> @Override <del> public void onError(Throwable t) { <del> o.onError(t); <del> } <del> <del> @Override <del> public void onNext(T t) { <del> o.onNext(t); <del> } <del> <del> @Override <del> public void onSubscribe(Subscription inner) { <del> o.onSubscribe(Disposables.from(inner)); <del> inner.request(Long.MAX_VALUE); <del> } <del> <del> }); <del> } <del> }; <add> return new ObservableFromPublisher<T>(publisher); <ide> } <ide> <ide> @SchedulerSupport(SchedulerSupport.NONE) <ide> public static <T> Observable<T> mergeDelayError(ObservableSource<? extends T>... <ide> @SchedulerSupport(SchedulerSupport.NONE) <ide> @SuppressWarnings("unchecked") <ide> public static <T> Observable<T> never() { <del> return (Observable<T>)NEVER; <add> return (Observable<T>) ObservableNever.INSTANCE; <ide> } <ide> <ide> @SchedulerSupport(SchedulerSupport.NONE) <ide> public static Observable<Integer> range(final int start, final int count) { <ide> if ((long)start + (count - 1) > Integer.MAX_VALUE) { <ide> throw new IllegalArgumentException("Integer overflow"); <ide> } <del> return new Observable<Integer>() { <del> @Override <del> protected void subscribeActual(Observer<? super Integer> o) { <del> Disposable d = Disposables.empty(); <del> o.onSubscribe(d); <del> <del> long end = start - 1L + count; <del> for (long i = start; i <= end && !d.isDisposed(); i++) { <del> o.onNext((int)i); <del> } <del> if (!d.isDisposed()) { <del> o.onComplete(); <del> } <del> } <del> }; <add> return new ObservableRange(start, count); <ide> } <ide> <ide> @SchedulerSupport(SchedulerSupport.NONE) <ide> public final Observable<Boolean> any(Predicate<? super T> predicate) { <ide> <ide> @SchedulerSupport(SchedulerSupport.NONE) <ide> public final Observable<T> asObservable() { <del> final Observable<T> outer = this; <del> return new Observable<T>() { <del> @Override <del> protected void subscribeActual(Observer<? super T> o) { <del> outer.subscribe(o); <del> } <del> }; <add> return new ObservableWrapper<T>(this); <ide> } <ide> <ide> @SchedulerSupport(SchedulerSupport.NONE) <ide> public final <U, R> Observable<R> zipWith(ObservableSource<? extends U> other, B <ide> public final <U, R> Observable<R> zipWith(ObservableSource<? extends U> other, BiFunction<? super T, ? super U, ? extends R> zipper, boolean delayError, int bufferSize) { <ide> return zip(this, other, zipper, delayError, bufferSize); <ide> } <del> <del> <del> } <add>} <ide><path>src/main/java/io/reactivex/internal/operators/observable/ObservableEmpty.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>package io.reactivex.internal.operators.observable; <add> <add>import io.reactivex.Observable; <add>import io.reactivex.Observer; <add>import io.reactivex.internal.disposables.EmptyDisposable; <add> <add>public final class ObservableEmpty extends Observable<Object> { <add> public static final Observable<Object> INSTANCE = new ObservableEmpty(); <add> <add> private ObservableEmpty() { <add> } <add> <add> @Override <add> protected void subscribeActual(Observer<? super Object> o) { <add> o.onSubscribe(EmptyDisposable.INSTANCE); <add> o.onComplete(); <add> } <add>} <ide><path>src/main/java/io/reactivex/internal/operators/observable/ObservableFromPublisher.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>package io.reactivex.internal.operators.observable; <add> <add>import io.reactivex.Observable; <add>import io.reactivex.Observer; <add>import io.reactivex.disposables.Disposable; <add>import java.util.concurrent.atomic.AtomicBoolean; <add>import org.reactivestreams.Publisher; <add>import org.reactivestreams.Subscriber; <add>import org.reactivestreams.Subscription; <add> <add>public final class ObservableFromPublisher<T> extends Observable<T> { <add> private final Publisher<? extends T> publisher; <add> <add> public ObservableFromPublisher(Publisher<? extends T> publisher) { <add> this.publisher = publisher; <add> } <add> <add> @Override <add> protected void subscribeActual(final Observer<? super T> o) { <add> publisher.subscribe(new PublisherSubscriber<T>(o)); <add> } <add> <add> static final class PublisherSubscriber<T> <add> extends AtomicBoolean <add> implements Subscriber<T>, Disposable { <add> <add> private final Observer<? super T> o; <add> private Subscription inner; <add> <add> PublisherSubscriber(Observer<? super T> o) { <add> this.o = o; <add> } <add> <add> @Override <add> public void onComplete() { <add> o.onComplete(); <add> } <add> <add> @Override <add> public void onError(Throwable t) { <add> o.onError(t); <add> } <add> <add> @Override <add> public void onNext(T t) { <add> o.onNext(t); <add> } <add> <add> @Override <add> public void onSubscribe(Subscription inner) { <add> this.inner = inner; <add> o.onSubscribe(this); <add> inner.request(Long.MAX_VALUE); <add> } <add> <add> @Override public void dispose() { <add> if (compareAndSet(false, true)) { <add> inner.cancel(); <add> inner = null; <add> } <add> } <add> <add> @Override public boolean isDisposed() { <add> return get(); <add> } <add> } <add>} <ide><path>src/main/java/io/reactivex/internal/operators/observable/ObservableNever.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>package io.reactivex.internal.operators.observable; <add> <add>import io.reactivex.Observable; <add>import io.reactivex.Observer; <add>import io.reactivex.internal.disposables.EmptyDisposable; <add> <add>public final class ObservableNever extends Observable<Object> { <add> public static final Observable<Object> INSTANCE = new ObservableNever(); <add> <add> private ObservableNever() { <add> } <add> <add> @Override <add> protected void subscribeActual(Observer<? super Object> o) { <add> o.onSubscribe(EmptyDisposable.INSTANCE); <add> } <add>} <ide><path>src/main/java/io/reactivex/internal/operators/observable/ObservableRange.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>package io.reactivex.internal.operators.observable; <add> <add>import io.reactivex.Observable; <add>import io.reactivex.Observer; <add>import io.reactivex.disposables.Disposable; <add>import io.reactivex.disposables.Disposables; <add> <add>public final class ObservableRange extends Observable<Integer> { <add> private final int start; <add> private final int count; <add> <add> public ObservableRange(int start, int count) { <add> this.start = start; <add> this.count = count; <add> } <add> <add> @Override <add> protected void subscribeActual(Observer<? super Integer> o) { <add> Disposable d = Disposables.empty(); <add> o.onSubscribe(d); <add> <add> long end = start - 1L + count; <add> for (long i = start; i <= end && !d.isDisposed(); i++) { <add> o.onNext((int)i); <add> } <add> if (!d.isDisposed()) { <add> o.onComplete(); <add> } <add> } <add>}
5
Python
Python
fix long lines reported by flake8
36c93d40a6b4b510cbf98237257d9ff21acd946b
<ide><path>libcloud/compute/drivers/ec2.py <ide> def ex_authorize_security_group_ingress(self, id, from_port, to_port, <ide> <ide> [{'group_name': 'default', 'user_id': '1234567890'}] <ide> <del> VPC example: To allow access from any system associated with <del> security group sg-47ad482e on your own account <add> VPC example: To allow access from any system associated <add> with security group sg-47ad482e on your own account <ide> <ide> [{'group_id': ' sg-47ad482e'}] <ide> :type group_pairs: ``list`` of ``dict`` <ide> def ex_get_console_output(self, node): <ide> <ide> :return: A dictionary with the following keys: <ide> - instance_id (``str``) <del> - timestamp (``datetime.datetime``) - timestamp of the last output <add> - timestamp (``datetime.datetime``) - last output timestamp <ide> - output (``str``) - console output <ide> :rtype: ``dict`` <ide> """ <ide> def ex_import_keypair(self, name, keyfile): <ide> @note: This is a non-standard extension API, and only works for EC2. <ide> <ide> :param name: The name of the public key to import. This must be <del> unique, otherwise an InvalidKeyPair.Duplicate exception is raised. <add> unique, otherwise an InvalidKeyPair. Duplicate <add> exception is raised. <ide> :type name: ``str`` <ide> <del> :param keyfile: The filename with the path of the public key to import. <add> :param keyfile: The filename with the path of the public key <add> to import. <ide> :type keyfile: ``str`` <ide> <ide> :rtype: ``dict`` <ide> def __init__(self, key, secret=None, secure=True, host=None, port=None, <ide> <ide> def create_node(self, **kwargs): <ide> """ <del> Creates a new Outscale node. The ex_iamprofile keyword is not supported. <add> Creates a new Outscale node. The ex_iamprofile keyword <add> is not supported. <ide> <ide> @inherits: :class:`BaseEC2NodeDriver.create_node` <ide> <ide> def create_node(self, **kwargs): <ide> assign to the node. <ide> :type ex_security_groups: ``list`` <ide> <del> :keyword ex_metadata: The Key/Value metadata to associate with a node <add> :keyword ex_metadata: The Key/Value metadata to associate <add> with a node. <ide> :type ex_metadata: ``dict`` <ide> <ide> :keyword ex_mincount: The minimum number of nodes to launch
1
Text
Text
translate a subtitle that was in english
846634ce363a5875ecf49611c457f1dd9336f579
<ide><path>guide/spanish/c/pointers/index.md <ide> Eche un vistazo a este cรณdigo, que cambia algo de mayรบsculas a minรบsculas: <ide> <ide> Esto comienza tomando una cadena (algo sobre lo que aprenderรก cuando ingrese a los arreglos) y se ejecuta en cada ubicaciรณn. Note el p ++. Esto incrementa el puntero, lo que significa que estรก mirando la siguiente ubicaciรณn de memoria. Cada letra es una ubicaciรณn de memoria, por lo tanto, el puntero estรก mirando cada letra y decidiendo quรฉ hacer para cada una. <ide> <del>### Const Qualifer <add>### El calificador const <ide> <del>El calificador const se puede aplicar a la declaraciรณn de cualquier variable para especificar que su valor no se modificarรก (lo que depende del lugar donde se almacenan las variables const, podemos cambiar el valor de la variable const usando el puntero). <add>El calificador const se puede aplicar a la declaraciรณn de cualquier variable para especificar que su valor no se modificarรก (lo cual depende del lugar donde se almacenen las variables const, podrรญamos cambiar el valor de la variable const usando el puntero). <ide> <ide> # Puntero a variable <ide> <ide> La mayorรญa de las veces, los accesos de punteros y matrices pueden tratarse com <ide> p++; /*Legal*/ <ide> a++; /*illegal*/ <ide> <del>``` <ide>\ No newline at end of file <add>```
1
Javascript
Javascript
reset module cache between tests
d6183570e3f9dd54ca02dca55fd0f518b2218084
<ide><path>src/isomorphic/deprecated/__tests__/cloneWithProps-test.js <ide> var emptyObject; <ide> describe('cloneWithProps', function() { <ide> <ide> beforeEach(function() { <add> require('mock-modules').dumpCache(); <ide> React = require('React'); <ide> ReactTestUtils = require('ReactTestUtils'); <ide> onlyChild = require('onlyChild'); <ide><path>src/renderers/shared/reconciler/__tests__/ReactCompositeComponent-test.js <ide> var reactComponentExpect; <ide> describe('ReactCompositeComponent', function() { <ide> <ide> beforeEach(function() { <add> require('mock-modules').dumpCache(); <ide> reactComponentExpect = require('reactComponentExpect'); <ide> React = require('React'); <ide> ReactCurrentOwner = require('ReactCurrentOwner');
2
Python
Python
use hashlib instead of deprecated md5 library
2db323a9ed2b2b0109f3e7bc356d9f984d69d68e
<ide><path>libcloud/drivers/gogrid.py <ide> import httplib <ide> import time <ide> import urllib <del>import md5, hashlib <add>import hashlib <ide> <ide> # JSON is included in the standard library starting with Python 2.6. For 2.5 <ide> # and 2.4, there's a simplejson egg at: http://pypi.python.org/pypi/simplejson <ide> def add_default_params(self, params): <ide> <ide> def get_signature(self, key, secret): <ide> """ create sig from md5 of key + secret + time """ <del> m = md5.new(key+secret+str(int(time.time()))) <add> m = hashlib.md5(key+secret+str(int(time.time()))) <ide> return m.hexdigest() <ide> <ide> class GoGridNode(Node):
1
Javascript
Javascript
fix uint usage
23bc284ab57e57d2a3f66c42cb3b4db99a21121b
<ide><path>examples/jsm/nodes/shadernode/ShaderNodeUtils.js <ide> import ArrayElementNode from '../utils/ArrayElementNode.js'; <ide> import ConvertNode from '../utils/ConvertNode.js'; <ide> import JoinNode from '../utils/JoinNode.js'; <ide> import SplitNode from '../utils/SplitNode.js'; <del> <ide> import ConstNode from '../core/ConstNode.js'; <ide> import { getValueFromType } from '../core/NodeUtils.js'; <ide> <ide> export const NodeHandler = { <ide> <ide> // accessing array <ide> <del> return new ShaderNodeObject( new ArrayElementNode( node, uint( Number( prop ) ) ) ); <add> return new ShaderNodeObject( new ArrayElementNode( node, new ConstNode( Number( prop ), 'uint' ) ) ); <ide> <ide> } <ide> <ide> export const nodeProxy = ( ...val ) => new ShaderNodeProxy( ...val ); <ide> const bools = [ false, true ]; <ide> const uints = [ 0, 1, 2, 3 ]; <ide> const ints = [ -1, -2 ]; <del>const floats = [ 0.5, 1.5, 1 / 3, 1e-6, 1e6, Math.PI, Math.PI * 2, 1 / Math.PI, 2 / Math.PI, 1 / ( Math.PI * 2), Math.PI / 2 ]; <add>const floats = [ 0.5, 1.5, 1 / 3, 1e-6, 1e6, Math.PI, Math.PI * 2, 1 / Math.PI, 2 / Math.PI, 1 / ( Math.PI * 2 ), Math.PI / 2 ]; <ide> <ide> export const boolsCacheMap = new Map(); <ide> for ( let bool of bools ) boolsCacheMap.set( bool, new ConstNode( bool ) );
1
Ruby
Ruby
fix gap in line between reqs and deps
62d48b4f9d5d0b11db514e5b5245b9f4fb1d2f66
<ide><path>Library/Homebrew/cmd/deps.rb <ide> def puts_deps_tree(formulae) <ide> <ide> def recursive_deps_tree(f, prefix) <ide> reqs = f.requirements.select(&:default_formula?) <add> deps = f.deps.default <ide> max = reqs.length - 1 <ide> reqs.each_with_index do |req, i| <del> chr = i == max ? "โ””โ”€โ”€" : "โ”œโ”€โ”€" <add> chr = if i == max && deps.empty? <add> "โ””โ”€โ”€" <add> else <add> "โ”œโ”€โ”€" <add> end <ide> puts prefix + "#{chr} :#{dep_display_name(req.to_dependency)}" <ide> end <del> deps = f.deps.default <ide> max = deps.length - 1 <ide> deps.each_with_index do |dep, i| <del> chr = i == max ? "โ””โ”€โ”€" : "โ”œโ”€โ”€" <add> chr = if i == max <add> "โ””โ”€โ”€" <add> else <add> "โ”œโ”€โ”€" <add> end <ide> prefix_ext = i == max ? " " : "โ”‚ " <ide> puts prefix + "#{chr} #{dep_display_name(dep)}" <ide> recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_ext)
1
Javascript
Javascript
use radix in parseint function calls
0b19fd525173827fe62a88880f3fe072d3c7a0fa
<ide><path>fonts.js <ide> var Type1Parser = function() { <ide> i += length; <ide> token = ''; <ide> } else if (isSeparator(c)) { <del> length = parseInt(token); <add> length = parseInt(token, 10); <ide> token = ''; <ide> } else { <ide> token += c; <ide> var Type1Parser = function() { <ide> break; <ide> case '/Subrs': <ide> ++i; <del> var num = parseInt(getToken()); <add> var num = parseInt(getToken(), 10); <ide> getToken(); // read in 'array' <ide> for (var j = 0; j < num; ++j) { <ide> var t = getToken(); // read in 'dup' <ide> if (t == 'ND' || t == '|-' || t == 'noaccess') <ide> break; <del> var index = parseInt(getToken()); <add> var index = parseInt(getToken(), 10); <ide> if (index > j) <ide> j = index; <del> var length = parseInt(getToken()); <add> var length = parseInt(getToken(), 10); <ide> getToken(); // read in 'RD' <ide> var data = eexec.slice(i + 1, i + 1 + length); <ide> var lenIV = program.properties.private['lenIV']; <ide> var Type1Parser = function() { <ide> properties.textMatrix = matrix; <ide> break; <ide> case '/Encoding': <del> var size = parseInt(getToken()); <add> var size = parseInt(getToken(), 10); <ide> getToken(); // read in 'array' <ide> <ide> for (var j = 0; j < size; j++) { <ide> var token = getToken(); <ide> if (token == 'dup') { <del> var index = parseInt(getToken()); <add> var index = parseInt(getToken(), 10); <ide> var glyph = getToken(); <ide> <ide> if ('undefined' == typeof(properties.differences[index])) {
1
Python
Python
fix mypy neo4j and influxdb
36aa695ea817ea6f7e446558ef108d2c450ebb0c
<ide><path>airflow/providers/influxdb/hooks/influxdb.py <ide> <ide> """This module allows to connect to a InfluxDB database.""" <ide> <del>from typing import List <add>from typing import Dict, List <ide> <ide> import pandas as pd <ide> from influxdb_client import InfluxDBClient <ide> def __init__(self, conn_id: str = default_conn_name, *args, **kwargs) -> None: <ide> self.influxdb_conn_id = conn_id <ide> self.connection = kwargs.pop("connection", None) <ide> self.client = None <del> self.extras = None <add> self.extras: Dict = {} <ide> self.uri = None <ide> self.org_name = None <ide> <ide><path>airflow/providers/neo4j/hooks/neo4j.py <ide> def __init__(self, conn_id: str = default_conn_name, *args, **kwargs) -> None: <ide> self.neo4j_conn_id = conn_id <ide> self.connection = kwargs.pop("connection", None) <ide> self.client = None <del> self.extras = None <del> self.uri = None <ide> <ide> def get_conn(self) -> Neo4jDriver: <ide> """ <ide> def get_conn(self) -> Neo4jDriver: <ide> return self.client <ide> <ide> self.connection = self.get_connection(self.neo4j_conn_id) <del> self.extras = self.connection.extra_dejson.copy() <ide> <del> self.uri = self.get_uri(self.connection) <del> self.log.info('URI: %s', self.uri) <add> uri = self.get_uri(self.connection) <add> self.log.info('URI: %s', uri) <ide> <ide> is_encrypted = self.connection.extra_dejson.get('encrypted', False) <ide> <ide> self.client = GraphDatabase.driver( <del> self.uri, auth=(self.connection.login, self.connection.password), encrypted=is_encrypted <add> uri, auth=(self.connection.login, self.connection.password), encrypted=is_encrypted <ide> ) <ide> <ide> return self.client <ide><path>airflow/providers/neo4j/operators/neo4j.py <ide> def __init__( <ide> self.neo4j_conn_id = neo4j_conn_id <ide> self.sql = sql <ide> self.parameters = parameters <del> self.hook = None <del> <del> def get_hook(self): <del> """Function to retrieve the Neo4j Hook.""" <del> return Neo4jHook(conn_id=self.neo4j_conn_id) <ide> <ide> def execute(self, context: Dict) -> None: <ide> self.log.info('Executing: %s', self.sql) <del> self.hook = self.get_hook() <del> self.hook.run(self.sql) <add> hook = Neo4jHook(conn_id=self.neo4j_conn_id) <add> hook.run(self.sql)
3
Text
Text
fix typo in openssl upgrading doc
b22a189b430e87d225279b43148b11f68fca8f49
<ide><path>deps/openssl/doc/UPGRADING.md <ide> Since perl is not a build requirement in node, they all should be <ide> generated in advance and statically stored in the repository. We <ide> provide two sets of asm files, one is asm_latest(avx2 and addx <ide> supported) in `deps/openssl/asm` and the other asm_obsolete(without <del>avx1/2 and addx) in `deps/openssl/asm_obsolute`, which depends on <add>avx1/2 and addx) in `deps/openssl/asm_obsolete`, which depends on <ide> supported features in assemblers. Each directory has a `Makefile` <ide> to generate asm files with perl scripts in openssl sources. <ide>
1
Text
Text
add object_detection to the main readme
0f1bd993f1be399ce9fb849580ade94d56943c6d
<ide><path>README.md <ide> running TensorFlow 0.12 or earlier, please <ide> - [neural_gpu](neural_gpu): highly parallel neural computer. <ide> - [neural_programmer](neural_programmer): neural network augmented with logic and mathematic operations. <ide> - [next_frame_prediction](next_frame_prediction): probabilistic future frame synthesis via cross convolutional networks. <add>- [object_detection](object_detection): localizing and identifying multiple objects in a single image. <ide> - [real_nvp](real_nvp): density estimation using real-valued non-volume preserving (real NVP) transformations. <ide> - [resnet](resnet): deep and wide residual networks. <ide> - [skip_thoughts](skip_thoughts): recurrent neural network sentence-to-vector encoder.
1
Javascript
Javascript
fix deprecation warning on moment().locale()
677db209498780f5c0eeec5de71569d28f1d48cd
<ide><path>moment.js <ide> }, <ide> <ide> lang : deprecate( <del> "moment().lang is deprecated. Use moment().locale instead.", <add> "moment().lang() is deprecated. Use moment().localeData() instead.", <ide> function (key) { <ide> return this.localeData(key); <ide> }
1
PHP
PHP
fix undeclared property
4ce55910cf590de5e87d7d347e262d1f399fe4a5
<ide><path>src/Routing/Middleware/RoutingMiddleware.php <ide> */ <ide> class RoutingMiddleware <ide> { <add> /** <add> * The application that will have its routing hook invoked. <add> * <add> * @var \Cake\Http\BaseApplication <add> */ <add> protected $app; <add> <ide> /** <ide> * Constructor <ide> *
1
Text
Text
add docs to show how to select specific simulator
b0dbb4210fa2201b6977599c8aab58157101a7e1
<ide><path>docs/RunningOnDeviceIOS.md <ide> title: Running On Device <ide> layout: docs <ide> category: Guides (iOS) <ide> permalink: docs/running-on-device-ios.html <del>next: communication-ios <add>next: running-on-simulator-ios <ide> --- <ide> <ide> Note that running on device requires [Apple Developer account](https://developer.apple.com/register) and provisioning your iPhone. This guide covers only React Native specific topic. <ide><path>docs/RunningOnSimulatorIOS.md <add>--- <add>id: running-on-simulator-ios <add>title: Running On Simulator <add>layout: docs <add>category: Guides (iOS) <add>permalink: docs/running-on-simulator-ios.html <add>next: communication-ios <add>--- <add> <add>## Starting the simulator <add> <add>Once you have your React Native project initialized, you can run `react-native run-ios` inside the newly created project directory. If everything is set up correctly, you should see your new app running in the iOS Simulator shortly. <add> <add>## Specifying a device <add> <add>You can specify the device the simulator should run with the `--simulator` flag, followed by the device name as a string. The default is `"iPhone 6"`. If you wish to run your app on an iPhone 4s, just run `react-native run-ios --simulator "iPhone 4s"`. <add> <add>The device names correspond to the list of devices available in Xcode. You can check your available devices by running `xcrun simctl list devices` from the console.
2
Text
Text
clarify manual merging of pr in release doc
bfe51ea64a6957587c33baf32916b205dea91a45
<ide><path>dev/README_RELEASE_AIRFLOW.md <ide> The Release Candidate artifacts we vote upon should be the exact ones we vote ag <ide> <ide> - Update the `REVISION_HEADS_MAP` at airflow/utils/db.py to include the revision head of the release even if there are no migrations. <ide> - Commit the version change. <del>- PR from the 'test' branch to the 'stable' branch, and manually merge it once approved. <add>- PR from the 'test' branch to the 'stable' branch, and manually merge it once approved. Here's how to manually merge the PR: <add> <add> ```shell script <add> git merge --ff-only v${VERSION_BRANCH}-test <add> ``` <add> <ide> - Check out the 'stable' branch <ide> <ide> ```shell script
1
Javascript
Javascript
change api to clearatomproject
89fbf1e25b344152e674eadd2ddde5cdabb2a011
<ide><path>src/project.js <ide> class Project extends Model { <ide> this.projectFilePath = newSettings.originPath <ide> } <ide> <del> clearProjectSettings () { <add> clearAtomProject () { <ide> atom.config.clearProjectSettings() <ide> } <ide>
1
Python
Python
remove metrics hack for dist strat
6cfa81a1ff52d5804ba9df6a766991dbb53eeb3c
<ide><path>official/transformer/v2/metrics.py <ide> def get_config(self): <ide> <ide> def call(self, inputs): <ide> logits, targets = inputs[0], inputs[1] <del> # TODO(guptapriya): Remove this check when underlying issue to create <del> # metrics with dist strat in cross replica context is fixed. <del> if (tf.distribute.has_strategy() and <del> not tf.distribute.in_cross_replica_context()): <del> for mean, fn in self.metric_mean_fns: <del> m = mean(*fn(logits, targets)) <del> self.add_metric(m) <add> for mean, fn in self.metric_mean_fns: <add> m = mean(*fn(logits, targets)) <add> self.add_metric(m) <ide> return logits <ide> <ide>
1
PHP
PHP
fix phpcs and php5.3 error
b55a88508f52c5449ddf57a5019c70fac2348a4d
<ide><path>lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php <ide> * Secondary Post stub class. <ide> */ <ide> class SecondaryPost extends Model { <add> <ide> /** <ide> * @var string <ide> */ <ide> class SecondaryPost extends Model { <ide> * @var string <ide> */ <ide> public $useDbConfig = 'secondary'; <add> <ide> } <ide> <ide> /** <ide> public function testGetMockForModelSecondaryDatasource() { <ide> ) <ide> ), App::RESET); <ide> CakePlugin::load('TestPlugin'); <del> ConnectionManager::create('test_secondary', [ <add> ConnectionManager::create('test_secondary', array( <ide> 'datasource' => 'Database/TestLocalDriver' <del> ]); <add> )); <ide> $post = $this->getMockForModel('SecondaryPost', array('save')); <ide> $this->assertEquals('test_secondary', $post->useDbConfig); <ide> ConnectionManager::drop('test_secondary');
1
PHP
PHP
remove unused variable $declaringclass
e5853da9a0484d54aa28a9a2e4ed774bb4f954a4
<ide><path>src/Illuminate/Container/Container.php <ide> protected function getDependencies(array $parameters, array $primitives = []) <ide> */ <ide> protected function resolveNonClass(ReflectionParameter $parameter) <ide> { <del> $declaringClass = $parameter->getDeclaringClass(); <del> <ide> if (! is_null($concrete = $this->getContextualConcrete('$'.$parameter->name))) { <ide> if ($concrete instanceof Closure) { <ide> return call_user_func($concrete, $this);
1
PHP
PHP
fix duplicate items in habtm associations
89b9bb72972365a817530ad68fbf60be9765acd8
<ide><path>lib/Cake/Model/Datasource/DboSource.php <ide> protected function _mergeAssociation(&$data, &$merge, $association, $type, $self <ide> } <ide> } else { <ide> foreach ($merge as $i => $row) { <add> $insert = array(); <ide> if (count($row) === 1) { <del> if (empty($data[$association]) || (isset($data[$association]) && !in_array($row[$association], $data[$association]))) { <del> $data[$association][] = $row[$association]; <del> } <del> } elseif (!empty($row)) { <del> $tmp = array_merge($row[$association], $row); <del> unset($tmp[$association]); <del> $data[$association][] = $tmp; <add> $insert = $row[$association]; <add> } elseif (isset($row[$association])) { <add> $insert = array_merge($row[$association], $row); <add> unset($insert[$association]); <add> } <add> <add> if (empty($data[$association]) || (isset($data[$association]) && !in_array($insert, $data[$association], true))) { <add> $data[$association][] = $insert; <ide> } <ide> } <ide> }
1
Python
Python
make test(all=true) the default
ceb9ec29824966383c20364697a330577bd159d5
<ide><path>numpy/testing/numpytest.py <ide> def _test_suite_from_all_tests(self, this_package, level, verbosity): <ide> all_tests = unittest.TestSuite(suite_list) <ide> return all_tests <ide> <del> def test(self, level=1, verbosity=1, all=False, sys_argv=[], <add> def test(self, level=1, verbosity=1, all=True, sys_argv=[], <ide> testcase_pattern='.*'): <ide> """Run Numpy module test suite with level and verbosity. <ide>
1
PHP
PHP
add a basic application contract
c79c1ed4ff05f30e6e882473c8dc11f99422a4a4
<ide><path>src/Illuminate/Contracts/Foundation/Application.php <add><?php namespace Illuminate\Contracts\Foundation; <add> <add>interface Application { <add> <add> /** <add> * Register a service provider with the application. <add> * <add> * @param \Illuminate\Support\ServiceProvider|string $provider <add> * @param array $options <add> * @param bool $force <add> * @return \Illuminate\Support\ServiceProvider <add> */ <add> public function register($provider, $options = array(), $force = false); <add> <add> /** <add> * Register a deferred provider and service. <add> * <add> * @param string $provider <add> * @param string $service <add> * @return void <add> */ <add> public function registerDeferredProvider($provider, $service = null); <add> <add> /** <add> * Boot the application's service providers. <add> * <add> * @return void <add> */ <add> public function boot(); <add> <add> /** <add> * Register a new boot listener. <add> * <add> * @param mixed $callback <add> * @return void <add> */ <add> public function booting($callback); <add> <add> /** <add> * Register a new "booted" listener. <add> * <add> * @param mixed $callback <add> * @return void <add> */ <add> public function booted($callback); <add> <add>} <ide><path>src/Illuminate/Foundation/Application.php <ide> use Symfony\Component\HttpFoundation\Request as SymfonyRequest; <ide> use Symfony\Component\HttpFoundation\Response as SymfonyResponse; <ide> use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; <add>use Illuminate\Contracts\Foundation\Application as ApplicationContract; <ide> <del>class Application extends Container implements HttpKernelInterface, TerminableInterface, ResponsePreparerInterface { <add>class Application extends Container implements HttpKernelInterface, <add> TerminableInterface, <add> ApplicationContract, <add> ResponsePreparerInterface { <ide> <ide> /** <ide> * The Laravel framework version.
2
Javascript
Javascript
replace concatenation with string templates
27b5bf14ca8958d44d75030477b85a6bd34d6490
<ide><path>tools/lint-js.js <ide> if (cluster.isMaster) { <ide> } else { <ide> failures += results.length; <ide> } <del> outFn(formatter(results) + '\r\n'); <add> outFn(`${formatter(results)}\r\n`); <ide> printProgress(); <ide> } else { <ide> successes += results; <ide> if (cluster.isMaster) { <ide> return; <ide> <ide> // Clear line <del> outFn('\r' + ' '.repeat(lastLineLen) + '\r'); <add> outFn(`\r ${' '.repeat(lastLineLen)}\r`); <ide> <ide> // Calculate and format the data for displaying <ide> const elapsed = process.hrtime(startTime)[0]; <ide> if (cluster.isMaster) { <ide> <ide> // Truncate line like cpplint does in case it gets too long <ide> if (line.length > 75) <del> line = line.slice(0, 75) + '...'; <add> line = `${line.slice(0, 75)}...`; <ide> <ide> // Store the line length so we know how much to erase the next time around <ide> lastLineLen = line.length; <ide> if (cluster.isMaster) { <ide> } <ide> <ide> function padString(str, len, chr) { <del> str = '' + str; <add> str = `${str}`; <ide> if (str.length >= len) <ide> return str; <ide> return chr.repeat(len - str.length) + str;
1
Ruby
Ruby
remove redundant `squish` for single line message
12c2f44316848ac88f6b2b49edff96a83acf190c
<ide><path>activemodel/lib/active_model/attribute_set/builder.rb <ide> def marshal_dump <ide> <ide> def marshal_load(values) <ide> if values.is_a?(Hash) <del> ActiveSupport::Deprecation.warn(<<~MSG.squish) <add> ActiveSupport::Deprecation.warn(<<~MSG) <ide> Marshalling load from legacy attributes format is deprecated and will be removed in Rails 6.2. <ide> MSG <ide> empty_hash = {}.freeze <ide><path>activerecord/lib/active_record/connection_adapters/abstract/quoting.rb <ide> def type_cast(value, column = nil) <ide> value = id_value_for_database(value) if value.is_a?(Base) <ide> <ide> if column <del> ActiveSupport::Deprecation.warn(<<~MSG.squish) <add> ActiveSupport::Deprecation.warn(<<~MSG) <ide> Passing a column to `type_cast` is deprecated and will be removed in Rails 6.2. <ide> MSG <ide> type = lookup_cast_type_from_column(column)
2
Text
Text
use consistent header style in tutorial part 5
ad9aa23198bf1008651a778dd3f633570d4ee2d3
<ide><path>docs/tutorial/5-relationships-and-hyperlinked-apis.md <del># Tutorial 5 - Relationships & Hyperlinked APIs <add># Tutorial 5: Relationships & Hyperlinked APIs <ide> <ide> At the moment relationships within our API are represented by using primary keys. In this part of the tutorial we'll improve the cohesion and discoverability of our API, by instead using hyperlinking for relationships. <ide>
1
Text
Text
fix typo error, link to field
0484d01aae4906b07ae7485e6fa173c71a8f1a1e
<ide><path>docs/api-guide/schemas.md <ide> that do not expect a request body. <ide> <ide> ### get_path_fields(self, path, method): <ide> <del>Return a list of `coreapi.Link()` instances. One for each path parameter in the URL. <add>Return a list of `coreapi.Field()` instances. One for each path parameter in the URL. <ide> <ide> ### get_serializer_fields(self, path, method) <ide> <del>Return a list of `coreapi.Link()` instances. One for each field in the serializer class used by the view. <add>Return a list of `coreapi.Field()` instances. One for each field in the serializer class used by the view. <ide> <ide> ### get_pagination_fields(self, path, method) <ide> <del>Return a list of `coreapi.Link()` instances, as returned by the `get_schema_fields()` method on any pagination class used by the view. <add>Return a list of `coreapi.Field()` instances, as returned by the `get_schema_fields()` method on any pagination class used by the view. <ide> <ide> ### get_filter_fields(self, path, method) <ide> <del>Return a list of `coreapi.Link()` instances, as returned by the `get_schema_fields()` method of any filter classes used by the view. <add>Return a list of `coreapi.Field()` instances, as returned by the `get_schema_fields()` method of any filter classes used by the view. <ide> <ide> ### get_manual_fields(self, path, method) <ide>
1
Text
Text
update korean translation to e928c65
dc56073d681af450236e14861bf96e57b532ed97
<ide><path>docs/docs/04-multiple-components.ko-KR.md <ide> var MyComponent = React.createClass({ <ide> ); <ide> } <ide> }); <del> <add>``` <add>```javascript <ide> // ๋งž์Œ :) <ide> var ListItemWrapper = React.createClass({ <ide> render: function() { <ide><path>docs/docs/07-forms.ko-KR.md <ide> HTML์—์„œ๋Š” `<textarea>` ํƒœ๊ทธ์˜ ๊ฐ’์„ ์„ค์ •ํ•  ๋•Œ `<textarea>` ํƒœ๊ทธ์˜ <ide> > <ide> > `<input>`, `<textarea>`์—์„œ๋Š” `onChange`๊ฐ€ DOM์˜ [`oninput`](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/oninput) ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ์™€ ๊ฐ™์€ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๋ฏ€๋กœ ์ผ๋ฐ˜์ ์ธ ๊ฒฝ์šฐ์—๋Š” `onChange`๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”. <ide> <add><a name="controlled-components"></a> <ide> ## ์ œ์–ด๋˜๋Š”(controlled) ์ปดํฌ๋„ŒํŠธ <ide> <ide> `value`๊ฐ€ ์„ค์ •๋œ `<input>`์€ *์ œ์–ด๋˜๋Š”* ์ปดํฌ๋„ŒํŠธ์ž…๋‹ˆ๋‹ค. ์ œ์–ด๋˜๋Š” `<input>`์—์„œ, ๋ Œ๋” ์—˜๋ฆฌ๋จผํŠธ์˜ ๊ฐ’์€ ํ•ญ์ƒ `value` prop์„ ๋ฐ˜์˜ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, <ide> HTML์—์„œ๋Š” `<textarea>` ํƒœ๊ทธ์˜ ๊ฐ’์„ ์„ค์ •ํ•  ๋•Œ `<textarea>` ํƒœ๊ทธ์˜ <ide> <ide> ์ด๊ฒƒ์€ ๋นˆ ๊ฐ’์œผ๋กœ ์‹œ์ž‘๋˜๋Š” input์„ ๋ Œ๋”ํ•ฉ๋‹ˆ๋‹ค. ์ž„์˜์˜ ์‚ฌ์šฉ์ž ์ž…๋ ฅ์€ ์ฆ‰์‹œ ๋ Œ๋”๋œ ์—˜๋ฆฌ๋จผํŠธ์— ๋ฐ˜์˜๋ฉ๋‹ˆ๋‹ค. ๊ฐ’์˜ ์—…๋ฐ์ดํŠธ๋ฅผ ๊ฐ์‹œํ•˜๊ธธ ์›ํ•œ๋‹ค๋ฉด, ์ œ์–ด๋˜๋Š” ์ปดํฌ๋„ŒํŠธ์ฒ˜๋Ÿผ `onChange` ์ด๋ฒคํŠธ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. <ide> <add>### ๊ธฐ๋ณธ ๊ฐ’ <add> <ide> ๋น„์–ด ์žˆ์ง€ ์•Š์€ ๊ฐ’์œผ๋กœ ์ดˆ๊ธฐํ™”ํ•˜๊ธธ ์›ํ•œ๋‹ค๋ฉด, `defaultValue` prop๋กœ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, <ide> <ide> ```javascript <ide> HTML์—์„œ๋Š” `<textarea>` ํƒœ๊ทธ์˜ ๊ฐ’์„ ์„ค์ •ํ•  ๋•Œ `<textarea>` ํƒœ๊ทธ์˜ <ide> <ide> ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ, `<input>`์€ `defaultChecked`๋ฅผ ์ง€์›ํ•˜๊ณ  `<select>`๋Š” `defaultValue`๋ฅผ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. <ide> <add>> ์ฃผ์˜: <add>> <add>> `defaultValue`, `defaultChecked` prop์€ ์ตœ์ดˆ ๋ Œ๋”์—์„œ๋งŒ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ๋’ค์— ์ผ์–ด๋‚˜๋Š” ๋ Œ๋”์—์„œ ๊ฐ’์„ ์—…๋ฐ์ดํŠธํ•  ํ•„์š”๊ฐ€ ์žˆ๋‹ค๋ฉด, [์ œ์–ด๋˜๋Š”(controlled) ์ปดํฌ๋„ŒํŠธ](#controlled-components)๋ฅผ ์‚ฌ์šฉํ•˜์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค. <add> <ide> <ide> ## ์‹ฌํ™” ์ฃผ์ œ <ide> <ide> React์—์„œ `<input>`๊ฐ™์€ ํผ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด, ์ „ํ†ต์ ์ธ ํผ H <ide> <input type="text" name="title" value="Untitled" /> <ide> ``` <ide> <del>์ด๋ ‡๊ฒŒ ํ•˜๋ฉด input์€ `Untitled` ๊ฐ’์œผ๋กœ *์ดˆ๊ธฐํ™”* ๋ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ input์„ ์—…๋ฐ์ดํŠธํ•  ๋•Œ, ๋…ธ๋“œ์˜ value *ํ”„๋กœํผํ‹ฐ*๊ฐ€ ๋ณ€๊ฒฝ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ, `node.getAttribute('value')`์€ ์—ฌ์ „ํžˆ ์ดˆ๊ธฐํ™” ๋•Œ ์‚ฌ์šฉํ–ˆ๋˜ ๊ฐ’์ธ `Untitled`๋ฅผ ๋ฆฌํ„ดํ•ฉ๋‹ˆ๋‹ค. <add>์ด๋ ‡๊ฒŒ ํ•˜๋ฉด input์€ `Untitled` ๊ฐ’์œผ๋กœ *์ดˆ๊ธฐํ™”* ๋ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ input์„ ์—…๋ฐ์ดํŠธํ•  ๋•Œ, ๋…ธ๋“œ์˜ `value` *ํ”„๋กœํผํ‹ฐ*๊ฐ€ ๋ณ€๊ฒฝ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ, `node.getAttribute('value')`์€ ์—ฌ์ „ํžˆ ์ดˆ๊ธฐํ™” ๋•Œ ์‚ฌ์šฉํ–ˆ๋˜ ๊ฐ’์ธ `Untitled`๋ฅผ ๋ฆฌํ„ดํ•ฉ๋‹ˆ๋‹ค. <ide> <ide> HTML๊ณผ ๋‹ค๋ฅด๊ฒŒ, React ์ปดํฌ๋„ŒํŠธ๋Š” ์ดˆ๊ธฐํ™” ์‹œ์  ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ, ์–ด๋–ค ์‹œ์ ์ด๋ผ๋„ ๋ฐ˜๋“œ์‹œ ๋ทฐ์˜ state๋ฅผ ๋‚˜ํƒ€๋‚ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด React์—์„œ <ide> <ide> HTML๊ณผ ๋‹ค๋ฅด๊ฒŒ, React ์ปดํฌ๋„ŒํŠธ๋Š” ์ดˆ๊ธฐํ™” ์‹œ์  ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ, ์–ด <ide> HTML์—์„œ, `<textarea>`์˜ ๊ฐ’์€ ๋ณดํ†ต ๊ทธ๊ฒƒ์˜ ์ž์‹๋“ค๋กœ ์„ค์ •๋ฉ๋‹ˆ๋‹ค. <ide> <ide> ```html <del> <!-- ๋ฐ˜๋ก€: ์ด๋ ‡๊ฒŒ ํ•˜์ง€ ๋งˆ์„ธ์š”! --> <add> <!-- ์•ˆํ‹ฐํŒจํ„ด: ์ด๋ ‡๊ฒŒ ํ•˜์ง€ ๋งˆ์„ธ์š”! --> <ide> <textarea name="description">์ด๊ฒƒ์€ ์„ค๋ช…์ž…๋‹ˆ๋‹ค.</textarea> <ide> ``` <ide> <ide><path>docs/docs/08-working-with-the-browser.ko-KR.md <ide> React๋Š” ์ด ํ”„๋กœ์„ธ์Šค์— ํ›…์„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋Š” ์ƒ๋ช…์ฃผ๊ธฐ ๋ฉ”์†Œ๋“œ <ide> ### Updating <ide> <ide> * `componentWillReceiveProps(object nextProps)`๋Š” ๋งˆ์šดํŠธ๋œ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์ƒˆ๋กœ์šด props์„ ๋ฐ›์„ ๋•Œ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค. ์ด ๋ฉ”์†Œ๋“œ๋Š” `this.props`์™€ `nextProps`์„ ๋น„๊ตํ•˜์—ฌ `this.setState()`๋ฅผ ์‚ฌ์šฉํ•ด ์ƒํƒœ ๋ณ€ํ™˜์„ ์ˆ˜ํ–‰ํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜์•ผ ํ•ฉ๋‹ˆ๋‹ค. <del>* `shouldComponentUpdate(object nextProps, object nextState): boolean`๋Š” ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์–ด๋–ค ๋ณ€๊ฒฝ์ด DOM์˜ ์—…๋ฐ์ดํŠธ๋ฅผ ๋ณด์ฆํ•˜๋Š”์ง€ ๊ฒฐ์ •ํ•ด์•ผ ํ•  ๋•Œ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค. ์ตœ์ ํ™”ํ•˜๋ ค๋ฉด, React๊ฐ€ ์—…๋ฐ์ดํŠธ๋ฅผ ๋ฌด์‹œํ•ด์•ผํ•  ๋•Œ `this.props`์™€ `nextProps`๋ฅผ, `this.state`์™€ `nextState`๋ฅผ ๋น„๊ตํ•ด false๋ฅผ ๋ฆฌํ„ดํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. <add>* `shouldComponentUpdate(object nextProps, object nextState): boolean`๋Š” ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์–ด๋–ค ๋ณ€๊ฒฝ์ด DOM์˜ ์—…๋ฐ์ดํŠธ๋ฅผ ๋ณด์ฆํ•˜๋Š”์ง€ ๊ฒฐ์ •ํ•ด์•ผ ํ•  ๋•Œ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค. ์ตœ์ ํ™”ํ•˜๋ ค๋ฉด, React๊ฐ€ ์—…๋ฐ์ดํŠธ๋ฅผ ๋ฌด์‹œํ•ด์•ผํ•  ๋•Œ `this.props`์™€ `nextProps`๋ฅผ, `this.state`์™€ `nextState`๋ฅผ ๋น„๊ตํ•ด `false`๋ฅผ ๋ฆฌํ„ดํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. <ide> * `componentWillUpdate(object nextProps, object nextState)`๋Š” ์—…๋ฐ์ดํŠธ๊ฐ€ ๋ฐœ์ƒํ•˜๊ธฐ ์ง์ „์— ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค. ์ด ์‹œ์ ์—๋Š” `this.setState()`๋ฅผ ํ˜ธ์ถœํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. <ide> * `componentDidUpdate(object prevProps, object prevState)`๋Š” ์—…๋ฐ์ดํŠธ๊ฐ€ ๋ฐœ์ƒํ•œ ํ›„ ์ฆ‰์‹œ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค. <ide> <ide><path>docs/docs/08.1-more-about-refs.ko-KR.md <ide> render ๋ฉ”์†Œ๋“œ๋ฅผ ํ†ตํ•ด UI ๊ตฌ์กฐ๋ฅผ ์–ป์€ ๋‹ค์Œ, ๋ฐ˜ํ™˜๋œ ์ปดํฌ๋„ŒํŠธ <ide> ์ด๋Š” `render()`์—์„œ ๋ฐ˜ํ™˜๋œ ๋ฌด์–ธ๊ฐ€๋ฅผ "๊ณ„์† ์œ ์ง€ํ•  ์ˆ˜" ์—†์œผ๋ฉฐ ์•„๋ฌด๋Ÿฐ ์˜๋ฏธ๋„ ์—†์„ ๊ฒƒ์ด๋ผ๋Š” ๋œป์ž…๋‹ˆ๋‹ค. <ide> <ide> ```javascript <del> // ๋ฐ˜๋ก€: ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์•ˆ๋ฉ๋‹ˆ๋‹ค! <add> // ์•ˆํ‹ฐํŒจํ„ด: ์ด๊ฒƒ์€ ๋™์ž‘ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. <ide> render: function() { <ide> var myInput = <input />; // ์—ฌ๊ธฐ์„œ ๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœํ•  ๊ฒ๋‹ˆ๋‹ค. <ide> this.rememberThisInput = myInput; // ์–ธ์  ๊ฐ€ ๋ฏธ๋ž˜์˜ ํŠน์ • ์‹œ์ ์— ์ž…๋ ฅํ•  ๊ฑฐ์—์š”! YAY! <ide> render ๋ฉ”์†Œ๋“œ๋ฅผ ํ†ตํ•ด UI ๊ตฌ์กฐ๋ฅผ ์–ป์€ ๋‹ค์Œ, ๋ฐ˜ํ™˜๋œ ์ปดํฌ๋„ŒํŠธ <ide> } <ide> ``` <ide> <del>์ด ๋ฐ˜๋ก€์—์„œ `<input />`์€ ๋‹จ์ง€ `<input />`์˜ *์„œ์ˆ *์ผ ๋ฟ์ž…๋‹ˆ๋‹ค. ์ด ์„œ์ˆ ์€ `<input />`์— ๋Œ€ํ•œ *์ง„์งœ* **์ง€์› ์ธ์Šคํ„ด์Šค(backing instance)**๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. <add>์ด ์˜ˆ์ œ์—์„œ `<input />`์€ ๋‹จ์ง€ `<input />`์˜ *์„œ์ˆ *์ผ ๋ฟ์ž…๋‹ˆ๋‹ค. ์ด ์„œ์ˆ ์€ `<input />`์— ๋Œ€ํ•œ *์ง„์งœ* **์ง€์› ์ธ์Šคํ„ด์Šค(backing instance)**๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. <ide> <ide> ์ž ๊ทธ๋Ÿผ ์–ด๋–ป๊ฒŒ *์ง„์งœ* input์˜ ์ง€์› ์ธ์Šคํ„ด์Šค๋ฅผ ๋‹ค๋ฃฐ๊นŒ์š”? <ide> <ide> React๋Š” `render()`๋กœ ์ถœ๋ ฅ๋œ ์ปดํฌ๋„ŒํŠธ์— ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋Š” ์•„์ฃผ ํŠน <ide> }); <ide> ``` <ide> <del>์ด ์˜ˆ์ œ์—์„œ render ํ•จ์ˆ˜๋Š” `<input />` ์ธ์Šคํ„ด์Šค์˜ ์„œ์ˆ ์„ ๋ฐ˜ํ™˜ํ–ˆ์ง€๋งŒ, ์ง„์งœ ์ธ์Šคํ„ด์Šค๋Š” `this.refs.theInput`์„ ํ†ตํ•ด ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. render์—์„œ `ref="theInput"`์„ ๊ฐ€์ง„ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋ฐ˜ํ™˜๋œ ๋™์•ˆ, `this.refs.theInput`์€ ์ ์ ˆํ•œ ์ธ์Šคํ„ด์Šค์— ์ ‘๊ทผํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” `<Typeahead ref="myTypeahead" />`์ฒ˜๋Ÿผ DOM์ด ์•„๋‹Œ ๊ณ ์ˆ˜์ค€์˜ ์ปดํฌ๋„ŒํŠธ์—์„œ๋„ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค. <add>์ด ์˜ˆ์ œ์—์„œ render ํ•จ์ˆ˜๋Š” `<input />` ์ธ์Šคํ„ด์Šค์˜ ์„œ์ˆ ์„ ๋ฐ˜ํ™˜ํ–ˆ์ง€๋งŒ, ์ง„์งœ ์ธ์Šคํ„ด์Šค๋Š” `this.refs.theInput`์„ ํ†ตํ•ด ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. `render`์—์„œ `ref="theInput"`์„ ๊ฐ€์ง„ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋ฐ˜ํ™˜๋œ ๋™์•ˆ, `this.refs.theInput`์€ ์ ์ ˆํ•œ ์ธ์Šคํ„ด์Šค์— ์ ‘๊ทผํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” `<Typeahead ref="myTypeahead" />`์ฒ˜๋Ÿผ DOM์ด ์•„๋‹Œ ๊ณ ์ˆ˜์ค€์˜ ์ปดํฌ๋„ŒํŠธ์—์„œ๋„ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค. <ide> <ide> <ide> ## ์š”์•ฝ <ide><path>docs/docs/10.1-animation.ko-KR.md <ide> var TodoList = React.createClass({ <ide> ```css <ide> .example-enter { <ide> opacity: 0.01; <del> transition: opacity .5s ease-in; <ide> } <ide> <ide> .example-enter.example-enter-active { <ide> opacity: 1; <add> transition: opacity .5s ease-in; <ide> } <ide> ``` <ide> <ide> var TodoList = React.createClass({ <ide> ```css <ide> .example-leave { <ide> opacity: 1; <del> transition: opacity .5s ease-in; <ide> } <ide> <ide> .example-leave.example-leave-active { <ide> opacity: 0.01; <add> transition: opacity .5s ease-in; <ide> } <ide> ``` <ide> <ide><path>docs/docs/10.2-form-input-binding-sugar.ko-KR.md <ide> React์—์„œ ์ด๋Š” "change" ์ด๋ฒคํŠธ๋ฅผ ๊ฐ์‹œํ•˜๊ณ  ๋ฐ์ดํ„ฐ ์†Œ์Šค(๋ณดํ†ต DO <ide> <ide> > ์ฃผ์˜: <ide> > <del>> ReactLink๋Š” ์–‡์€ ๋ ˆํผ๊ณ  `onChange`/`setState()`ํŒจํ„ด ๋ถ€๋ถ„์˜ ๊ด€๋ก€์ผ ๋ฟ์ž…๋‹ˆ๋‹ค. React ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ์˜ ๋ฐ์ดํ„ฐ ํ๋ฆ„์„ ๊ทผ๋ณธ์ ์œผ๋กœ ๋ฐ”๊พธ์ง€๋Š” ์•Š์Šต๋‹ˆ๋‹ค. <add>> `ReactLink`๋Š” ์–‡์€ ๋ ˆํผ๊ณ  `onChange`/`setState()`ํŒจํ„ด ๋ถ€๋ถ„์˜ ๊ด€๋ก€์ผ ๋ฟ์ž…๋‹ˆ๋‹ค. React ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ์˜ ๋ฐ์ดํ„ฐ ํ๋ฆ„์„ ๊ทผ๋ณธ์ ์œผ๋กœ ๋ฐ”๊พธ์ง€๋Š” ์•Š์Šต๋‹ˆ๋‹ค. <ide> <ide> ## ReactLink: ์ ์šฉ ์ „ํ›„ <ide> <ide><path>docs/docs/11-advanced-performance.ko-KR.md <ide> React.createClass({ <ide> <ide> ## ๊ตฌ์›์ž Immutable-js <ide> <del>[Immutable-js](https://github.com/facebook/immutable-js)๋Š” Lee Byron์ด ๋งŒ๋“ค๊ณ  Facebook์ด ์˜คํ”ˆ์†Œ์Šคํ™” ํ•œ Javascript ์ปฌ๋ ‰์…˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค. ์ด๋Š” *๊ตฌ์กฐ์˜ ๊ณต์œ (structural sharing)*๋ฅผ ํ†ตํ•ด *๋ถˆ๋ณ€์˜ ์˜์†์ ์ธ(immutable persistent)* ์ปฌ๋ ‰์…˜์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์†์„ฑ์ด ๋ฌด์—‡์„ ์˜๋ฏธํ•˜๋Š”์ง€ ์‚ดํŽด๋ณด์ฃ : <add>[Immutable-js](https://github.com/facebook/immutable-js)๋Š” Lee Byron์ด ๋งŒ๋“ค๊ณ  Facebook์ด ์˜คํ”ˆ์†Œ์Šคํ™” ํ•œ JavaScript ์ปฌ๋ ‰์…˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค. ์ด๋Š” *๊ตฌ์กฐ์˜ ๊ณต์œ (structural sharing)*๋ฅผ ํ†ตํ•ด *๋ถˆ๋ณ€์˜ ์˜์†์ ์ธ(immutable persistent)* ์ปฌ๋ ‰์…˜์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์†์„ฑ์ด ๋ฌด์—‡์„ ์˜๋ฏธํ•˜๋Š”์ง€ ์‚ดํŽด๋ณด์ฃ : <ide> <ide> * *๋ถˆ๋ณ€์„ฑ(Immutable)*: ์ปฌ๋ ‰์…˜์ด ํ•œ๋ฒˆ ์ƒ์„ฑ๋˜๋ฉด, ์ด ํ›„ ๋‹ค๋ฅธ ์‹œ์ ์— ๋ณ€๊ฒฝ๋  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. <ide> * *์˜์†์„ฑ(Persistent)*: ์ƒˆ๋กœ์šด ์ปฌ๋ ‰์…˜์ด ์ด์ „์˜ ์ปฌ๋ ‰์…˜์ด๋‚˜ ์…‹(set) ๊ฐ™์€ ๋ฎคํ…Œ์ด์…˜(mutation)์—์„œ ์ƒ์„ฑ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ธฐ์กด์˜ ์ปฌ๋ ‰์…˜์€ ์ƒˆ๋กœ์šด ์ปฌ๋ ‰์…˜์ด ์ƒ์„ฑ๋œ ํ›„์—๋„ ์—ฌ์ „ํžˆ ์œ ํšจํ•ฉ๋‹ˆ๋‹ค. <ide> * *๊ตฌ์กฐ์˜ ๊ณต์œ (Structural Sharing)*: ์ƒˆ๋กœ์šด ์ปฌ๋ ‰์…˜์€ ๊ฐ€๋Šฅํ•œ ํ•œ ์›๋ž˜์˜ ์ปฌ๋ ‰์…˜๊ณผ ๊ฐ™์€ ๊ตฌ์กฐ๋ฅผ ์‚ฌ์šฉํ•ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค. ๊ณต๊ฐ„ ํšจ์œจ์„ฑ๊ณผ ์ ์ ˆํ•œ ์„ฑ๋Šฅ์„ ์œ„ํ•ด ๋ณต์‚ฌ๋ฅผ ์ตœ์†Œํ™”ํ•ฉ๋‹ˆ๋‹ค. <ide> <del>๋ถˆ๋ณ€์„ฑ์€ ๋ณ€๊ฒฝ์˜ ์ถ”์ ์„ ๋น„์šฉ์„ ์ค„์—ฌ์ค๋‹ˆ๋‹ค; ๋ณ€๊ฒฝ์€ ํ•ญ์ƒ ์ƒˆ๋กœ์šด ๊ฐ์ฒด์—๋งŒ ๋ฐœ์ƒํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ์ฒด์— ๋Œ€ํ•œ ์ฐธ์กฐ๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ๋งŒ ํ™•์ธํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์ผ๋ฐ˜์ ์ธ JavaScript ์ฝ”๋“œ์—์„œ๋Š”: <add>๋ถˆ๋ณ€์„ฑ์€ ๋ณ€๊ฒฝ์˜ ์ถ”์ ์„ ๋น„์šฉ์„ ์ค„์—ฌ์ค๋‹ˆ๋‹ค; ๋ณ€๊ฒฝ์€ ํ•ญ์ƒ ์ƒˆ๋กœ์šด ๊ฐ์ฒด์—๋งŒ ๋ฐœ์ƒํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ์ฒด์— ๋Œ€ํ•œ ์ฐธ์กฐ๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ๋งŒ ํ™•์ธํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์ผ๋ฐ˜์ ์ธ ์ด JavaScript ์ฝ”๋“œ์—์„œ๋Š”: <ide> <ide> ```javascript <ide> var x = { foo: "bar" }; <ide><path>docs/docs/getting-started.ko-KR.md <ide> React.render( <ide> <script type="text/jsx" src="src/helloworld.js"></script> <ide> ``` <ide> <add>ํฌ๋กฌ ๊ฐ™์€ ๋ช‡๋ช‡ ๋ธŒ๋ผ์šฐ์ €์—์„œ๋Š” HTTP์„ ํ†ตํ•ด ์ œ๊ณต๋˜๋Š” ํŒŒ์ผ์ด ์•„๋‹ˆ๋ฉด ๋กœ๋“œ์— ์‹คํŒจํ•˜๋ฏ€๋กœ ์ฃผ์˜ํ•˜์„ธ์š”. <add> <ide> ### ์˜คํ”„๋ผ์ธ ๋ณ€ํ™˜ <ide> <ide> ๋จผ์ € ์ปค๋งจ๋“œ๋ผ์ธ ๋„๊ตฌ๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค. ([npm](https://www.npmjs.com/) ํ•„์š”): <ide><path>docs/docs/ref-02-component-api.ko-KR.md <ide> replaceState(object nextState[, function callback]) <ide> forceUpdate([function callback]) <ide> ``` <ide> <del>`render()` ๋ฉ”์†Œ๋“œ๊ฐ€ `this.props`๋‚˜ `this.state`๊ฐ€ ์•„๋‹Œ ๋‹ค๋ฅธ ๊ณณ์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์–ด์˜ค๋Š” ๊ฒฝ์šฐ `forceUpdate()`๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ React๊ฐ€ `render()`๋ฅผ ๋‹ค์‹œ ์‹คํ–‰ํ•˜๋„๋ก ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. `this.state`๋ฅผ ์ง์ ‘ ๋ณ€๊ฒฝํ•˜๋Š” ๊ฒฝ์šฐ์—๋„ `forceUpdate()`๋ฅผ ํ˜ธ์ถœํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. <add>๊ธฐ๋ณธ์ ์œผ๋กœ, ์ปดํฌ๋„ŒํŠธ์˜ state๋‚˜ props๊ฐ€ ๋ณ€๊ฒฝ๋˜๋ฉด, ์ปดํฌ๋„ŒํŠธ๋Š” ๋‹ค์‹œ ๋ Œ๋”๋ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ด๋Ÿฐ ๋ณ€๊ฒฝ์ด ๋ฌต์‹œ์ ์ด๊ฑฐ๋‚˜(์˜ˆ๋ฅผ๋“ค์–ด ๊ฐ์ฒด์˜ ๋ณ€๊ฒฝ ์—†์ด ๊นŠ์ด ์žˆ๋Š” ๋ฐ์ดํ„ฐ๋งŒ ๋ณ€๊ฒฝ๋œ ๊ฒฝ์šฐ) `render()` ํ•จ์ˆ˜๊ฐ€ ๋‹ค๋ฅธ ๊ฐ’์— ์˜์กดํ•˜๋Š” ๊ฒฝ์šฐ, `forceUpdate()`๋ฅผ ํ˜ธ์ถœํ•ด React์—๊ฒŒ `render()`๋ฅผ ๋‹ค์‹œ ์‹คํ–‰ํ•  ํ•„์š”๊ฐ€ ์žˆ๋‹ค๊ณ  ์•Œ๋ฆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. <ide> <ide> `forceUpdate()`๋ฅผ ํ˜ธ์ถœํ•˜๋ฉด `shouldComponentUpdate()`๋ฅผ ์ƒ๋žตํ•˜๊ณ  ํ•ด๋‹น ์ปดํฌ๋„ŒํŠธ `render()` ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค. ๊ฐ ์ž์‹ ์ปดํฌ๋„ŒํŠธ์— ๋Œ€ํ•ด์„œ๋Š” `shouldComponentUpdate()`๋ฅผ ํฌํ•จํ•ด ๋ณดํ†ต ๋ผ์ดํ”„ ์‚ฌ์ดํด ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค. React๋Š” ๋งˆํฌ์—…์ด ๋ณ€๊ฒฝ๋œ ๊ฒฝ์šฐ์—๋งŒ DOM์„ ์—…๋ฐ์ดํŠธํ•ฉ๋‹ˆ๋‹ค. <ide> <del>ํŠน๋ณ„ํ•œ ๊ฒฝ์šฐ๊ฐ€ ์•„๋‹ˆ๋ฉด `forceUpdate()`๋Š” ๋˜๋„๋ก ํ”ผํ•˜์‹œ๊ณ  `render()`์—์„œ๋Š” `this.props`์™€ `this.state`์—์„œ๋งŒ ์ฝ์–ด์˜ค์„ธ์š”. ๊ทธ๋ ‡๊ฒŒ ํ•˜๋Š” ๊ฒƒ์ด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํ›จ์”ฌ ๋‹จ์ˆœํ•˜๊ณ  ํšจ์œจ์ ์œผ๋กœ ๋งŒ๋“ค์–ด์ค๋‹ˆ๋‹ค. <add>ํŠน๋ณ„ํ•œ ๊ฒฝ์šฐ๊ฐ€ ์•„๋‹ˆ๋ฉด `forceUpdate()`๋Š” ๋˜๋„๋ก ํ”ผํ•˜์‹œ๊ณ  `render()`์—์„œ๋Š” `this.props`์™€ `this.state`์—์„œ๋งŒ ์ฝ์–ด์˜ค์„ธ์š”. ๊ทธ๋ ‡๊ฒŒ ํ•˜๋Š” ๊ฒƒ์ด ์ปดํฌ๋„ŒํŠธ๋ฅผ "์ˆœ์ˆ˜"ํ•˜๊ฒŒ ํ•˜๊ณ  ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ํ›จ์”ฌ ๋‹จ์ˆœํ•˜๊ณ  ํšจ์œจ์ ์œผ๋กœ ๋งŒ๋“ค์–ด์ค๋‹ˆ๋‹ค. <ide> <ide> <ide> ### getDOMNode <ide> setProps(object nextProps[, function callback]) <ide> <ide> ์™ธ๋ถ€ JavaScript ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜๊ณผ ์—ฐ๋™ํ•˜๋Š” ๊ฒฝ์šฐ `React.render()`๋กœ ๋ Œ๋”๋ง๋œ React ์ปดํฌ๋„ŒํŠธ์— ๋ณ€๊ฒฝ์„ ์•Œ๋ฆฌ๊ณ  ์‹ถ์„ ๋•Œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. <ide> <del>์ตœ์ƒ์œ„ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์—…๋ฐ์ดํŠธํ•  ๋•Œ `React.render()`๋ฅผ ๊ฐ™์€ ๋…ธ๋“œ์— ๋‹ค์‹œ ํ˜ธ์ถœํ•˜๋Š” ๊ฒƒ์ด ๋ฐ”๋žŒ์งํ•œ ๋ฐฉ๋ฒ•์ด์ง€๋งŒ, `setProps()`๋ฅผ ํ˜ธ์ถœํ•ด์„œ props๋ฅผ ๋ฐ”๊พธ๊ณ  ์žฌ๋ Œ๋”๋ง์„ ๋ฐœ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฝœ๋ฐฑ ํ•จ์ˆ˜๋ฅผ ์ถ”๊ฐ€๋กœ ๋„˜๊ธฐ๋ฉด `setProps`๊ฐ€ ์™„๋ฃŒ๋˜๊ณ  ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋‹ค์‹œ ๋ Œ๋”๋ง๋œ ๋‹ค์Œ์— ํ•œ๋ฒˆ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค. <add>์ตœ์ƒ์œ„ ์ปดํฌ๋„ŒํŠธ์—์„œ `setProps()`๋ฅผ ํ˜ธ์ถœํ•˜๋ฉด ํ”„๋กœํผํ‹ฐ๋ฅผ ๋ณ€๊ฒฝํ•˜๊ณ  ๋ Œ๋”๋ฅผ ๋‹ค์‹œ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ๊ฑฐ๊ธฐ์— ์ฝœ๋ฐฑ ํ•จ์ˆ˜๋ฅผ ๋„˜๊ธฐ๋ฉด `setProps`๊ฐ€ ์™„๋ฃŒ๋˜๊ณ  ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋‹ค์‹œ ๋ Œ๋”๋ง๋œ ๋‹ค์Œ์— ํ•œ๋ฒˆ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค. <ide> <ide> > ์ฃผ์˜: <ide> > <del>> ๊ฐ€๋Šฅํ•˜๋‹ค๋ฉด `React.render()`๋ฅผ ๋‹ค์‹œ ํ˜ธ์ถœํ•˜๋Š” ์„ ์–ธ์ ์ธ ๋ฐฉ๋ฒ•์ด ๋” ๋ฐ”๋žŒ์งํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡๊ฒŒ ํ•˜๋Š” ํŽธ์ด ์—…๋ฐ์ดํŠธ์— ๋Œ€ํ•ด ์ƒ๊ฐํ•˜๋Š” ๊ฒƒ์„ ์‰ฝ๊ฒŒ ๋งŒ๋“ญ๋‹ˆ๋‹ค. (๋‘๊ฐ€์ง€ ๋ฐฉ์‹์— ๋ˆˆ์— ๋„๋Š” ์„ฑ๋Šฅ ์ฐจ์ด๋Š” ์—†์Šต๋‹ˆ๋‹ค.) <add>> ๊ฐ€๋Šฅํ•˜๋‹ค๋ฉด ์ด๊ฒƒ ๋Œ€์‹  `React.render()`๋ฅผ ๊ฐ™์€ ๋…ธ๋“œ์—์„œ ๋‹ค์‹œ ํ˜ธ์ถœํ•˜๋Š” ์„ ์–ธ์ ์ธ ๋ฐฉ๋ฒ•์ด ๋” ๋ฐ”๋žŒ์งํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡๊ฒŒ ํ•˜๋Š” ํŽธ์ด ์—…๋ฐ์ดํŠธ์— ๋Œ€ํ•ด ์ƒ๊ฐํ•˜๋Š” ๊ฒƒ์„ ์‰ฝ๊ฒŒ ๋งŒ๋“ญ๋‹ˆ๋‹ค. (๋‘๊ฐ€์ง€ ๋ฐฉ์‹์— ๋ˆˆ์— ๋„๋Š” ์„ฑ๋Šฅ ์ฐจ์ด๋Š” ์—†์Šต๋‹ˆ๋‹ค.) <ide> > <ide> > ์ด ๋ฉ”์†Œ๋“œ๋Š” ์ตœ์ƒ์œ„ ์ปดํฌ๋„ŒํŠธ์—๋งŒ ํ˜ธ์ถœ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์‹œ ๋งํ•ด, `React.render()`์— ๋ฐ”๋กœ ๋„˜๊ธด ์ปดํฌ๋„ŒํŠธ์—์„œ๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ณ  ์ž์‹์—์„œ๋Š” ๋ถˆ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ์ž์‹ ์ปดํฌ๋„ŒํŠธ์— `setProps()`๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, ๊ทธ ๋Œ€์‹  ๋ฐ˜์‘์ ์ธ ์—…๋ฐ์ดํŠธ์˜ ์žฅ์ ์„ ํ™œ์šฉํ•˜์—ฌ `render()` ์•ˆ์—์„œ ์ž์‹ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋งŒ๋“ค ๋•Œ ์ƒˆ๋กœ์šด prop์„ ๋„˜๊ธฐ์„ธ์š”. <ide> > <ide><path>docs/docs/tutorial.ko-KR.md <ide> next: thinking-in-react-ko-KR.html <ide> </html> <ide> ``` <ide> <del>๋‹ค์Œ ์ง„ํ–‰์„ ์œ„ํ•ด, ์œ„์˜ ์Šคํฌ๋ฆฝํŠธ ํƒœ๊ทธ์•ˆ์— JavaScript ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค. <add>๋‹ค์Œ ์ง„ํ–‰์„ ์œ„ํ•ด, ์œ„์˜ ์Šคํฌ๋ฆฝํŠธ ํƒœ๊ทธ์•ˆ์— JavaScript ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค. ๊ฐ ๋‹จ๊ณ„๋ฅผ ์ถ”๊ฐ€ํ•œ ๋‹ค์Œ index.html ํŒŒ์ผ์„ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์—ด์–ด์„œ ์ง„ํ–‰์„ ํ™•์ธํ•˜์„ธ์š”. <ide> <ide> > ์ฃผ์˜: <ide> > <ide> var CommentBox = React.createClass({ <ide> <ide> ### state ์—…๋ฐ์ดํŠธํ•˜๊ธฐ <ide> <del>์ปดํฌ๋„ŒํŠธ์˜ ์ตœ์ดˆ ์ƒ์„ฑ ์‹œ์—, ์„œ๋ฒ„์—์„œ GET ๋ฐฉ์‹์œผ๋กœ JSON์„ ๋„˜๊ฒจ๋ฐ›์•„ ์ตœ์‹ ์˜ ๋ฐ์ดํ„ฐ๊ฐ€ state์— ๋ฐ˜์˜๋˜๊ธธ ์›ํ–ˆ์Šต๋‹ˆ๋‹ค. ์‹ค์ œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„  ์ด๊ฒƒ์ด ๋™์ ์ธ ์—”๋“œํฌ์ธํŠธ์ด์ง€๋งŒ, ์ด ์˜ˆ์ œ์—์„œ๋Š” ์ •์  JSON ํŒŒ์ผ์„ ์‚ฌ์šฉํ•ด์„œ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋งŒ๋“ค์–ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. <add>์ปดํฌ๋„ŒํŠธ์˜ ์ตœ์ดˆ ์ƒ์„ฑ ์‹œ์—, ์„œ๋ฒ„์—์„œ GET ๋ฐฉ์‹์œผ๋กœ JSON์„ ๋„˜๊ฒจ๋ฐ›์•„ ์ตœ์‹ ์˜ ๋ฐ์ดํ„ฐ๊ฐ€ state์— ๋ฐ˜์˜๋˜๊ธธ ์›ํ–ˆ์Šต๋‹ˆ๋‹ค. ์‹ค์ œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„  ์ด๊ฒƒ์ด ๋™์ ์ธ ์—”๋“œํฌ์ธํŠธ์ด์ง€๋งŒ, ์ด ์˜ˆ์ œ์—์„œ๋Š” ๋‹จ์ˆœํžˆํ•˜๊ธฐ ์œ„ํ•ด comments์˜ ๋ฐฐ์—ด์ด ๋‹ด๊ธด ์ •์  JSON ํŒŒ์ผ `public/comments.json`์„ ์‚ฌ์šฉํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. <ide> <ide> ```javascript <ide> // tutorial13.json <ide><path>docs/tips/03-if-else-in-JSX.ko-KR.md <ide> React.createElement("div", {id: if (condition) { 'msg' }}, "Hello World!"); <ide> React.render(<div id={condition ? 'msg' : ''}>Hello World!</div>, mountNode); <ide> ``` <ide> <del>์‚ผํ•ญ ์—ฐ์‚ฐ์ž๊ฐ€ ์ถฉ๋ถ„ํ•˜์ง€ ์•Š๋‹ค๋ฉด `if` ๋ฌธ์„ ์‚ฌ์šฉํ•ด ์–ด๋–ค ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์‚ฌ์šฉ๋  ์ง€ ๊ฒฐ์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. <add>์‚ผํ•ญ ์—ฐ์‚ฐ์ž๊ฐ€ ์ถฉ๋ถ„ํ•˜์ง€ ์•Š๋‹ค๋ฉด JSX๊ตฌ๋ฌธ ๋ฐ–์—์„œ `if` ๋ฌธ์„ ์‚ฌ์šฉํ•ด ์–ด๋–ค ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์‚ฌ์šฉ๋  ์ง€ ๊ฒฐ์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. <ide> <ide> ```js <ide> var loginButton; <ide> return ( <ide> <Home /> <ide> {loginButton} <ide> </nav> <del>) <add>); <ide> ``` <ide> <add>"inline"์„ ์ข€๋” ์„ ํ˜ธํ•œ๋‹ค๋ฉด, JSX _์•ˆ์—_ [์ฆ‰์‹œ ํ‰๊ฐ€๋˜๋Š” ํ•จ์ˆ˜ ํ‘œํ˜„์‹](https://en.wikipedia.org/wiki/Immediately-invoked_function_expression)์„ ์„ ์–ธํ•˜์„ธ์š”. <add> <add>```js <add>return ( <add> <section> <add> <h1>Color</h1> <add> <h3>Name</h3> <add> <p>{this.state.color || "white"}</p> <add> <h3>Hex</h3> <add> <p> <add> {() => { <add> switch (this.state.color) { <add> case "red": return "#FF0000"; <add> case "green": return "#00FF00"; <add> case "blue": return "#0000FF"; <add> default: return "#FFFFFF"; <add> } <add> }()} <add> </p> <add> </section> <add>); <add>``` <add> <add>> ์ฃผ์˜: <add>> <add>> ์œ„์˜ ์˜ˆ์ œ์— ์žˆ๋Š” ES6 [ํ™”์‚ดํ‘œ ํ•จ์ˆ˜](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions)๋Š” `this`์˜ ๊ฐ’์„ ๊ตฌ๋ฌธ์ ์œผ๋กœ ๋ฐ”์ธ๋“œํ•˜๊ธฐ์œ„ํ•ด ์‚ฌ์šฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. <add> <ide> [JSX ์ปดํŒŒ์ผ๋Ÿฌ](/react/jsx-compiler.html)๋กœ ์ง€๊ธˆ ๋ฐ”๋กœ ์‚ฌ์šฉํ•ด๋ณด์„ธ์š”.
11
Text
Text
remove undefined reference variable
a84e10eba0f79608711285f673c4103940e00c2c
<ide><path>doc/api/http2.md <ide> const req = client.request({ <ide> ':authority': `localhost:${port}` <ide> }); <ide> <del>req.on('response', common.mustCall()); <add>req.on('response', (headers) => { <add> console.log(headers[http2.constants.HTTP2_HEADER_STATUS]); <add>}); <ide> let data = ''; <ide> req.setEncoding('utf8'); <ide> req.on('data', (chunk) => data += chunk);
1
PHP
PHP
fix issue with pusher channel
c51ef988d8c6d10d5613dc58f4fdd255edf70216
<ide><path>src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php <ide> <ide> use Illuminate\Broadcasting\BroadcastException; <ide> use Illuminate\Support\Arr; <add>use Illuminate\Support\Collection; <ide> use Pusher\ApiErrorException; <ide> use Pusher\Pusher; <ide> use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; <ide> public function broadcast(array $channels, $event, array $payload = []) <ide> <ide> $parameters = $socket !== null ? ['socket_id' => $socket] : []; <ide> <add> $channels = Collection::make($this->formatChannels($channels)); <add> <ide> try { <del> $this->pusher->trigger( <del> $this->formatChannels($channels), $event, $payload, $parameters <del> ); <add> $channels->chunk(100)->each(function ($channels) use ($event, $payload, $parameters) { <add> $this->pusher->trigger($channels, $event, $payload, $parameters); <add> }); <ide> } catch (ApiErrorException $e) { <ide> throw new BroadcastException( <ide> sprintf('Pusher error: %s.', $e->getMessage())
1
PHP
PHP
increase test coverage
d58bb116856319e123d82256b576095e42231a55
<ide><path>tests/TestCase/Validation/ValidatorTest.php <ide> public function testLengthBetween() <ide> $this->assertNotEmpty($validator->errors(['username' => 'foo'])); <ide> } <ide> <add> /** <add> * Tests the lengthBetween proxy method <add> * <add> * @expectedException InvalidArgumentException <add> * @return void <add> */ <add> public function testLengthBetweenFailure() <add> { <add> $validator = new Validator(); <add> $validator->lengthBetween('username', [7]); <add> } <add> <ide> /** <ide> * Tests the creditCard proxy method <ide> * <ide> public function testIps() <ide> $this->assertNotEmpty($validator->errors(['username' => 'not ip'])); <ide> } <ide> <add> /** <add> * Tests the minLength proxy method <add> * <add> * @return void <add> */ <add> public function testMinLength() <add> { <add> $validator = new Validator(); <add> $this->assertProxyMethod($validator, 'minLength', 2, [2]); <add> $this->assertNotEmpty($validator->errors(['username' => 'a'])); <add> } <add> <ide> /** <ide> * Tests the maxLength proxy method <ide> * <ide> public function testMaxLength() <ide> $this->assertNotEmpty($validator->errors(['username' => 'aaa'])); <ide> } <ide> <add> /** <add> * Tests the numeric proxy method <add> * <add> * @return void <add> */ <add> public function testNumeric() <add> { <add> $validator = new Validator(); <add> $this->assertProxyMethod($validator, 'numeric'); <add> $this->assertEmpty($validator->errors(['username' => '22'])); <add> $this->assertNotEmpty($validator->errors(['username' => 'a'])); <add> } <add> <ide> /** <ide> * Tests the naturalNumber proxy method <ide> * <ide> public function testRange() <ide> $this->assertNotEmpty($validator->errors(['username' => 5])); <ide> } <ide> <add> /** <add> * Tests the range failure case <add> * <add> * @expectedException InvalidArgumentException <add> * @return void <add> */ <add> public function testRangeFailure() <add> { <add> $validator = new Validator(); <add> $validator->range('username', [1]); <add> } <ide> /** <ide> * Tests the url proxy method <ide> * <ide> public function testUtf8Extended() <ide> $this->assertEmpty($validator->errors(['username' => $extended])); <ide> } <ide> <add> /** <add> * Tests the email proxy method <add> * <add> * @return void <add> */ <add> public function testEmail() <add> { <add> $validator = new Validator(); <add> $validator->email('username'); <add> $this->assertEmpty($validator->errors(['username' => '[email protected]'])); <add> $this->assertNotEmpty($validator->errors(['username' => 'not an email'])); <add> } <add> <ide> /** <ide> * Tests the integer proxy method <ide> * <ide> protected function assertProxyMethod($validator, $method, $extra = null, $pass = <ide> } <ide> <ide> $rule = $validator->field('username')->rule($method); <del> $this->assertNull($rule->get('message')); <del> $this->assertNull($rule->get('on')); <del> $this->assertEquals($name, $rule->get('rule')); <del> $this->assertEquals($pass, $rule->get('pass')); <del> $this->assertEquals('default', $rule->get('provider')); <add> $this->assertNull($rule->get('message'), 'Message is present when it should not be'); <add> $this->assertNull($rule->get('on'), 'On clause is present when it should not be'); <add> $this->assertEquals($name, $rule->get('rule'), 'Rule name does not match'); <add> $this->assertEquals($pass, $rule->get('pass'), 'Passed options are different'); <add> $this->assertEquals('default', $rule->get('provider'), 'Provider does not match'); <ide> <ide> if ($extra !== null) { <ide> $validator->{$method}('username', $extra, 'the message', 'create'); <ide> protected function assertProxyMethod($validator, $method, $extra = null, $pass = <ide> } <ide> <ide> $rule = $validator->field('username')->rule($method); <del> $this->assertEquals('the message', $rule->get('message')); <del> $this->assertEquals('create', $rule->get('on')); <add> $this->assertEquals('the message', $rule->get('message'), 'Error messages are not the same'); <add> $this->assertEquals('create', $rule->get('on'), 'On clause is wrong'); <ide> } <ide> }
1
Javascript
Javascript
remove unused `return` statement
73f3515ba79aace9332e140ff60615a425c5f4c4
<ide><path>src/ng/compile.js <ide> function $CompileProvider($provide, $$sanitizeUriProvider) { <ide> if (!letter || letter !== lowercase(letter)) { <ide> throw $compileMinErr('baddir', "Directive name '{0}' is invalid. The first character must be a lowercase letter", name); <ide> } <del> return name; <ide> } <ide> <ide> /**
1
PHP
PHP
add better bitwise operators support
a9c50095980e6f24ca23c811fa55752e0f50dd6c
<ide><path>src/Illuminate/Database/Query/Builder.php <ide> class Builder <ide> 'not similar to', 'not ilike', '~~*', '!~~*', <ide> ]; <ide> <add> /** <add> * All of the available binary operators. <add> * <add> * @var string[] <add> */ <add> public $binaryOperators = [ <add> '&', '|', '^', '<<', '>>', '&~', <add> ]; <add> <ide> /** <ide> * Whether to use write pdo for the select. <ide> * <ide> public function where($column, $operator = null, $value = null, $boolean = 'and' <ide> } <ide> } <ide> <add> if ($this->isBinaryOperator($operator)) { <add> $type = 'Binary'; <add> } <add> <ide> // Now that we are working with just a simple query we can put the elements <ide> // in our array and add the query binding to our array of bindings that <ide> // will be bound to each SQL statements when it is finally executed. <ide> protected function invalidOperator($operator) <ide> ! in_array(strtolower($operator), $this->grammar->getOperators(), true); <ide> } <ide> <add> protected function isBinaryOperator($operator) <add> { <add> return in_array(strtolower($operator), $this->binaryOperators, true) || <add> in_array(strtolower($operator), $this->grammar->getBinaryOperators(), true); <add> } <add> <ide> /** <ide> * Add an "or where" clause to the query. <ide> * <ide> public function having($column, $operator = null, $value = null, $boolean = 'and <ide> [$value, $operator] = [$operator, '=']; <ide> } <ide> <add> if ($this->isBinaryOperator($operator)) { <add> $type = 'binary'; <add> } <add> <ide> $this->havings[] = compact('type', 'column', 'operator', 'value', 'boolean'); <ide> <ide> if (! $value instanceof Expression) { <ide><path>src/Illuminate/Database/Query/Grammars/Grammar.php <ide> class Grammar extends BaseGrammar <ide> */ <ide> protected $operators = []; <ide> <add> /** <add> * The grammar specific binary operators. <add> * <add> * @var array <add> */ <add> protected $binaryOperators = []; <add> <ide> /** <ide> * The components that make up a select clause. <ide> * <ide> protected function whereBasic(Builder $query, $where) <ide> return $this->wrap($where['column']).' '.$operator.' '.$value; <ide> } <ide> <add> protected function whereBinary(Builder $query, $where) <add> { <add> $value = $this->parameter($where['value']); <add> <add> $operator = str_replace('?', '??', $where['operator']); <add> <add> return '('.$this->wrap($where['column']).' '.$operator.' '.$value.') != 0'; <add> } <add> <ide> /** <ide> * Compile a "where in" clause. <ide> * <ide> protected function whereJsonContains(Builder $query, $where) <ide> $not = $where['not'] ? 'not ' : ''; <ide> <ide> return $not.$this->compileJsonContains( <del> $where['column'], $this->parameter($where['value']) <add> $where['column'], <add> $this->parameter($where['value']) <ide> ); <ide> } <ide> <ide> public function prepareBindingForJsonContains($binding) <ide> protected function whereJsonLength(Builder $query, $where) <ide> { <ide> return $this->compileJsonLength( <del> $where['column'], $where['operator'], $this->parameter($where['value']) <add> $where['column'], <add> $where['operator'], <add> $this->parameter($where['value']) <ide> ); <ide> } <ide> <ide> protected function compileHaving(array $having) <ide> return $having['boolean'].' '.$having['sql']; <ide> } elseif ($having['type'] === 'between') { <ide> return $this->compileHavingBetween($having); <add> } elseif ($having['type'] === 'binary') { <add> return $this->compileHavingBinary($having); <ide> } <ide> <ide> return $this->compileBasicHaving($having); <ide> protected function compileHavingBetween($having) <ide> return $having['boolean'].' '.$column.' '.$between.' '.$min.' and '.$max; <ide> } <ide> <add> /** <add> * Compile a having clause involving a binary operator. <add> * <add> * @param array $having <add> * @return string <add> */ <add> protected function compileHavingBinary($having) <add> { <add> $column = $this->wrap($having['column']); <add> <add> $parameter = $this->parameter($having['value']); <add> <add> return $having['boolean'].' ('.$column.' '.$having['operator'].' '.$parameter.') != 0'; <add> } <add> <ide> /** <ide> * Compile the "order by" portions of the query. <ide> * <ide> public function getOperators() <ide> { <ide> return $this->operators; <ide> } <add> <add> /** <add> * Get the grammar specific binary operators. <add> * <add> * @return array <add> */ <add> public function getBinaryOperators() <add> { <add> return $this->binaryOperators; <add> } <ide> } <ide><path>src/Illuminate/Database/Query/Grammars/PostgresGrammar.php <ide> class PostgresGrammar extends Grammar <ide> 'is distinct from', 'is not distinct from', <ide> ]; <ide> <add> /** <add> * The grammar specific binary operators. <add> * <add> * @var array <add> */ <add> protected $binaryOperators = [ <add> '~', '&', '|', '#', '<<', '>>', '<<=', '>>=', <add> ]; <add> <ide> /** <ide> * {@inheritdoc} <ide> * <ide><path>tests/Database/DatabaseQueryBuilderTest.php <ide> public function testMySqlSoundsLikeOperator() <ide> $this->assertEquals(['John Doe'], $builder->getBindings()); <ide> } <ide> <add> public function testBinaryOperators() <add> { <add> $builder = $this->getBuilder(); <add> $builder->select('*')->from('users')->where('bar', '&', 1); <add> $this->assertSame('select * from "users" where ("bar" & ?) != 0', $builder->toSql()); <add> <add> $builder = $this->getPostgresBuilder(); <add> $builder->select('*')->from('users')->where('bar', '#', 1); <add> $this->assertSame('select * from "users" where ("bar" # ?) != 0', $builder->toSql()); <add> <add> $builder = $this->getBuilder(); <add> $builder->select('*')->from('users')->having('bar', '&', 1); <add> $this->assertSame('select * from "users" having ("bar" & ?) != 0', $builder->toSql()); <add> <add> $builder = $this->getPostgresBuilder(); <add> $builder->select('*')->from('users')->having('bar', '#', 1); <add> $this->assertSame('select * from "users" having ("bar" # ?) != 0', $builder->toSql()); <add> } <add> <ide> public function testMergeWheresCanMergeWheresAndBindings() <ide> { <ide> $builder = $this->getBuilder();
4
Ruby
Ruby
extract a relation#arel_attribute
5952861948a0918b1955202c1ea19589634537dc
<ide><path>activerecord/lib/active_record/core.rb <ide> def arel_engine # :nodoc: <ide> end <ide> end <ide> <del> def arel_attribute(name, table) # :nodoc: <add> def arel_attribute(name, table = arel_table) # :nodoc: <ide> name = attribute_alias(name) if attribute_alias?(name) <ide> table[name] <ide> end <ide><path>activerecord/lib/active_record/relation.rb <ide> def insert(values) # :nodoc: <ide> <ide> if !primary_key_value && connection.prefetch_primary_key?(klass.table_name) <ide> primary_key_value = connection.next_sequence_value(klass.sequence_name) <del> values[klass.arel_attribute(klass.primary_key, table)] = primary_key_value <add> values[arel_attribute(klass.primary_key)] = primary_key_value <ide> end <ide> end <ide> <ide> def substitute_values(values) # :nodoc: <ide> [substitutes, binds] <ide> end <ide> <add> def arel_attribute(name) # :nodoc: <add> klass.arel_attribute(name, table) <add> end <add> <ide> # Initializes new record from relation while maintaining the current <ide> # scope. <ide> # <ide> def update_all(updates) <ide> stmt.table(table) <ide> <ide> if joins_values.any? <del> @klass.connection.join_to_update(stmt, arel, @klass.arel_attribute(primary_key, table)) <add> @klass.connection.join_to_update(stmt, arel, arel_attribute(primary_key)) <ide> else <del> stmt.key = @klass.arel_attribute(primary_key, table) <add> stmt.key = arel_attribute(primary_key) <ide> stmt.take(arel.limit) <ide> stmt.order(*arel.orders) <ide> stmt.wheres = arel.constraints <ide> def delete_all(conditions = nil) <ide> stmt.from(table) <ide> <ide> if joins_values.any? <del> @klass.connection.join_to_delete(stmt, arel, @klass.arel_attribute(primary_key, table)) <add> @klass.connection.join_to_delete(stmt, arel, arel_attribute(primary_key)) <ide> else <ide> stmt.wheres = arel.constraints <ide> end <ide><path>activerecord/lib/active_record/relation/batches.rb <ide> def in_batches(of: 1000, start: nil, finish: nil, load: false) <ide> yield yielded_relation <ide> <ide> break if ids.length < of <del> batch_relation = relation.where(klass.arel_attribute(primary_key, table).gt(primary_key_offset)) <add> batch_relation = relation.where(arel_attribute(primary_key).gt(primary_key_offset)) <ide> end <ide> end <ide> <ide> private <ide> <ide> def apply_limits(relation, start, finish) <del> relation = relation.where(klass.arel_attribute(primary_key, table).gteq(start)) if start <del> relation = relation.where(klass.arel_attribute(primary_key, table).lteq(finish)) if finish <add> relation = relation.where(arel_attribute(primary_key).gteq(start)) if start <add> relation = relation.where(arel_attribute(primary_key).lteq(finish)) if finish <ide> relation <ide> end <ide> <ide><path>activerecord/lib/active_record/relation/calculations.rb <ide> def pluck(*column_names) <ide> else <ide> relation = spawn <ide> relation.select_values = column_names.map { |cn| <del> @klass.has_attribute?(cn) || @klass.attribute_alias?(cn) ? klass.arel_attribute(cn, table) : cn <add> @klass.has_attribute?(cn) || @klass.attribute_alias?(cn) ? arel_attribute(cn) : cn <ide> } <ide> result = klass.connection.select_all(relation.arel, nil, bound_attributes) <ide> result.cast_values(klass.attribute_types) <ide><path>activerecord/lib/active_record/relation/finder_methods.rb <ide> def first! <ide> def last(limit = nil) <ide> if limit <ide> if order_values.empty? && primary_key <del> order(klass.arel_attribute(primary_key, table).desc).limit(limit).reverse <add> order(arel_attribute(primary_key).desc).limit(limit).reverse <ide> else <ide> to_a.last(limit) <ide> end <ide> def find_nth_with_limit(index, limit) <ide> # TODO: once the offset argument is removed from find_nth, <ide> # find_nth_with_limit_and_offset can be merged into this method <ide> relation = if order_values.empty? && primary_key <del> order(klass.arel_attribute(primary_key, table).asc) <add> order(arel_attribute(primary_key).asc) <ide> else <ide> self <ide> end <ide><path>activerecord/lib/active_record/relation/predicate_builder/relation_handler.rb <ide> class PredicateBuilder <ide> class RelationHandler # :nodoc: <ide> def call(attribute, value) <ide> if value.select_values.empty? <del> value = value.select(value.klass.arel_attribute(value.klass.primary_key, value.klass.arel_table)) <add> value = value.select(value.arel_attribute(value.klass.primary_key)) <ide> end <ide> <ide> attribute.in(value.arel) <ide><path>activerecord/lib/active_record/relation/query_methods.rb <ide> def build_select(arel) <ide> def arel_columns(columns) <ide> columns.map do |field| <ide> if (Symbol === field || String === field) && (klass.has_attribute?(field) || klass.attribute_alias?(field)) && !from_clause.value <del> klass.arel_attribute(field, table) <add> arel_attribute(field) <ide> elsif Symbol === field <ide> connection.quote_table_name(field.to_s) <ide> else <ide> def arel_columns(columns) <ide> <ide> def reverse_sql_order(order_query) <ide> if order_query.empty? <del> return [klass.arel_attribute(primary_key, table).desc] if primary_key <add> return [arel_attribute(primary_key).desc] if primary_key <ide> raise IrreversibleOrderError, <ide> "Relation has no current order and table has no primary key to be used as default order" <ide> end <ide> def preprocess_order_args(order_args) <ide> order_args.map! do |arg| <ide> case arg <ide> when Symbol <del> klass.arel_attribute(arg, table).asc <add> arel_attribute(arg).asc <ide> when Hash <ide> arg.map { |field, dir| <del> klass.arel_attribute(field, table).send(dir.downcase) <add> arel_attribute(field).send(dir.downcase) <ide> } <ide> else <ide> arg
7
PHP
PHP
add thenreturn helper method to pipeline
d261f9fc75e888fd15895f1354b7ac338638dc47
<ide><path>src/Illuminate/Pipeline/Pipeline.php <ide> public function then(Closure $destination) <ide> return $pipeline($this->passable); <ide> } <ide> <add> /** <add> * Run the pipeline and return the result. <add> * <add> * @return mixed <add> */ <add> public function thenReturn() <add> { <add> return $this->then(function ($passable) { <add> return $passable; <add> }); <add> } <add> <ide> /** <ide> * Get the final piece of the Closure onion. <ide> * <ide><path>tests/Pipeline/PipelineTest.php <ide> public function testPipelineThrowsExceptionOnResolveWithoutContainer() <ide> return $piped; <ide> }); <ide> } <add> <add> public function testPipelineThenReturnMethodRunsPipelineThenReturnsPassable() <add> { <add> $result = (new Pipeline(new Container)) <add> ->send('foo') <add> ->through([PipelineTestPipeOne::class]) <add> ->thenReturn(); <add> <add> $this->assertEquals('foo', $result); <add> $this->assertEquals('foo', $_SERVER['__test.pipe.one']); <add> <add> unset($_SERVER['__test.pipe.one']); <add> } <ide> } <ide> <ide> class PipelineTestPipeOne
2
Text
Text
write reusable javascript with functions
cab064a183df281e24ef8d4551c4c480f9182b81
<ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/write-reusable-javascript-with-functions.english.md <ide> tests: <ide> - text: <code>reusableFunction</code> should be a function <ide> testString: assert(typeof reusableFunction === 'function', '<code>reusableFunction</code> should be a function'); <ide> - text: <code>reusableFunction</code> should output "Hi World" to the dev console <del> testString: assert("Hi World" === logOutput, '<code>reusableFunction</code> should output "Hi World" to the dev console'); <add> testString: assert(hiWorldWasLogged, '<code>reusableFunction</code> should output "Hi World" to the dev console'); <ide> - text: Call <code>reusableFunction</code> after you define it <del> testString: assert(/^\s*reusableFunction\(\)\s*;/m.test(code), 'Call <code>reusableFunction</code> after you define it'); <add> testString: assert(/^\s*reusableFunction\(\)\s*/m.test(code), 'Call <code>reusableFunction</code> after you define it'); <ide> <ide> ``` <ide> <ide> ourReusableFunction(); <ide> <ide> ```js <ide> var logOutput = ""; <del>var originalConsole = console <add>var originalConsole = console; <add>var nativeLog = console.log; <add>var hiWorldWasLogged = false; <ide> function capture() { <del> var nativeLog = console.log; <ide> console.log = function (message) { <add> if(message === 'Hi World') hiWorldWasLogged = true; <ide> if(message && message.trim) logOutput = message.trim(); <ide> if(nativeLog.apply) { <ide> nativeLog.apply(originalConsole, arguments); <ide> function capture() { <ide> } <ide> <ide> function uncapture() { <del> console.log = originalConsole.log; <add> console.log = nativeLog; <ide> } <ide> <ide> capture();
1
Javascript
Javascript
update react native types
8336f19aa80c6646d6969fa61e34420776d884be
<ide><path>packages/react-native-renderer/src/ReactFabric.js <ide> <ide> import type {HostComponent} from './ReactNativeTypes'; <ide> import type {ReactNodeList} from 'shared/ReactTypes'; <del>import type {ElementRef} from 'react'; <add>import type {ElementRef, Element, ElementType} from 'react'; <ide> <ide> import './ReactFabricInjection'; <ide> <ide> import getComponentName from 'shared/getComponentName'; <ide> <ide> const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; <ide> <del>function findHostInstance_DEPRECATED( <del> componentOrHandle: any, <add>function findHostInstance_DEPRECATED<TElementType: ElementType>( <add> componentOrHandle: ?(ElementRef<TElementType> | number), <ide> ): ?ElementRef<HostComponent<mixed>> { <ide> if (__DEV__) { <ide> const owner = ReactCurrentOwner.current; <ide> function findHostInstance_DEPRECATED( <ide> if (componentOrHandle == null) { <ide> return null; <ide> } <add> // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN <ide> if (componentOrHandle._nativeTag) { <add> // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN <ide> return componentOrHandle; <ide> } <add> // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN <ide> if (componentOrHandle.canonical && componentOrHandle.canonical._nativeTag) { <add> // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN <ide> return componentOrHandle.canonical; <ide> } <ide> let hostInstance; <ide> function sendAccessibilityEvent(handle: any, eventType: string) { <ide> } <ide> <ide> function render( <del> element: React$Element<any>, <del> containerTag: any, <del> callback: ?Function, <del>) { <add> element: Element<ElementType>, <add> containerTag: number, <add> callback: ?() => void, <add>): ?ElementRef<ElementType> { <ide> let root = roots.get(containerTag); <ide> <ide> if (!root) { <ide> function render( <ide> } <ide> updateContainer(element, root, null, callback); <ide> <add> // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN <ide> return getPublicRootInstance(root); <ide> } <ide> <ide><path>packages/react-native-renderer/src/ReactFabricHostConfig.js <ide> import type { <ide> MeasureLayoutOnSuccessCallback, <ide> MeasureOnSuccessCallback, <ide> NativeMethods, <del> ReactNativeBaseComponentViewConfig, <add> ViewConfig, <ide> TouchedViewDataAtPoint, <ide> } from './ReactNativeTypes'; <ide> <ide> if (registerEventHandler) { <ide> */ <ide> class ReactFabricHostComponent { <ide> _nativeTag: number; <del> viewConfig: ReactNativeBaseComponentViewConfig<>; <add> viewConfig: ViewConfig; <ide> currentProps: Props; <ide> _internalInstanceHandle: Object; <ide> <ide> constructor( <ide> tag: number, <del> viewConfig: ReactNativeBaseComponentViewConfig<>, <add> viewConfig: ViewConfig, <ide> props: Props, <ide> internalInstanceHandle: Object, <ide> ) { <ide><path>packages/react-native-renderer/src/ReactNativeAttributePayload.js <ide> function defaultDiffer(prevProp: mixed, nextProp: mixed): boolean { <ide> function restoreDeletedValuesInNestedArray( <ide> updatePayload: Object, <ide> node: NestedNode, <del> validAttributes: AttributeConfiguration<>, <add> validAttributes: AttributeConfiguration, <ide> ) { <ide> if (Array.isArray(node)) { <ide> let i = node.length; <ide> function diffNestedArrayProperty( <ide> updatePayload: null | Object, <ide> prevArray: Array<NestedNode>, <ide> nextArray: Array<NestedNode>, <del> validAttributes: AttributeConfiguration<>, <add> validAttributes: AttributeConfiguration, <ide> ): null | Object { <ide> const minLength = <ide> prevArray.length < nextArray.length ? prevArray.length : nextArray.length; <ide> function diffNestedProperty( <ide> updatePayload: null | Object, <ide> prevProp: NestedNode, <ide> nextProp: NestedNode, <del> validAttributes: AttributeConfiguration<>, <add> validAttributes: AttributeConfiguration, <ide> ): null | Object { <ide> if (!updatePayload && prevProp === nextProp) { <ide> // If no properties have been added, then we can bail out quickly on object <ide> function diffNestedProperty( <ide> function addNestedProperty( <ide> updatePayload: null | Object, <ide> nextProp: NestedNode, <del> validAttributes: AttributeConfiguration<>, <add> validAttributes: AttributeConfiguration, <ide> ) { <ide> if (!nextProp) { <ide> return updatePayload; <ide> function addNestedProperty( <ide> function clearNestedProperty( <ide> updatePayload: null | Object, <ide> prevProp: NestedNode, <del> validAttributes: AttributeConfiguration<>, <add> validAttributes: AttributeConfiguration, <ide> ): null | Object { <ide> if (!prevProp) { <ide> return updatePayload; <ide> function diffProperties( <ide> updatePayload: null | Object, <ide> prevProps: Object, <ide> nextProps: Object, <del> validAttributes: AttributeConfiguration<>, <add> validAttributes: AttributeConfiguration, <ide> ): null | Object { <ide> let attributeConfig; <ide> let nextProp; <ide> function diffProperties( <ide> updatePayload, <ide> prevProp, <ide> nextProp, <del> ((attributeConfig: any): AttributeConfiguration<>), <add> ((attributeConfig: any): AttributeConfiguration), <ide> ); <ide> if (removedKeyCount > 0 && updatePayload) { <ide> restoreDeletedValuesInNestedArray( <ide> updatePayload, <ide> nextProp, <del> ((attributeConfig: any): AttributeConfiguration<>), <add> ((attributeConfig: any): AttributeConfiguration), <ide> ); <ide> removedKeys = null; <ide> } <ide> function diffProperties( <ide> updatePayload = clearNestedProperty( <ide> updatePayload, <ide> prevProp, <del> ((attributeConfig: any): AttributeConfiguration<>), <add> ((attributeConfig: any): AttributeConfiguration), <ide> ); <ide> } <ide> } <ide> function diffProperties( <ide> function addProperties( <ide> updatePayload: null | Object, <ide> props: Object, <del> validAttributes: AttributeConfiguration<>, <add> validAttributes: AttributeConfiguration, <ide> ): null | Object { <ide> // TODO: Fast path <ide> return diffProperties(updatePayload, emptyObject, props, validAttributes); <ide> function addProperties( <ide> function clearProperties( <ide> updatePayload: null | Object, <ide> prevProps: Object, <del> validAttributes: AttributeConfiguration<>, <add> validAttributes: AttributeConfiguration, <ide> ): null | Object { <ide> // TODO: Fast path <ide> return diffProperties(updatePayload, prevProps, emptyObject, validAttributes); <ide> } <ide> <ide> export function create( <ide> props: Object, <del> validAttributes: AttributeConfiguration<>, <add> validAttributes: AttributeConfiguration, <ide> ): null | Object { <ide> return addProperties( <ide> null, // updatePayload <ide> export function create( <ide> export function diff( <ide> prevProps: Object, <ide> nextProps: Object, <del> validAttributes: AttributeConfiguration<>, <add> validAttributes: AttributeConfiguration, <ide> ): null | Object { <ide> return diffProperties( <ide> null, // updatePayload <ide><path>packages/react-native-renderer/src/ReactNativeFiberHostComponent.js <ide> import type { <ide> MeasureLayoutOnSuccessCallback, <ide> MeasureOnSuccessCallback, <ide> NativeMethods, <del> ReactNativeBaseComponentViewConfig, <add> ViewConfig, <ide> } from './ReactNativeTypes'; <ide> import type {Instance} from './ReactNativeHostConfig'; <ide> <ide> class ReactNativeFiberHostComponent { <ide> _children: Array<Instance | number>; <ide> _nativeTag: number; <ide> _internalFiberInstanceHandleDEV: Object; <del> viewConfig: ReactNativeBaseComponentViewConfig<>; <add> viewConfig: ViewConfig; <ide> <ide> constructor( <ide> tag: number, <del> viewConfig: ReactNativeBaseComponentViewConfig<>, <add> viewConfig: ViewConfig, <ide> internalInstanceHandleDEV: Object, <ide> ) { <ide> this._nativeTag = tag; <ide><path>packages/react-native-renderer/src/ReactNativeRenderer.js <ide> <ide> import type {HostComponent} from './ReactNativeTypes'; <ide> import type {ReactNodeList} from 'shared/ReactTypes'; <add>import type {ElementRef, Element, ElementType} from 'react'; <ide> <ide> import './ReactNativeInjection'; <ide> <ide> function sendAccessibilityEvent(handle: any, eventType: string) { <ide> } <ide> <ide> function render( <del> element: React$Element<any>, <del> containerTag: any, <del> callback: ?Function, <del>) { <add> element: Element<ElementType>, <add> containerTag: number, <add> callback: ?() => void, <add>): ?ElementRef<ElementType> { <ide> let root = roots.get(containerTag); <ide> <ide> if (!root) { <ide> function render( <ide> } <ide> updateContainer(element, root, null, callback); <ide> <add> // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN <ide> return getPublicRootInstance(root); <ide> } <ide> <ide><path>packages/react-native-renderer/src/ReactNativeTypes.js <ide> * LICENSE file in the root directory of this source tree. <ide> * <ide> * @format <del> * @flow <add> * @flow strict <ide> */ <ide> <del>import type {ElementRef, AbstractComponent} from 'react'; <add>import type {ElementRef, ElementType, Element, AbstractComponent} from 'react'; <ide> <ide> export type MeasureOnSuccessCallback = ( <ide> x: number, <ide> export type MeasureLayoutOnSuccessCallback = ( <ide> height: number, <ide> ) => void; <ide> <del>type AttributeType = <add>type AttributeType<T, V> = <ide> | true <ide> | $ReadOnly<{| <del> diff?: <T>(arg1: T, arg2: T) => boolean, <del> process?: (arg1: any) => any, <add> diff?: (arg1: T, arg2: T) => boolean, <add> process?: (arg1: V) => T, <ide> |}>; <ide> <del>export type AttributeConfiguration< <del> TProps = string, <del> TStyleProps = string, <del>> = $ReadOnly<{ <del> [propName: TProps]: AttributeType, <del> style: $ReadOnly<{[propName: TStyleProps]: AttributeType, ...}>, <add>// We either force that `diff` and `process` always use mixed, <add>// or we allow them to define specific types and use this hack <add>type AnyAttributeType = AttributeType<$FlowFixMe, $FlowFixMe>; <add> <add>export type AttributeConfiguration = $ReadOnly<{ <add> [propName: string]: AnyAttributeType, <add> style: $ReadOnly<{ <add> [propName: string]: AnyAttributeType, <add> ..., <add> }>, <add> ... <add>}>; <add> <add>type PartialAttributeConfiguration = $ReadOnly<{ <add> [propName: string]: AnyAttributeType, <add> style?: $ReadOnly<{ <add> [propName: string]: AnyAttributeType, <add> ..., <add> }>, <ide> ... <ide> }>; <ide> <del>export type ReactNativeBaseComponentViewConfig< <del> TProps = string, <del> TStyleProps = string, <del>> = $ReadOnly<{| <del> baseModuleName?: string, <add>export type ViewConfig = $ReadOnly<{ <add> Commands?: $ReadOnly<{[commandName: string]: number, ...}>, <add> Constants?: $ReadOnly<{[name: string]: mixed, ...}>, <add> Manager?: string, <add> NativeProps?: $ReadOnly<{[propName: string]: string, ...}>, <add> baseModuleName?: ?string, <ide> bubblingEventTypes?: $ReadOnly<{ <del> [eventName: string]: $ReadOnly<{| <del> phasedRegistrationNames: $ReadOnly<{| <add> [eventName: string]: $ReadOnly<{ <add> phasedRegistrationNames: $ReadOnly<{ <ide> captured: string, <ide> bubbled: string, <del> |}>, <del> |}>, <add> }>, <add> }>, <ide> ..., <ide> }>, <del> Commands?: $ReadOnly<{[commandName: string]: number, ...}>, <ide> directEventTypes?: $ReadOnly<{ <del> [eventName: string]: $ReadOnly<{| <add> [eventName: string]: $ReadOnly<{ <ide> registrationName: string, <del> |}>, <add> }>, <ide> ..., <ide> }>, <del> NativeProps?: $ReadOnly<{[propName: string]: string, ...}>, <ide> uiViewClassName: string, <del> validAttributes: AttributeConfiguration<TProps, TStyleProps>, <del>|}>; <add> validAttributes: AttributeConfiguration, <add>}>; <ide> <del>export type ViewConfigGetter = () => ReactNativeBaseComponentViewConfig<>; <add>export type PartialViewConfig = $ReadOnly<{ <add> bubblingEventTypes?: $PropertyType<ViewConfig, 'bubblingEventTypes'>, <add> directEventTypes?: $PropertyType<ViewConfig, 'directEventTypes'>, <add> uiViewClassName: string, <add> validAttributes?: PartialAttributeConfiguration, <add>}>; <ide> <ide> export type NativeMethods = { <ide> blur(): void, <ide> export type NativeMethods = { <ide> onSuccess: MeasureLayoutOnSuccessCallback, <ide> onFail?: () => void, <ide> ): void, <del> setNativeProps(nativeProps: Object): void, <add> setNativeProps(nativeProps: {...}): void, <ide> ... <ide> }; <ide> <ide> type InspectorDataSource = $ReadOnly<{| <ide> |}>; <ide> <ide> type InspectorDataGetter = ( <del> (componentOrHandle: any) => ?number, <add> <TElementType: ElementType>( <add> componentOrHandle: ElementRef<TElementType> | number, <add> ) => ?number, <ide> ) => $ReadOnly<{| <del> measure: Function, <add> measure: (callback: MeasureOnSuccessCallback) => void, <ide> props: InspectorDataProps, <ide> source: InspectorDataSource, <ide> |}>; <ide> export type TouchedViewDataAtPoint = $ReadOnly<{| <ide> * Provide minimal Flow typing for the high-level RN API and call it a day. <ide> */ <ide> export type ReactNativeType = { <del> findHostInstance_DEPRECATED( <del> componentOrHandle: any, <add> findHostInstance_DEPRECATED<TElementType: ElementType>( <add> componentOrHandle: ?(ElementRef<TElementType> | number), <ide> ): ?ElementRef<HostComponent<mixed>>, <del> findNodeHandle(componentOrHandle: any): ?number, <add> findNodeHandle<TElementType: ElementType>( <add> componentOrHandle: ?(ElementRef<TElementType> | number), <add> ): ?number, <ide> dispatchCommand( <ide> handle: ElementRef<HostComponent<mixed>>, <ide> command: string, <del> args: Array<any>, <add> args: Array<mixed>, <ide> ): void, <ide> sendAccessibilityEvent( <ide> handle: ElementRef<HostComponent<mixed>>, <ide> eventType: string, <ide> ): void, <ide> render( <del> element: React$Element<any>, <del> containerTag: any, <del> callback: ?Function, <del> ): any, <del> unmountComponentAtNode(containerTag: number): any, <del> unmountComponentAtNodeAndRemoveContainer(containerTag: number): any, <del> // TODO (bvaughn) Add types <del> unstable_batchedUpdates: any, <add> element: Element<ElementType>, <add> containerTag: number, <add> callback: ?() => void, <add> ): ?ElementRef<ElementType>, <add> unmountComponentAtNode(containerTag: number): void, <add> unmountComponentAtNodeAndRemoveContainer(containerTag: number): void, <add> unstable_batchedUpdates: <T>(fn: (T) => void, bookkeeping: T) => void, <ide> __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: SecretInternalsType, <ide> ... <ide> }; <ide> <ide> export type ReactFabricType = { <del> findHostInstance_DEPRECATED( <del> componentOrHandle: any, <add> findHostInstance_DEPRECATED<TElementType: ElementType>( <add> componentOrHandle: ?(ElementRef<TElementType> | number), <ide> ): ?ElementRef<HostComponent<mixed>>, <del> findNodeHandle(componentOrHandle: any): ?number, <add> findNodeHandle<TElementType: ElementType>( <add> componentOrHandle: ?(ElementRef<TElementType> | number), <add> ): ?number, <ide> dispatchCommand( <ide> handle: ElementRef<HostComponent<mixed>>, <ide> command: string, <del> args: Array<any>, <add> args: Array<mixed>, <ide> ): void, <ide> sendAccessibilityEvent( <ide> handle: ElementRef<HostComponent<mixed>>, <ide> eventType: string, <ide> ): void, <ide> render( <del> element: React$Element<any>, <del> containerTag: any, <del> callback: ?Function, <del> ): any, <del> unmountComponentAtNode(containerTag: number): any, <add> element: Element<ElementType>, <add> containerTag: number, <add> callback: ?() => void, <add> ): ?ElementRef<ElementType>, <add> unmountComponentAtNode(containerTag: number): void, <ide> ... <ide> }; <ide> <ide> export type ReactNativeEventTarget = { <del> node: Object, <add> node: {...}, <ide> canonical: { <ide> _nativeTag: number, <del> viewConfig: ReactNativeBaseComponentViewConfig<>, <del> currentProps: Object, <del> _internalInstanceHandle: Object, <add> viewConfig: ViewConfig, <add> currentProps: {...}, <add> _internalInstanceHandle: {...}, <ide> ... <ide> }, <ide> ...
6
Mixed
Javascript
apply component and mixins specs deterministically
367c88e399d60dfa5a5611fcaa5769c18b7ca86e
<ide><path>docs/docs/05-reusable-components.md <ide> React.renderComponent( <ide> ); <ide> ``` <ide> <del>A nice feature of mixins is that if a component is using multiple mixins and several mixins define the same lifecycle method (i.e. several mixins want to do some cleanup when the component is destroyed), all of the lifecycle methods are guaranteed to be called. <add>A nice feature of mixins is that if a component is using multiple mixins and several mixins define the same lifecycle method (i.e. several mixins want to do some cleanup when the component is destroyed), all of the lifecycle methods are guaranteed to be called. Methods defined on mixins run in the order mixins were listed, followed by a method call on the component. <ide> <ide><path>src/core/ReactCompositeComponent.js <ide> var ReactUpdates = require('ReactUpdates'); <ide> var instantiateReactComponent = require('instantiateReactComponent'); <ide> var invariant = require('invariant'); <ide> var keyMirror = require('keyMirror'); <add>var keyOf = require('keyOf'); <ide> var merge = require('merge'); <ide> var mixInto = require('mixInto'); <ide> var monitorCodeUse = require('monitorCodeUse'); <ide> var mapObject = require('mapObject'); <ide> var shouldUpdateReactComponent = require('shouldUpdateReactComponent'); <ide> var warning = require('warning'); <ide> <add>var MIXINS_KEY = keyOf({mixins: null}); <add> <ide> /** <ide> * Policies that describe methods in `ReactCompositeComponentInterface`. <ide> */ <ide> function mixSpecIntoComponent(ConvenienceConstructor, spec) { <ide> <ide> var Constructor = ConvenienceConstructor.type; <ide> var proto = Constructor.prototype; <add> <add> // By handling mixins before any other properties, we ensure the same <add> // chaining order is applied to methods with DEFINE_MANY policy, whether <add> // mixins are listed before or after these methods in the spec. <add> if (spec.hasOwnProperty(MIXINS_KEY)) { <add> RESERVED_SPEC_KEYS.mixins(ConvenienceConstructor, spec.mixins); <add> } <add> <ide> for (var name in spec) { <del> var property = spec[name]; <ide> if (!spec.hasOwnProperty(name)) { <ide> continue; <ide> } <ide> <add> if (name === MIXINS_KEY) { <add> // We have already handled mixins in a special case above <add> continue; <add> } <add> <add> var property = spec[name]; <ide> validateMethodOverride(proto, name); <ide> <ide> if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) { <ide><path>src/core/__tests__/ReactCompositeComponentMixin-test.js <ide> var reactComponentExpect; <ide> <ide> var TestComponent; <ide> var TestComponentWithPropTypes; <add>var TestComponentWithReverseSpec; <ide> var mixinPropValidator; <ide> var componentPropValidator; <ide> <ide> describe('ReactCompositeComponent-mixin', function() { <ide> } <ide> }; <ide> <add> var MixinBWithReverseSpec = { <add> componentDidMount: function() { <add> this.props.listener('MixinBWithReverseSpec didMount'); <add> }, <add> mixins: [MixinA] <add> }; <add> <ide> var MixinC = { <ide> statics: { <ide> staticC: function() {} <ide> describe('ReactCompositeComponent-mixin', function() { <ide> } <ide> }); <ide> <add> TestComponentWithReverseSpec = React.createClass({ <add> render: function() { <add> return <div />; <add> }, <add> componentDidMount: function() { <add> this.props.listener('Component didMount'); <add> }, <add> mixins: [MixinBWithReverseSpec, MixinC, MixinD] <add> }); <add> <ide> TestComponentWithPropTypes = React.createClass({ <ide> mixins: [MixinD], <ide> propTypes: { <ide> describe('ReactCompositeComponent-mixin', function() { <ide> ]); <ide> }); <ide> <add> it('should chain functions regardless of spec property order', function() { <add> var listener = mocks.getMockFunction(); <add> var instance = <TestComponentWithReverseSpec listener={listener} />; <add> instance = ReactTestUtils.renderIntoDocument(instance); <add> <add> expect(listener.mock.calls).toEqual([ <add> ['MixinA didMount'], <add> ['MixinBWithReverseSpec didMount'], <add> ['MixinC didMount'], <add> ['Component didMount'] <add> ]); <add> }); <add> <ide> it('should validate prop types via mixins', function() { <ide> expect(TestComponent.type.propTypes).toBeDefined(); <ide> expect(TestComponent.type.propTypes.value)
3
PHP
PHP
add way to get argument names as a list
a57945d9cdad67972f4125744bbeeddfe936a965
<ide><path>src/Console/ConsoleOptionParser.php <ide> public function arguments() <ide> return $this->_args; <ide> } <ide> <add> /** <add> * Get the list of argument names. <add> * <add> * @return string[] <add> */ <add> public function argumentNames() <add> { <add> $out = []; <add> foreach ($this->_args as $arg) { <add> $out[] = $arg->name(); <add> } <add> <add> return $out; <add> } <add> <ide> /** <ide> * Get the defined options in the parser. <ide> * <ide><path>tests/TestCase/Console/ConsoleOptionParserTest.php <ide> public function testAddArgumentOutOfOrder() <ide> $this->assertEquals('name', $result[1]->name()); <ide> $this->assertEquals('bag', $result[2]->name()); <ide> $this->assertSame([0, 1, 2], array_keys($result)); <add> $this->assertEquals( <add> ['other', 'name', 'bag'], <add> $parser->argumentNames() <add> ); <ide> } <ide> <ide> /**
2
Mixed
Javascript
assign error code to bootstrap_node created error
251e5ed8ee91747e31233fb2711f31be5d2e98a6
<ide><path>doc/api/errors.md <ide> found [here][online]. <ide> encountered by [`http`][] or [`net`][] -- often a sign that a `socket.end()` <ide> was not properly called. <ide> <add> <ide> <a id="nodejs-error-codes"></a> <ide> ## Node.js Error Codes <ide> <ide> An error using the `'ERR_STDOUT_CLOSE'` code is thrown specifically when an <ide> attempt is made to close the `process.stdout` stream. By design, Node.js does <ide> not allow `stdout` or `stderr` Streams to be closed by user code. <ide> <add><a id="ERR_UNKNOWN_BUILTIN_MODULE"></a> <add>### ERR_UNKNOWN_BUILTIN_MODULE <add> <add>The `'ERR_UNKNOWN_BUILTIN_MODULE'` error code is used to identify a specific <add>kind of internal Node.js error that should not typically be triggered by user <add>code. Instances of this error point to an internal bug within the Node.js <add>binary itself. <add> <ide> <a id="ERR_UNKNOWN_STDIN_TYPE"></a> <ide> ### ERR_UNKNOWN_STDIN_TYPE <ide> <ide> an attempt is made to launch a Node.js process with an unknown `stdout` or <ide> in user code, although it is not impossible. Occurrences of this error are most <ide> likely an indication of a bug within Node.js itself. <ide> <add> <ide> [`fs.readdir`]: fs.html#fs_fs_readdir_path_options_callback <ide> [`fs.readFileSync`]: fs.html#fs_fs_readfilesync_file_options <ide> [`fs.unlink`]: fs.html#fs_fs_unlink_path_callback <ide><path>lib/internal/bootstrap_node.js <ide> } <ide> <ide> if (!NativeModule.exists(id)) { <del> throw new Error(`No such native module ${id}`); <add> // Model the error off the internal/errors.js model, but <add> // do not use that module given that it could actually be <add> // the one causing the error if there's a bug in Node.js <add> const err = new Error(`No such built-in module: ${id}`); <add> err.code = 'ERR_UNKNOWN_BUILTIN_MODULE'; <add> err.name = 'Error [ERR_UNKNOWN_BUILTIN_MODULE]'; <add> throw err; <ide> } <ide> <ide> process.moduleLoadList.push(`NativeModule ${id}`); <ide><path>lib/internal/errors.js <ide> E('ERR_STDERR_CLOSE', 'process.stderr cannot be closed'); <ide> E('ERR_STDOUT_CLOSE', 'process.stdout cannot be closed'); <ide> E('ERR_UNKNOWN_STDIN_TYPE', 'Unknown stdin file type'); <ide> E('ERR_UNKNOWN_STREAM_TYPE', 'Unknown stream file type'); <add>E('ERR_UNKNOWN_BUILTIN_MODULE', (id) => `No such built-in module: ${id}`); <ide> // Add new errors from here... <ide> <ide> function invalidArgType(name, expected, actual) {
3
Javascript
Javascript
pick the right architecture on linux
35bc2cf520fb96b5dd43d86938f90c4e6e597194
<ide><path>script/lib/package-application.js <ide> module.exports = function () { <ide> 'app-bundle-id': 'com.github.atom', <ide> 'app-copyright': `Copyright ยฉ 2014-${(new Date()).getFullYear()} GitHub, Inc. All rights reserved.`, <ide> 'app-version': CONFIG.appMetadata.version, <del> 'arch': process.platform === 'win32' ? 'ia32' : 'x64', <add> 'arch': (() => { <add> if (process.platform === 'linux') { <add> return process.arch <add> } else { <add> return process.platform === 'win32' ? 'ia32' : 'x64' <add> }})(), <ide> 'asar': {unpack: buildAsarUnpackGlobExpression()}, <ide> 'build-version': CONFIG.appMetadata.version, <ide> 'download': {cache: CONFIG.electronDownloadPath},
1
Javascript
Javascript
prevent example breaking on key update
00d5fde49ca50eb777ac61541bdd9cc68fd52f20
<ide><path>src/ng/cacheFactory.js <ide> $scope.keys = []; <ide> $scope.cache = $cacheFactory('cacheId'); <ide> $scope.put = function(key, value) { <del> $scope.cache.put(key, value); <del> $scope.keys.push(key); <add> if ($scope.cache.get(key) === undefined) { <add> $scope.keys.push(key); <add> } <add> $scope.cache.put(key, value === undefined ? null : value); <ide> }; <ide> }]); <ide> </file>
1
Ruby
Ruby
add missing developer_tools methods
ed9f7308b265944c27c833b9a2aaa0e911ff5667
<ide><path>Library/Homebrew/compat/macos.rb <ide> def mountain_lion? <ide> def macports_or_fink_installed? <ide> !macports_or_fink.empty? <ide> end <add> <add> def locate(tool) <add> DeveloperTools.locate(tool) <add> end <add> <add> def default_cc <add> DeveloperTools.default_cc <add> end <add> <add> def default_compiler <add> DeveloperTools.default_compiler <add> end <add> <add> def gcc_40_build_version <add> DeveloperTools.gcc_40_build_version <add> end <add> alias_method :gcc_4_0_build_version, :gcc_40_build_version <add> <add> def gcc_42_build_version <add> DeveloperTools.gcc_42_build_version <add> end <add> alias_method :gcc_build_version, :gcc_42_build_version <add> <add> def llvm_build_version <add> DeveloperTools.llvm_build_version <add> end <add> <add> def clang_version <add> DeveloperTools.llvm_build_version <add> end <add> <add> def clang_build_version <add> DeveloperTools.clang_build_version <add> end <ide> end <ide> end
1
Python
Python
fix tests on python 2
a0833836e07aeabde98eb3cfa1a583b3dd4a9439
<ide><path>numpy/tests/test_public_api.py <ide> from __future__ import division, absolute_import, print_function <ide> <add>import sys <add> <ide> import numpy as np <add>import pytest <ide> <ide> <ide> def check_dir(module, module_name=None): <ide> def check_dir(module, module_name=None): <ide> return results <ide> <ide> <add>@pytest.mark.skipif( <add> sys.version_info[0] < 3, <add> reason="NumPy exposes slightly different functions on Python 2") <ide> def test_numpy_namespace(): <ide> # None of these objects are publicly documented. <ide> undocumented = {
1
PHP
PHP
remove extra line
f00248acf69c35570326ba9a6870d8750ff6f23d
<ide><path>src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php <ide> protected function isClassCastable($key) <ide> throw new InvalidCastException($this->getModel(), $key, $castType); <ide> } <ide> <del> <ide> /** <ide> * Determine if the key is serializable using a custom class. <ide> *
1
Python
Python
add auto next sentence prediction
8551a992326d3c538c40ad944898f079203b5491
<ide><path>src/transformers/modeling_tf_auto.py <ide> from .modeling_tf_bert import ( <ide> TFBertForMaskedLM, <ide> TFBertForMultipleChoice, <add> TFBertForNextSentencePrediction, <ide> TFBertForPreTraining, <ide> TFBertForQuestionAnswering, <ide> TFBertForSequenceClassification, <ide> from .modeling_tf_mobilebert import ( <ide> TFMobileBertForMaskedLM, <ide> TFMobileBertForMultipleChoice, <add> TFMobileBertForNextSentencePrediction, <ide> TFMobileBertForPreTraining, <ide> TFMobileBertForQuestionAnswering, <ide> TFMobileBertForSequenceClassification, <ide> ] <ide> ) <ide> <add>TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING = OrderedDict( <add> [ <add> (BertConfig, TFBertForNextSentencePrediction), <add> (MobileBertConfig, TFMobileBertForNextSentencePrediction), <add> ] <add>) <add> <ide> <ide> TF_AUTO_MODEL_PRETRAINED_DOCSTRING = r""" <ide> <ide> def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs): <ide> ", ".join(c.__name__ for c in TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPING.keys()), <ide> ) <ide> ) <add> <add> <add>class TFAutoModelForNextSentencePrediction: <add> r""" <add> This is a generic model class that will be instantiated as one of the model classes of the library---with a <add> multiple choice classification head---when created with the when created with the <add> :meth:`~transformers.TFAutoModelForNextSentencePrediction.from_pretrained` class method or the <add> :meth:`~transformers.TFAutoModelForNextSentencePrediction.from_config` class method. <add> <add> This class cannot be instantiated directly using ``__init__()`` (throws an error). <add> """ <add> <add> def __init__(self): <add> raise EnvironmentError( <add> "TFAutoModelForNextSentencePrediction is designed to be instantiated " <add> "using the `TFAutoModelForNextSentencePrediction.from_pretrained(pretrained_model_name_or_path)` or " <add> "`TFAutoModelForNextSentencePrediction.from_config(config)` methods." <add> ) <add> <add> @classmethod <add> @replace_list_option_in_docstrings(TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING, use_model_types=False) <add> def from_config(cls, config): <add> r""" <add> Instantiates one of the model classes of the library---with a next sentence prediction head---from a <add> configuration. <add> <add> Note: <add> Loading a model from its configuration file does **not** load the model weights. It only affects the <add> model's configuration. Use :meth:`~transformers.TFAutoModelForNextSentencePrediction.from_pretrained` to <add> load the model weights. <add> <add> Args: <add> config (:class:`~transformers.PretrainedConfig`): <add> The model class to instantiate is selected based on the configuration class: <add> <add> List options <add> <add> Examples:: <add> <add> >>> from transformers import AutoConfig, TFAutoModelForNextSentencePrediction <add> >>> # Download configuration from S3 and cache. <add> >>> config = AutoConfig.from_pretrained('bert-base-uncased') <add> >>> model = TFAutoModelForNextSentencePrediction.from_config(config) <add> """ <add> if type(config) in TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING.keys(): <add> return TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING[type(config)](config) <add> raise ValueError( <add> "Unrecognized configuration class {} for this kind of TFAutoModel: {}.\n" <add> "Model type should be one of {}.".format( <add> config.__class__, <add> cls.__name__, <add> ", ".join(c.__name__ for c in TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING.keys()), <add> ) <add> ) <add> <add> @classmethod <add> @replace_list_option_in_docstrings(TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING) <add> @add_start_docstrings( <add> "Instantiate one of the model classes of the library---with a next sentence prediction head---from a " <add> "pretrained model.", <add> TF_AUTO_MODEL_PRETRAINED_DOCSTRING, <add> ) <add> def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs): <add> r""" <add> Examples:: <add> <add> >>> from transformers import AutoConfig, TFAutoModelForNextSentencePrediction <add> <add> >>> # Download model and configuration from S3 and cache. <add> >>> model = TFAutoModelForNextSentencePrediction.from_pretrained('bert-base-uncased') <add> <add> >>> # Update configuration during loading <add> >>> model = TFAutoModelForNextSentencePrediction.from_pretrained('bert-base-uncased', output_attentions=True) <add> >>> model.config.output_attentions <add> True <add> <add> >>> # Loading from a PyTorch checkpoint file instead of a TensorFlow model (slower) <add> >>> config = AutoConfig.from_json_file('./pt_model/bert_pt_model_config.json') <add> >>> model = TFAutoModelForNextSentencePrediction.from_pretrained('./pt_model/bert_pytorch_model.bin', from_pt=True, config=config) <add> """ <add> config = kwargs.pop("config", None) <add> if not isinstance(config, PretrainedConfig): <add> config, kwargs = AutoConfig.from_pretrained( <add> pretrained_model_name_or_path, return_unused_kwargs=True, **kwargs <add> ) <add> <add> if type(config) in TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING.keys(): <add> return TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING[type(config)].from_pretrained( <add> pretrained_model_name_or_path, *model_args, config=config, **kwargs <add> ) <add> raise ValueError( <add> "Unrecognized configuration class {} for this kind of TFAutoModel: {}.\n" <add> "Model type should be one of {}.".format( <add> config.__class__, <add> cls.__name__, <add> ", ".join(c.__name__ for c in TF_MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING.keys()), <add> ) <add> ) <ide><path>utils/check_repo.py <ide> "RagSequenceForGeneration", <ide> "RagTokenForGeneration", <ide> "T5Stack", <del> "TFBertForNextSentencePrediction", <ide> "TFFunnelBaseModel", <ide> "TFGPT2DoubleHeadsModel", <del> "TFMobileBertForNextSentencePrediction", <ide> "TFOpenAIGPTDoubleHeadsModel", <ide> "XLMForQuestionAnswering", <ide> "XLMProphetNetDecoder",
2
Javascript
Javascript
add spec for devsettings
85252a6cac044872e80f35fb3ab1c198d92cbf21
<ide><path>Libraries/NativeModules/specs/NativeDevSettings.js <add>/** <add> * Copyright (c) Facebook, Inc. and its affiliates. <add> * <add> * This source code is licensed under the MIT license found in the <add> * LICENSE file in the root directory of this source tree. <add> * <add> * @flow strict-local <add> * @format <add> */ <add> <add>'use strict'; <add> <add>import type {TurboModule} from '../../TurboModule/RCTExport'; <add>import * as TurboModuleRegistry from '../../TurboModule/TurboModuleRegistry'; <add> <add>export interface Spec extends TurboModule { <add> +reload: () => void; <add> +setHotLoadingEnabled: (isHotLoadingEnabled: boolean) => void; <add> +setIsDebuggingRemotely: (isDebuggingRemotelyEnabled: boolean) => void; <add> +setLiveReloadEnabled: (isLiveReloadEnabled: boolean) => void; <add> +setProfilingEnabled: (isProfilingEnabled: boolean) => void; <add> +toggleElementInspector: () => void; <add> <add> // iOS only. <add> +setIsShakeToShowDevMenuEnabled: (enabled: boolean) => void; <add>} <add> <add>export default TurboModuleRegistry.getEnforcing<Spec>('DevSettings');
1
Ruby
Ruby
avoid deprecation warning
6e5b98e9102373957d748aa084f625d2d56e02ff
<ide><path>activerecord/lib/active_record/railtie.rb <ide> class Railtie < Rails::Railtie <ide> <ide> config.after_initialize do <ide> ActiveSupport.on_load(:active_record) do <del> instantiate_observers <add> ActiveRecord::Base.instantiate_observers <ide> <ide> ActionDispatch::Reloader.to_prepare do <ide> ActiveRecord::Base.instantiate_observers
1
Python
Python
fix a typo in doc string
5775220a931b1bc5da89c01a9ca624d664130593
<ide><path>official/utils/misc/keras_utils.py <ide> class TimeHistory(tf.keras.callbacks.Callback): <ide> <ide> def __init__(self, batch_size, log_steps): <ide> """Callback for logging performance (# examples/second). <del>k <add> <ide> Args: <ide> batch_size: Total batch size. <ide> log_steps: Interval of time history logs.
1
Mixed
Javascript
add new functions to outgoingmessage
3e6f1032a4fdb8ca7fba02c7d2103fba68c0ee1f
<ide><path>doc/api/http.md <ide> Example: <ide> var contentType = response.getHeader('content-type'); <ide> ``` <ide> <add>### response.getHeaderNames() <add><!-- YAML <add>added: REPLACEME <add>--> <add> <add>* Returns: {Array} <add> <add>Returns an array containing the unique names of the current outgoing headers. <add>All header names are lowercase. <add> <add>Example: <add> <add>```js <add>response.setHeader('Foo', 'bar'); <add>response.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']); <add> <add>var headerNames = response.getHeaderNames(); <add>// headerNames === ['foo', 'set-cookie'] <add>``` <add> <add>### response.getHeaders() <add><!-- YAML <add>added: REPLACEME <add>--> <add> <add>* Returns: {Object} <add> <add>Returns a shallow copy of the current outgoing headers. Since a shallow copy <add>is used, array values may be mutated without additional calls to various <add>header-related http module methods. The keys of the returned object are the <add>header names and the values are the respective header values. All header names <add>are lowercase. <add> <add>Example: <add> <add>```js <add>response.setHeader('Foo', 'bar'); <add>response.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']); <add> <add>var headers = response.getHeaders(); <add>// headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] } <add>``` <add> <add>### response.hasHeader(name) <add><!-- YAML <add>added: REPLACEME <add>--> <add> <add>* `name` {String} <add>* Returns: {Boolean} <add> <add>Returns `true` if the header identified by `name` is currently set in the <add>outgoing headers. Note that the header name matching is case-insensitive. <add> <add>Example: <add> <add>```js <add>var hasContentType = response.hasHeader('content-type'); <add>``` <add> <ide> ### response.headersSent <ide> <!-- YAML <ide> added: v0.9.3 <ide><path>lib/_http_outgoing.js <ide> var RE_FIELDS = new RegExp('^(?:Connection|Transfer-Encoding|Content-Length|' + <ide> var RE_CONN_VALUES = /(?:^|\W)close|upgrade(?:$|\W)/ig; <ide> var RE_TE_CHUNKED = common.chunkExpression; <ide> <add>// Used to store headers returned by getHeaders() <add>function OutgoingHeaders() {} <add>OutgoingHeaders.prototype = Object.create(null); <add> <ide> var dateCache; <ide> function utcDate() { <ide> if (!dateCache) { <ide> OutgoingMessage.prototype.getHeader = function getHeader(name) { <ide> }; <ide> <ide> <add>// Returns an array of the names of the current outgoing headers. <add>OutgoingMessage.prototype.getHeaderNames = function getHeaderNames() { <add> return (this._headers ? Object.keys(this._headers) : []); <add>}; <add> <add> <add>// Returns a shallow copy of the current outgoing headers. <add>OutgoingMessage.prototype.getHeaders = function getHeaders() { <add> const headers = this._headers; <add> const ret = new OutgoingHeaders(); <add> if (headers) { <add> const keys = Object.keys(headers); <add> for (var i = 0; i < keys.length; ++i) { <add> const key = keys[i]; <add> const val = headers[key][1]; <add> ret[key] = val; <add> } <add> } <add> return ret; <add>}; <add> <add> <add>OutgoingMessage.prototype.hasHeader = function hasHeader(name) { <add> if (typeof name !== 'string') { <add> throw new TypeError('"name" argument must be a string'); <add> } <add> <add> return !!(this._headers && this._headers[name.toLowerCase()]); <add>}; <add> <add> <ide> OutgoingMessage.prototype.removeHeader = function removeHeader(name) { <ide> if (typeof name !== 'string') { <ide> throw new TypeError('"name" argument must be a string'); <ide><path>test/parallel/test-http-mutable-headers.js <ide> const cookies = [ <ide> const s = http.createServer(common.mustCall((req, res) => { <ide> switch (test) { <ide> case 'headers': <add> // Check that header-related functions work before setting any headers <add> // eslint-disable-next-line no-restricted-properties <add> assert.deepEqual(res.getHeaders(), {}); <add> assert.deepStrictEqual(res.getHeaderNames(), []); <add> assert.deepStrictEqual(res.hasHeader('Connection'), false); <add> assert.deepStrictEqual(res.getHeader('Connection'), undefined); <add> <ide> assert.throws(() => { <ide> res.setHeader(); <ide> }, /^TypeError: Header name must be a valid HTTP Token \["undefined"\]$/); <ide> const s = http.createServer(common.mustCall((req, res) => { <ide> res.removeHeader(); <ide> }, /^TypeError: "name" argument must be a string$/); <ide> <add> const arrayValues = [1, 2, 3]; <ide> res.setHeader('x-test-header', 'testing'); <ide> res.setHeader('X-TEST-HEADER2', 'testing'); <ide> res.setHeader('set-cookie', cookies); <del> res.setHeader('x-test-array-header', [1, 2, 3]); <add> res.setHeader('x-test-array-header', arrayValues); <ide> <ide> assert.strictEqual(res.getHeader('x-test-header'), 'testing'); <ide> assert.strictEqual(res.getHeader('x-test-header2'), 'testing'); <ide> <add> const headersCopy = res.getHeaders(); <add> // eslint-disable-next-line no-restricted-properties <add> assert.deepEqual(headersCopy, { <add> 'x-test-header': 'testing', <add> 'x-test-header2': 'testing', <add> 'set-cookie': cookies, <add> 'x-test-array-header': arrayValues <add> }); <add> // eslint-disable-next-line no-restricted-properties <add> assert.deepEqual(headersCopy['set-cookie'], cookies); <add> assert.strictEqual(headersCopy['x-test-array-header'], arrayValues); <add> <add> assert.deepStrictEqual(res.getHeaderNames(), <add> ['x-test-header', 'x-test-header2', <add> 'set-cookie', 'x-test-array-header']); <add> <add> assert.strictEqual(res.hasHeader('x-test-header2'), true); <add> assert.strictEqual(res.hasHeader('X-TEST-HEADER2'), true); <add> assert.strictEqual(res.hasHeader('X-Test-Header2'), true); <add> assert.throws(() => { <add> res.hasHeader(); <add> }, /^TypeError: "name" argument must be a string$/); <add> assert.throws(() => { <add> res.hasHeader(null); <add> }, /^TypeError: "name" argument must be a string$/); <add> assert.throws(() => { <add> res.hasHeader(true); <add> }, /^TypeError: "name" argument must be a string$/); <add> assert.throws(() => { <add> res.hasHeader({ toString: () => 'X-TEST-HEADER2' }); <add> }, /^TypeError: "name" argument must be a string$/); <add> <ide> res.removeHeader('x-test-header2'); <add> <add> assert.strictEqual(res.hasHeader('x-test-header2'), false); <add> assert.strictEqual(res.hasHeader('X-TEST-HEADER2'), false); <add> assert.strictEqual(res.hasHeader('X-Test-Header2'), false); <ide> break; <ide> <ide> case 'contentLength':
3
Javascript
Javascript
switch _writablestate.buffer to queue
91586661c983f45d650644451df73c8649a8d459
<ide><path>lib/_stream_writable.js <ide> Writable.WritableState = WritableState; <ide> <ide> var util = require('util'); <ide> var Stream = require('stream'); <add>var debug = util.debuglog('stream'); <ide> <ide> util.inherits(Writable, Stream); <ide> <ide> function WriteReq(chunk, encoding, cb) { <ide> this.chunk = chunk; <ide> this.encoding = encoding; <ide> this.callback = cb; <add> this.next = null; <ide> } <ide> <ide> function WritableState(options, stream) { <ide> function WritableState(options, stream) { <ide> // the amount that is being written when _write is called. <ide> this.writelen = 0; <ide> <del> this.buffer = []; <add> this.bufferedRequest = null; <add> this.lastBufferedRequest = null; <ide> <ide> // number of pending user-supplied write callbacks <ide> // this must be 0 before 'finish' can be emitted <ide> function WritableState(options, stream) { <ide> this.errorEmitted = false; <ide> } <ide> <add>WritableState.prototype.getBuffer = function writableStateGetBuffer() { <add> var current = this.bufferedRequest; <add> var out = []; <add> while (current) { <add> out.push(current); <add> current = current.next; <add> } <add> return out; <add>}; <add> <add>Object.defineProperty(WritableState.prototype, 'buffer', { <add> get: util.deprecate(function() { <add> return this.getBuffer(); <add> }, '_writableState.buffer is deprecated. Use ' + <add> '_writableState.getBuffer() instead.') <add>}); <add> <ide> function Writable(options) { <ide> // Writable ctor is applied to Duplexes, though they're not <ide> // instanceof Writable, they're instanceof Readable. <ide> Writable.prototype.uncork = function() { <ide> !state.corked && <ide> !state.finished && <ide> !state.bufferProcessing && <del> state.buffer.length) <add> state.bufferedRequest) <ide> clearBuffer(this, state); <ide> } <ide> }; <ide> function writeOrBuffer(stream, state, chunk, encoding, cb) { <ide> if (!ret) <ide> state.needDrain = true; <ide> <del> if (state.writing || state.corked) <del> state.buffer.push(new WriteReq(chunk, encoding, cb)); <add> if (state.writing || state.corked) { <add> var last = state.lastBufferedRequest; <add> state.lastBufferedRequest = new WriteReq(chunk, encoding, cb); <add> if (last) { <add> last.next = state.lastBufferedRequest; <add> } else { <add> state.bufferedRequest = state.lastBufferedRequest; <add> } <add> } <ide> else <ide> doWrite(stream, state, false, len, chunk, encoding, cb); <ide> <ide> function onwrite(stream, er) { <ide> if (!finished && <ide> !state.corked && <ide> !state.bufferProcessing && <del> state.buffer.length) { <add> state.bufferedRequest) { <ide> clearBuffer(stream, state); <ide> } <ide> <ide> function onwriteDrain(stream, state) { <ide> // if there's something in the buffer waiting, then process it <ide> function clearBuffer(stream, state) { <ide> state.bufferProcessing = true; <add> var entry = state.bufferedRequest; <ide> <del> if (stream._writev && state.buffer.length > 1) { <add> if (stream._writev && entry && entry.next) { <ide> // Fast case, write everything using _writev() <add> var buffer = []; <ide> var cbs = []; <del> for (var c = 0; c < state.buffer.length; c++) <del> cbs.push(state.buffer[c].callback); <add> while (entry) { <add> cbs.push(entry.callback); <add> buffer.push(entry); <add> entry = entry.next; <add> } <ide> <ide> // count the one we are adding, as well. <ide> // TODO(isaacs) clean this up <ide> state.pendingcb++; <del> doWrite(stream, state, true, state.length, state.buffer, '', function(err) { <add> state.lastBufferedRequest = null; <add> doWrite(stream, state, true, state.length, buffer, '', function(err) { <ide> for (var i = 0; i < cbs.length; i++) { <ide> state.pendingcb--; <ide> cbs[i](err); <ide> } <ide> }); <ide> <ide> // Clear buffer <del> state.buffer = []; <ide> } else { <ide> // Slow case, write chunks one-by-one <del> for (var c = 0; c < state.buffer.length; c++) { <del> var entry = state.buffer[c]; <add> while (entry) { <ide> var chunk = entry.chunk; <ide> var encoding = entry.encoding; <ide> var cb = entry.callback; <ide> var len = state.objectMode ? 1 : chunk.length; <ide> <ide> doWrite(stream, state, false, len, chunk, encoding, cb); <del> <add> entry = entry.next; <ide> // if we didn't call the onwrite immediately, then <ide> // it means that we need to wait until it does. <ide> // also, that means that the chunk and cb are currently <ide> // being processed, so move the buffer counter past them. <ide> if (state.writing) { <del> c++; <ide> break; <ide> } <ide> } <ide> <del> if (c < state.buffer.length) <del> state.buffer = state.buffer.slice(c); <del> else <del> state.buffer.length = 0; <add> if (entry === null) <add> state.lastBufferedRequest = null; <ide> } <del> <add> state.bufferedRequest = entry; <ide> state.bufferProcessing = false; <ide> } <ide> <ide> Writable.prototype.end = function(chunk, encoding, cb) { <ide> function needFinish(stream, state) { <ide> return (state.ending && <ide> state.length === 0 && <del> state.buffer.length === 0 && <add> state.bufferedRequest === null && <ide> !state.finished && <ide> !state.writing); <ide> } <ide><path>lib/net.js <ide> Socket.prototype.__defineGetter__('bytesWritten', function() { <ide> data = this._pendingData, <ide> encoding = this._pendingEncoding; <ide> <del> state.buffer.forEach(function(el) { <add> state.getBuffer().forEach(function(el) { <ide> if (util.isBuffer(el.chunk)) <ide> bytes += el.chunk.length; <ide> else <ide><path>test/simple/test-stream2-transform.js <ide> test('writable side consumption', function(t) { <ide> t.equal(tx._readableState.length, 10); <ide> t.equal(transformed, 10); <ide> t.equal(tx._transformState.writechunk.length, 5); <del> t.same(tx._writableState.buffer.map(function(c) { <add> t.same(tx._writableState.getBuffer().map(function(c) { <ide> return c.chunk.length; <ide> }), [6, 7, 8, 9, 10]); <ide>
3
Python
Python
fix an `automodule` path
65ec64c932626689b50b53e0909ced47f5a821fa
<ide><path>numpy/typing/__init__.py <ide> <ide> .. versionadded:: 1.21 <ide> <del>.. automodule:: numpy._typing.mypy_plugin <add>.. automodule:: numpy.typing.mypy_plugin <ide> <ide> .. currentmodule:: numpy.typing <ide>
1