Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit817c39a

Browse files
authored
Update flatten helper without recursion (#5454)
1 parent0f02c50 commit817c39a

File tree

8 files changed

+8
-30
lines changed

8 files changed

+8
-30
lines changed

‎docs/v2/annotated-source/coffeescript.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ <h1>coffeescript.coffee</h1>
824824
<spanclass="hljs-string">&quot;<spanclass="hljs-subst">#{err.toString()}</span>\n<spanclass="hljs-subst">#{frames.join<spanclass="hljs-string">&#x27;\n&#x27;</span>}</span>\n&quot;</span>
825825
<spanclass="hljs-function">
826826
<spanclass="hljs-title">checkShebangLine</span> =<spanclass="hljs-params">(file, input)</span> -&gt;</span>
827-
firstLine = input.split(<spanclass="hljs-regexp">/$/m</span>)[<spanclass="hljs-number">0</span>]
827+
firstLine = input.split(<spanclass="hljs-regexp">/$/m</span>,<spanclass="hljs-number">1</span>)[<spanclass="hljs-number">0</span>]
828828
rest = firstLine?.match(<spanclass="hljs-regexp">/^#!\s*([^\s]+\s*)(.*)/</span>)
829829
args = rest?[<spanclass="hljs-number">2</span>]?.split(<spanclass="hljs-regexp">/\s/</span>).filter (s) -&gt; s<spanclass="hljs-keyword">isnt</span><spanclass="hljs-string">&#x27;&#x27;</span>
830830
<spanclass="hljs-keyword">if</span> args?.length &gt;<spanclass="hljs-number">1</span>

‎docs/v2/annotated-source/helpers.html

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,7 @@ <h1>helpers.coffee</h1>
275275
</div>
276276

277277
<divclass="content"><divclass='highlight'><pre><spanclass="hljs-built_in">exports</span>.flatten = flatten =<spanclass="hljs-function"><spanclass="hljs-params">(array)</span> -&gt;</span>
278-
flattened = []
279-
<spanclass="hljs-keyword">for</span> element<spanclass="hljs-keyword">in</span> array
280-
<spanclass="hljs-keyword">if</span><spanclass="hljs-string">&#x27;[object Array]&#x27;</span><spanclass="hljs-keyword">is</span> Object::toString.call element
281-
flattened = flattened.concat flatten element
282-
<spanclass="hljs-keyword">else</span>
283-
flattened.push element
284-
flattened</pre></div></div>
278+
array.flat(<spanclass="hljs-literal">Infinity</span>)</pre></div></div>
285279

286280
</li>
287281

‎docs/v2/browser-compiler-legacy/coffeescript.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/v2/browser-compiler-modern/coffeescript.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎lib/coffeescript-browser-compiler-legacy/coffeescript.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎lib/coffeescript-browser-compiler-modern/coffeescript.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎lib/coffeescript/helpers.js

Lines changed: 1 addition & 11 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎src/helpers.coffee

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@ extend = exports.extend = (object, properties) ->
4747
# Return a flattened version of an array.
4848
# Handy for getting a list of `children` from the nodes.
4949
exports.flatten=flatten= (array)->
50-
flattened= []
51-
for elementin array
52-
if'[object Array]'isObject::toString.call element
53-
flattened=flattened.concatflatten element
54-
else
55-
flattened.push element
56-
flattened
50+
array.flat(Infinity)
5751

5852
# Delete a key from an object, returning the value. Useful when a node is
5953
# looking for a particular method in an options hash.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp