path: refactor for performance and consistency · nodejs/node@bca53dc · GitHub
Skip to content

Commit bca53dc

Browse files
nwoltmansilverwind
authored andcommitted
path: refactor for performance and consistency
Improve performance by: + Not leaking the `arguments` object! + Getting the last character of a string by index, instead of with `.substr()` or `.slice()` Improve code consistency by: + Using `[]` instead of `.charAt()` where possible + Using a function declaration instead of a var declaration + Using `.slice()` with clearer arguments + Checking if `dir` is truthy in `win32.format` (added tests for this) Improve both by: + Making the reusable `trimArray()` function + Standardizing getting certain path statistics with the new `win32StatPath()` function PR-URL: #1778 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
1 parent 4614033 commit bca53dc

2 files changed

Lines changed: 91 additions & 74 deletions

File tree

lib/path.js

Lines changed: 69 additions & 70 deletions

test/parallel/test-path-parse-format.js

Lines changed: 22 additions & 4 deletions

0 commit comments

Comments
 (0)