Skip to content

Commit 61ba0a9

Browse files
committed
#19: array (chore): refactor common methods
1 parent 420a7fc commit 61ba0a9

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050
},
5151
"devDependencies": {
5252
"@ostai/eslint-config": "^3.5.0",
53-
"ava": "^3.12.1",
53+
"ava": "^3.13.0",
5454
"codecov": "^3.7.2",
55-
"eslint": "^7.8.0",
56-
"eslint-plugin-import": "^2.22.0",
55+
"eslint": "^7.10.0",
56+
"eslint-plugin-import": "^2.22.1",
5757
"nyc": "^15.1.0",
5858
"test-fixture": "^2.4.1",
59-
"typescript": "^4.0.2"
59+
"typescript": "^4.0.3"
6060
},
6161
"dependencies": {
6262
"core-util-is": "^1.0.2",

src/array.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const {
88

99
symbol,
1010
define,
11-
copy_comments
11+
copy_comments,
12+
copy_all_comments
1213
} = require('./common')
1314

1415

@@ -41,9 +42,7 @@ const reverse_comments = array => {
4142
}
4243

4344
const move_comment = (target, source, i, offset, remove) => {
44-
SYMBOL_PREFIXES.forEach(prefix => {
45-
copy_comments(target, source, i + offset, i, prefix, remove)
46-
})
45+
copy_all_comments(target, source, i + offset, i, remove)
4746
}
4847

4948
const move_comments = (

src/common.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ const copy_comments = (
6464
}
6565
}
6666

67+
const copy_all_comments = (
68+
target, source, target_key, source_key, remove_source
69+
) => {
70+
SYMBOL_PREFIXES.forEach(prefix => {
71+
copy_comments(target, source, target_key, source_key, prefix, remove_source)
72+
})
73+
}
74+
6775
const assign_non_prop_comments = (target, source) => {
6876
NON_PROP_SYMBOL_KEYS.forEach(key => {
6977
const comments = source[key]
@@ -82,9 +90,7 @@ const assign = (target, source, keys) => {
8290
}
8391

8492
target[key] = source[key]
85-
SYMBOL_PREFIXES.forEach(prefix => {
86-
copy_comments(target, source, key, key, prefix)
87-
})
93+
copy_all_comments(target, source, key, key)
8894
})
8995

9096
return target
@@ -118,6 +124,7 @@ module.exports = {
118124
symbol,
119125
define,
120126
copy_comments,
127+
copy_all_comments,
121128
assign_non_prop_comments,
122129

123130
assign (target, source, keys) {

0 commit comments

Comments
 (0)