aneka 0.17.5 → 0.17.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/.jsdoc.conf.json +0 -0
  2. package/CHANGES.md +87 -79
  3. package/LICENSE +21 -21
  4. package/README.md +63 -63
  5. package/docs/arrange-array.js.html +0 -0
  6. package/docs/create-class.js.html +0 -0
  7. package/docs/current-loc.js.html +0 -0
  8. package/docs/data/search.json +0 -0
  9. package/docs/defaults-deep.js.html +0 -0
  10. package/docs/delay.js.html +0 -0
  11. package/docs/extract-text.js.html +0 -0
  12. package/docs/fill-object.js.html +0 -0
  13. package/docs/filter-duplicate.js.html +0 -0
  14. package/docs/filter-index.js.html +0 -0
  15. package/docs/fonts/Inconsolata-Regular.ttf +0 -0
  16. package/docs/fonts/OpenSans-Regular.ttf +0 -0
  17. package/docs/fonts/WorkSans-Bold.ttf +0 -0
  18. package/docs/format-text.js.html +0 -0
  19. package/docs/generate-id.js.html +0 -0
  20. package/docs/get-caller-filename.js.html +0 -0
  21. package/docs/get-global-module-dir.js.html +0 -0
  22. package/docs/get-index.js.html +0 -0
  23. package/docs/get-key-by-value.js.html +0 -0
  24. package/docs/global.html +0 -0
  25. package/docs/includes.js.html +0 -0
  26. package/docs/index.html +0 -0
  27. package/docs/is-class.js.html +0 -0
  28. package/docs/is-set.js.html +0 -0
  29. package/docs/merge-objects-by-key.js.html +0 -0
  30. package/docs/paginate.js.html +0 -0
  31. package/docs/parse-args-argv.js.html +0 -0
  32. package/docs/parse-duration.js.html +0 -0
  33. package/docs/parse-env.js.html +0 -0
  34. package/docs/parse-kv-string.js.html +0 -0
  35. package/docs/parse-object.js.html +0 -0
  36. package/docs/pascal-case.js.html +0 -0
  37. package/docs/random-range.js.html +0 -0
  38. package/docs/resolve-path.js.html +0 -0
  39. package/docs/round.js.html +0 -0
  40. package/docs/scripts/core.js +0 -0
  41. package/docs/scripts/core.min.js +0 -0
  42. package/docs/scripts/resize.js +0 -0
  43. package/docs/scripts/search.js +0 -0
  44. package/docs/scripts/search.min.js +5 -5
  45. package/docs/scripts/third-party/Apache-License-2.0.txt +0 -0
  46. package/docs/scripts/third-party/fuse.js +0 -0
  47. package/docs/scripts/third-party/hljs-line-num-original.js +0 -0
  48. package/docs/scripts/third-party/hljs-line-num.js +0 -0
  49. package/docs/scripts/third-party/hljs-original.js +0 -0
  50. package/docs/scripts/third-party/hljs.js +0 -0
  51. package/docs/scripts/third-party/popper.js +0 -0
  52. package/docs/scripts/third-party/tippy.js +0 -0
  53. package/docs/scripts/third-party/tocbot.js +0 -0
  54. package/docs/scripts/third-party/tocbot.min.js +0 -0
  55. package/docs/sec-to-hms.js.html +0 -0
  56. package/docs/set-immediate.js.html +0 -0
  57. package/docs/set-interval.js.html +0 -0
  58. package/docs/set-timeout.js.html +0 -0
  59. package/docs/shim.js.html +0 -0
  60. package/docs/static/bitcoin.jpeg +0 -0
  61. package/docs/styles/clean-jsdoc-theme-base.css +0 -0
  62. package/docs/styles/clean-jsdoc-theme-dark.css +0 -0
  63. package/docs/styles/clean-jsdoc-theme-light.css +0 -0
  64. package/docs/styles/clean-jsdoc-theme-scrollbar.css +0 -0
  65. package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -0
  66. package/docs/styles/clean-jsdoc-theme.min.css +0 -0
  67. package/docs/text-to-array.js.html +0 -0
  68. package/docs/titleize.js.html +0 -0
  69. package/docs/without.js.html +0 -0
  70. package/index.js +119 -119
  71. package/package.json +48 -48
  72. package/src/arrange-array.js +25 -25
  73. package/src/create-class.js +35 -35
  74. package/src/current-loc.js +0 -0
  75. package/src/defaults-deep.js +20 -20
  76. package/src/delay.js +19 -19
  77. package/src/extract-text.js +23 -23
  78. package/src/fill-object.js +17 -17
  79. package/src/filter-duplicate.js +26 -26
  80. package/src/filter-index.js +17 -17
  81. package/src/format-text.js +88 -88
  82. package/src/generate-id.js +35 -35
  83. package/src/get-caller-filename.js +25 -25
  84. package/src/get-global-module-dir.js +24 -20
  85. package/src/get-index.js +15 -15
  86. package/src/get-key-by-value.js +12 -12
  87. package/src/includes.js +18 -18
  88. package/src/is-class.js +13 -13
  89. package/src/is-set.js +11 -11
  90. package/src/log.js +19 -19
  91. package/src/merge-objects-by-key.js +24 -24
  92. package/src/paginate.js +45 -45
  93. package/src/parse-args-argv.js +0 -0
  94. package/src/parse-duration.js +14 -14
  95. package/src/parse-env.js +0 -0
  96. package/src/parse-kv-string.js +21 -21
  97. package/src/parse-object.js +76 -76
  98. package/src/pascal-case.js +14 -14
  99. package/src/random-range.js +15 -15
  100. package/src/resolve-path.js +0 -0
  101. package/src/round.js +13 -13
  102. package/src/sec-to-hms.js +27 -27
  103. package/src/set-immediate.js +12 -12
  104. package/src/set-interval.js +56 -55
  105. package/src/set-timeout.js +34 -34
  106. package/src/shim.js +28 -28
  107. package/src/text-to-array.js +17 -17
  108. package/src/titleize.js +37 -37
  109. package/src/without.js +18 -18
  110. package/test/arrange-array.js +41 -41
  111. package/test/create-class.js +33 -33
  112. package/test/current-loc.js +24 -24
  113. package/test/defaults-deep.js +19 -19
  114. package/test/delay.js +17 -17
  115. package/test/extract-text.js +17 -17
  116. package/test/fill-object.js +17 -17
  117. package/test/filter-duplicate.js +19 -19
  118. package/test/filter-index.js +17 -17
  119. package/test/format-text.js +26 -26
  120. package/test/generate-id.js +28 -28
  121. package/test/get-caller-filename.js +22 -22
  122. package/test/get-global-module-dir.js +51 -51
  123. package/test/get-index.js +17 -17
  124. package/test/get-key-by-value.js +17 -17
  125. package/test/includes.js +18 -18
  126. package/test/is-class.js +19 -19
  127. package/test/is-set.js +21 -21
  128. package/test/log.js +47 -47
  129. package/test/merge-objects-by-key.js +19 -19
  130. package/test/paginate.js +24 -24
  131. package/test/parse-args-argv.js +63 -63
  132. package/test/parse-duration.js +18 -18
  133. package/test/parse-env.js +35 -35
  134. package/test/parse-kv-string.js +17 -17
  135. package/test/parse-object.js +30 -30
  136. package/test/pascal-case.js +18 -18
  137. package/test/random-range.js +21 -21
  138. package/test/resolve-path.js +22 -22
  139. package/test/round.js +19 -19
  140. package/test/sec-to-hms.js +18 -18
  141. package/test/set-immediate.js +17 -17
  142. package/test/set-interval.js +196 -180
  143. package/test/set-timeout.js +120 -120
  144. package/test/shim.js +34 -34
  145. package/test/text-to-array.js +18 -18
  146. package/test/titleize.js +27 -27
  147. package/test/without.js +17 -17
@@ -1,34 +1,34 @@
1
- import lockfile from '@bybrave/proper-lockfile2'
2
- import delay from './delay.js'
3
-
4
- /**
5
- * Like original setTimeout, but executes a function after a specified delay asynchronously.
6
- * Optionally using a lock file.
7
- *
8
- * @param {Function} handler The function to execute after the timeout.
9
- * @param {number|string} timeout The delay in milliseconds or a duration string.
10
- * @param {Object} [options={}] Additional options.
11
- * @param {string} [options.lockFile] The path to the lock file. If set, the handler will only execute if the lock can be acquired.
12
- * @param {Array} [options.args=[]] Arguments to pass to the handler.
13
- * @param {Object} [options.lockFileOpts] Options for the lock file.
14
- * @param {boolean} [options.silent=true] If true, errors during lock acquisition will be ignored.
15
- * @param {Object} [options.scope] The scope to bind the handler to.
16
- * @returns {Promise<void>} Promise resolved after the delay.
17
- */
18
- async function setTimeout (handler, timeout, options = {}) {
19
- const { lockFile, args = [], lockFileOpts, silent = true, scope } = options
20
- await delay(timeout)
21
- if (!lockFile) {
22
- await handler.call(scope, ...args)
23
- return
24
- }
25
- try {
26
- const release = await lockfile.lock(lockFile, lockFileOpts)
27
- await handler.call(scope, ...args)
28
- await release()
29
- } catch (err) {
30
- if (!silent) throw err
31
- }
32
- }
33
-
34
- export default setTimeout
1
+ import lockfile from '@bybrave/proper-lockfile2'
2
+ import delay from './delay.js'
3
+
4
+ /**
5
+ * Like original setTimeout, but executes a function after a specified delay asynchronously.
6
+ * Optionally using a lock file.
7
+ *
8
+ * @param {Function} handler The function to execute after the timeout.
9
+ * @param {number|string} timeout The delay in milliseconds or a duration string.
10
+ * @param {Object} [options={}] Additional options.
11
+ * @param {string} [options.lockFile] The path to the lock file. If set, the handler will only execute if the lock can be acquired.
12
+ * @param {Array} [options.args=[]] Arguments to pass to the handler.
13
+ * @param {Object} [options.lockFileOpts] Options for the lock file.
14
+ * @param {boolean} [options.silent=true] If true, errors during lock acquisition will be ignored.
15
+ * @param {Object} [options.scope] The scope to bind the handler to.
16
+ * @returns {Promise<void>} Promise resolved after the delay.
17
+ */
18
+ async function setTimeout (handler, timeout, options = {}) {
19
+ const { lockFile, args = [], lockFileOpts, silent = true, scope } = options
20
+ await delay(timeout)
21
+ if (!lockFile) {
22
+ await handler.call(scope, ...args)
23
+ return
24
+ }
25
+ try {
26
+ const release = await lockfile.lock(lockFile, lockFileOpts)
27
+ await handler.call(scope, ...args)
28
+ await release()
29
+ } catch (err) {
30
+ if (!silent) throw err
31
+ }
32
+ }
33
+
34
+ export default setTimeout
package/src/shim.js CHANGED
@@ -1,28 +1,28 @@
1
- /**
2
- * Attaches missing String polyfills when they are not available in the current runtime.
3
- * Adds `String.prototype.replaceAll` and `String.prototype.splice` if needed.
4
- *
5
- * @returns {void}
6
- */
7
- function shim () {
8
- // taken from: https://vanillajstoolkit.com/polyfills/stringreplaceall/
9
- if (!String.prototype.replaceAll) {
10
- String.prototype.replaceAll = function(str, newStr) { // eslint-disable-line
11
- if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {
12
- return this.replace(str, newStr)
13
- }
14
- return this.replace(new RegExp(str, 'g'), newStr)
15
- }
16
- }
17
- if (!String.prototype.splice) {
18
- String.prototype.splice = function(index, count, add) { // eslint-disable-line
19
- if (index < 0) {
20
- index += this.length
21
- if (index < 0) index = 0
22
- }
23
- return this.slice(0, index) + (add || '') + this.slice(index + count)
24
- }
25
- }
26
- }
27
-
28
- export default shim
1
+ /**
2
+ * Attaches missing String polyfills when they are not available in the current runtime.
3
+ * Adds `String.prototype.replaceAll` and `String.prototype.splice` if needed.
4
+ *
5
+ * @returns {void}
6
+ */
7
+ function shim () {
8
+ // taken from: https://vanillajstoolkit.com/polyfills/stringreplaceall/
9
+ if (!String.prototype.replaceAll) {
10
+ String.prototype.replaceAll = function(str, newStr) { // eslint-disable-line
11
+ if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {
12
+ return this.replace(str, newStr)
13
+ }
14
+ return this.replace(new RegExp(str, 'g'), newStr)
15
+ }
16
+ }
17
+ if (!String.prototype.splice) {
18
+ String.prototype.splice = function(index, count, add) { // eslint-disable-line
19
+ if (index < 0) {
20
+ index += this.length
21
+ if (index < 0) index = 0
22
+ }
23
+ return this.slice(0, index) + (add || '') + this.slice(index + count)
24
+ }
25
+ }
26
+ }
27
+
28
+ export default shim
@@ -1,17 +1,17 @@
1
- import isEmpty from 'lodash-es/isEmpty.js'
2
-
3
- /**
4
- * Converts multiline text into a cleaned array and removes comments.
5
- *
6
- * @param {string} text Input text.
7
- * @returns {Array<string>} Cleaned lines.
8
- */
9
- function textToArray (text) {
10
- const lines = text.trim().split('\n').map(line => line.trim())
11
- return lines.filter(c => {
12
- const line = c.split('#')[0].trim()
13
- return !isEmpty(line)
14
- })
15
- }
16
-
17
- export default textToArray
1
+ import isEmpty from 'lodash-es/isEmpty.js'
2
+
3
+ /**
4
+ * Converts multiline text into a cleaned array and removes comments.
5
+ *
6
+ * @param {string} text Input text.
7
+ * @returns {Array<string>} Cleaned lines.
8
+ */
9
+ function textToArray (text) {
10
+ const lines = text.trim().split('\n').map(line => line.trim())
11
+ return lines.filter(c => {
12
+ const line = c.split('#')[0].trim()
13
+ return !isEmpty(line)
14
+ })
15
+ }
16
+
17
+ export default textToArray
package/src/titleize.js CHANGED
@@ -1,37 +1,37 @@
1
- import forOwn from 'lodash-es/forOwn.js'
2
- import map from 'lodash-es/map.js'
3
- import words from 'lodash-es/words.js'
4
- import uniq from 'lodash-es/uniq.js'
5
- import concat from 'lodash-es/concat.js'
6
- import upperFirst from 'lodash-es/upperFirst.js'
7
- import generateId from './generate-id.js'
8
-
9
- /**
10
- * Converts text to title case with optional ignore and replacement rules.
11
- *
12
- * @param {string} [text=''] Source text.
13
- * @param {Object} [options={}] Transformation options.
14
- * @param {Array<string>} [options.ignores=[]] Words that should remain unchanged.
15
- * @param {Object<string, string>} [options.replacement={}] Exact token replacements.
16
- * @returns {string} Titleized text.
17
- */
18
- function titleize (text = '', options = {}) {
19
- let { ignores = [], replacement = {} } = options
20
- const defIgnores = ['or', 'and', 'of', 'with']
21
- const replacer = {}
22
- forOwn(replacement, (v, k) => {
23
- const id = generateId()
24
- replacer[id] = k
25
- text = text.replace(k, ` ${id} `)
26
- })
27
- return map(words(text), t => {
28
- forOwn(replacer, (v, k) => {
29
- if (k === t) t = replacement[replacer[k]]
30
- })
31
- ignores = uniq(concat(ignores, defIgnores))
32
- if (ignores.includes(t)) return t
33
- return upperFirst(t)
34
- }).join(' ')
35
- }
36
-
37
- export default titleize
1
+ import forOwn from 'lodash-es/forOwn.js'
2
+ import map from 'lodash-es/map.js'
3
+ import words from 'lodash-es/words.js'
4
+ import uniq from 'lodash-es/uniq.js'
5
+ import concat from 'lodash-es/concat.js'
6
+ import upperFirst from 'lodash-es/upperFirst.js'
7
+ import generateId from './generate-id.js'
8
+
9
+ /**
10
+ * Converts text to title case with optional ignore and replacement rules.
11
+ *
12
+ * @param {string} [text=''] Source text.
13
+ * @param {Object} [options={}] Transformation options.
14
+ * @param {Array<string>} [options.ignores=[]] Words that should remain unchanged.
15
+ * @param {Object<string, string>} [options.replacement={}] Exact token replacements.
16
+ * @returns {string} Titleized text.
17
+ */
18
+ function titleize (text = '', options = {}) {
19
+ let { ignores = [], replacement = {} } = options
20
+ const defIgnores = ['or', 'and', 'of', 'with']
21
+ const replacer = {}
22
+ forOwn(replacement, (v, k) => {
23
+ const id = generateId()
24
+ replacer[id] = k
25
+ text = text.replace(k, ` ${id} `)
26
+ })
27
+ return map(words(text), t => {
28
+ forOwn(replacer, (v, k) => {
29
+ if (k === t) t = replacement[replacer[k]]
30
+ })
31
+ ignores = uniq(concat(ignores, defIgnores))
32
+ if (ignores.includes(t)) return t
33
+ return upperFirst(t)
34
+ }).join(' ')
35
+ }
36
+
37
+ export default titleize
package/src/without.js CHANGED
@@ -1,18 +1,18 @@
1
- import w from 'lodash-es/without.js'
2
-
3
- /**
4
- * Returns an array without provided values and empty-like entries.
5
- *
6
- * @param {Array<any>} [arr=[]] Source array.
7
- * @param {...any} params Values to exclude.
8
- * @returns {Array<any>} Filtered array.
9
- * @example
10
- * without([1, 2, null, '', 3, 2], 2)
11
- * // => [1, 3]
12
- */
13
- function without (arr = [], ...params) {
14
- params.push(null, undefined, '')
15
- return w(arr, ...params)
16
- }
17
-
18
- export default without
1
+ import w from 'lodash-es/without.js'
2
+
3
+ /**
4
+ * Returns an array without provided values and empty-like entries.
5
+ *
6
+ * @param {Array<any>} [arr=[]] Source array.
7
+ * @param {...any} params Values to exclude.
8
+ * @returns {Array<any>} Filtered array.
9
+ * @example
10
+ * without([1, 2, null, '', 3, 2], 2)
11
+ * // => [1, 3]
12
+ */
13
+ function without (arr = [], ...params) {
14
+ params.push(null, undefined, '')
15
+ return w(arr, ...params)
16
+ }
17
+
18
+ export default without
@@ -1,41 +1,41 @@
1
- /* eslint-env mocha */
2
- import { expect } from 'chai'
3
- import fn from '../src/arrange-array.js'
4
-
5
- describe('arrangeArray', function () {
6
- it('returns items in original order when no prefix markers are used', function () {
7
- expect(fn(['a', 'b', 'c'])).to.deep.equal(['a', 'b', 'c'])
8
- })
9
-
10
- it('moves ^ prefixed items to the front', function () {
11
- expect(fn(['a', '^b', 'c'])).to.deep.equal(['b', 'a', 'c'])
12
- })
13
-
14
- it('moves $ prefixed items to the end', function () {
15
- expect(fn(['a', '$b', 'c'])).to.deep.equal(['a', 'c', 'b'])
16
- })
17
-
18
- it('handles both ^ and $ prefixed items in the same array', function () {
19
- expect(fn(['a', '^b', '$c', 'd'])).to.deep.equal(['b', 'a', 'd', 'c'])
20
- })
21
-
22
- it('preserves order of multiple ^ prefixed items', function () {
23
- expect(fn(['^a', '^b', 'c'])).to.deep.equal(['a', 'b', 'c'])
24
- })
25
-
26
- it('preserves order of multiple $ prefixed items', function () {
27
- expect(fn(['a', '$b', '$c'])).to.deep.equal(['a', 'b', 'c'])
28
- })
29
-
30
- it('trims items to detect prefix markers but returns original values for non-prefix items', function () {
31
- expect(fn([' a ', ' ^b ', ' c '])).to.deep.equal(['b', ' a ', ' c '])
32
- })
33
-
34
- it('does not detect prefix when trimItem is false and item has leading whitespace', function () {
35
- expect(fn([' a ', ' ^b '], false)).to.deep.equal([' a ', ' ^b '])
36
- })
37
-
38
- it('returns an empty array for empty input', function () {
39
- expect(fn([])).to.deep.equal([])
40
- })
41
- })
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/arrange-array.js'
4
+
5
+ describe('arrangeArray', function () {
6
+ it('returns items in original order when no prefix markers are used', function () {
7
+ expect(fn(['a', 'b', 'c'])).to.deep.equal(['a', 'b', 'c'])
8
+ })
9
+
10
+ it('moves ^ prefixed items to the front', function () {
11
+ expect(fn(['a', '^b', 'c'])).to.deep.equal(['b', 'a', 'c'])
12
+ })
13
+
14
+ it('moves $ prefixed items to the end', function () {
15
+ expect(fn(['a', '$b', 'c'])).to.deep.equal(['a', 'c', 'b'])
16
+ })
17
+
18
+ it('handles both ^ and $ prefixed items in the same array', function () {
19
+ expect(fn(['a', '^b', '$c', 'd'])).to.deep.equal(['b', 'a', 'd', 'c'])
20
+ })
21
+
22
+ it('preserves order of multiple ^ prefixed items', function () {
23
+ expect(fn(['^a', '^b', 'c'])).to.deep.equal(['a', 'b', 'c'])
24
+ })
25
+
26
+ it('preserves order of multiple $ prefixed items', function () {
27
+ expect(fn(['a', '$b', '$c'])).to.deep.equal(['a', 'b', 'c'])
28
+ })
29
+
30
+ it('trims items to detect prefix markers but returns original values for non-prefix items', function () {
31
+ expect(fn([' a ', ' ^b ', ' c '])).to.deep.equal(['b', ' a ', ' c '])
32
+ })
33
+
34
+ it('does not detect prefix when trimItem is false and item has leading whitespace', function () {
35
+ expect(fn([' a ', ' ^b '], false)).to.deep.equal([' a ', ' ^b '])
36
+ })
37
+
38
+ it('returns an empty array for empty input', function () {
39
+ expect(fn([])).to.deep.equal([])
40
+ })
41
+ })
@@ -1,33 +1,33 @@
1
- /* eslint-env mocha */
2
- import { expect } from 'chai'
3
- import fn from '../src/create-class.js'
4
-
5
- describe('createClass', function () {
6
- it('creates class with defaults and parent support', function () {
7
- const A = fn('A', { a: 1 })
8
- const a = new A({ b: 2 })
9
- expect(a).to.include({ a: 1, b: 2 })
10
-
11
- class Parent {
12
- constructor (options = {}) {
13
- this.p = options.p
14
- }
15
- }
16
-
17
- const B = fn('B', { x: true }, Parent)
18
- const b = new B({ p: 7, y: 'ok' })
19
- expect(b).to.include({ p: 7, x: true, y: 'ok' })
20
- })
21
-
22
- it('applies only default properties when no options passed', function () {
23
- const A = fn('A', { a: 1, b: 2 })
24
- const a = new A()
25
- expect(a).to.include({ a: 1, b: 2 })
26
- })
27
-
28
- it('lets option values override defaults', function () {
29
- const A = fn('A', { a: 1 })
30
- const a = new A({ a: 9 })
31
- expect(a.a).to.equal(9)
32
- })
33
- })
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/create-class.js'
4
+
5
+ describe('createClass', function () {
6
+ it('creates class with defaults and parent support', function () {
7
+ const A = fn('A', { a: 1 })
8
+ const a = new A({ b: 2 })
9
+ expect(a).to.include({ a: 1, b: 2 })
10
+
11
+ class Parent {
12
+ constructor (options = {}) {
13
+ this.p = options.p
14
+ }
15
+ }
16
+
17
+ const B = fn('B', { x: true }, Parent)
18
+ const b = new B({ p: 7, y: 'ok' })
19
+ expect(b).to.include({ p: 7, x: true, y: 'ok' })
20
+ })
21
+
22
+ it('applies only default properties when no options passed', function () {
23
+ const A = fn('A', { a: 1, b: 2 })
24
+ const a = new A()
25
+ expect(a).to.include({ a: 1, b: 2 })
26
+ })
27
+
28
+ it('lets option values override defaults', function () {
29
+ const A = fn('A', { a: 1 })
30
+ const a = new A({ a: 9 })
31
+ expect(a.a).to.equal(9)
32
+ })
33
+ })
@@ -1,24 +1,24 @@
1
- /* eslint-env mocha */
2
- import { expect } from 'chai'
3
- import path from 'path'
4
- import fn from '../src/current-loc.js'
5
-
6
- describe('currentLoc', function () {
7
- it('returns directory and filename aliases', function () {
8
- const info = fn(import.meta)
9
- expect(info).to.have.keys(['dir', 'file', '__dirname', '__filename'])
10
- expect(path.basename(info.dir)).to.equal('test')
11
- expect(info.file).to.include('/test/current-loc.js')
12
- })
13
-
14
- it('keeps alias values in sync', function () {
15
- const info = fn(import.meta)
16
- expect(info.dir).to.equal(info.__dirname)
17
- expect(info.file).to.equal(info.__filename)
18
- })
19
-
20
- it('returns absolute file path', function () {
21
- const info = fn(import.meta)
22
- expect(path.isAbsolute(info.file)).to.equal(true)
23
- })
24
- })
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import path from 'path'
4
+ import fn from '../src/current-loc.js'
5
+
6
+ describe('currentLoc', function () {
7
+ it('returns directory and filename aliases', function () {
8
+ const info = fn(import.meta)
9
+ expect(info).to.have.keys(['dir', 'file', '__dirname', '__filename'])
10
+ expect(path.basename(info.dir)).to.equal('test')
11
+ expect(info.file).to.include('/test/current-loc.js')
12
+ })
13
+
14
+ it('keeps alias values in sync', function () {
15
+ const info = fn(import.meta)
16
+ expect(info.dir).to.equal(info.__dirname)
17
+ expect(info.file).to.equal(info.__filename)
18
+ })
19
+
20
+ it('returns absolute file path', function () {
21
+ const info = fn(import.meta)
22
+ expect(path.isAbsolute(info.file)).to.equal(true)
23
+ })
24
+ })
@@ -1,19 +1,19 @@
1
- /* eslint-env mocha */
2
- import { expect } from 'chai'
3
- import fn from '../src/defaults-deep.js'
4
-
5
- describe('defaultsDeep', function () {
6
- it('deep merges objects and replaces arrays by first argument priority', function () {
7
- const out = fn({ a: { b: 1 }, arr: [1] }, { a: { c: 2 }, arr: [2, 3] })
8
- expect(out).to.deep.equal({ a: { b: 1, c: 2 }, arr: [1] })
9
- })
10
-
11
- it('returns empty object when no args are given', function () {
12
- expect(fn()).to.deep.equal({})
13
- })
14
-
15
- it('merges more than two objects', function () {
16
- const out = fn({ a: 1 }, { b: 2 }, { c: 3 })
17
- expect(out).to.deep.equal({ a: 1, b: 2, c: 3 })
18
- })
19
- })
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/defaults-deep.js'
4
+
5
+ describe('defaultsDeep', function () {
6
+ it('deep merges objects and replaces arrays by first argument priority', function () {
7
+ const out = fn({ a: { b: 1 }, arr: [1] }, { a: { c: 2 }, arr: [2, 3] })
8
+ expect(out).to.deep.equal({ a: { b: 1, c: 2 }, arr: [1] })
9
+ })
10
+
11
+ it('returns empty object when no args are given', function () {
12
+ expect(fn()).to.deep.equal({})
13
+ })
14
+
15
+ it('merges more than two objects', function () {
16
+ const out = fn({ a: 1 }, { b: 2 }, { c: 3 })
17
+ expect(out).to.deep.equal({ a: 1, b: 2, c: 3 })
18
+ })
19
+ })
package/test/delay.js CHANGED
@@ -1,17 +1,17 @@
1
- /* eslint-env mocha */
2
- import { expect } from 'chai'
3
- import fn from '../src/delay.js'
4
-
5
- describe('delay', function () {
6
- it('resolves after timeout', async function () {
7
- await fn(1)
8
- })
9
-
10
- it('returns a promise', function () {
11
- expect(fn(1)).to.be.an.instanceof(Promise)
12
- })
13
-
14
- it('works with default timeout argument', async function () {
15
- await fn()
16
- })
17
- })
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/delay.js'
4
+
5
+ describe('delay', function () {
6
+ it('resolves after timeout', async function () {
7
+ await fn(1)
8
+ })
9
+
10
+ it('returns a promise', function () {
11
+ expect(fn(1)).to.be.an.instanceof(Promise)
12
+ })
13
+
14
+ it('works with default timeout argument', async function () {
15
+ await fn()
16
+ })
17
+ })
@@ -1,17 +1,17 @@
1
- /* eslint-env mocha */
2
- import { expect } from 'chai'
3
- import fn from '../src/extract-text.js'
4
-
5
- describe('extractText', function () {
6
- it('extracts text between markers', function () {
7
- expect(fn('a [x] b', '[', ']')).to.deep.equal({ result: 'x', pattern: '[x]' })
8
- })
9
-
10
- it('returns empty result when start marker is missing', function () {
11
- expect(fn('a x b', '[', ']')).to.deep.equal({ result: '', pattern: '[]' })
12
- })
13
-
14
- it('returns empty result when end marker is missing', function () {
15
- expect(fn('a [x b', '[', ']')).to.deep.equal({ result: '', pattern: '[]' })
16
- })
17
- })
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/extract-text.js'
4
+
5
+ describe('extractText', function () {
6
+ it('extracts text between markers', function () {
7
+ expect(fn('a [x] b', '[', ']')).to.deep.equal({ result: 'x', pattern: '[x]' })
8
+ })
9
+
10
+ it('returns empty result when start marker is missing', function () {
11
+ expect(fn('a x b', '[', ']')).to.deep.equal({ result: '', pattern: '[]' })
12
+ })
13
+
14
+ it('returns empty result when end marker is missing', function () {
15
+ expect(fn('a [x b', '[', ']')).to.deep.equal({ result: '', pattern: '[]' })
16
+ })
17
+ })
@@ -1,17 +1,17 @@
1
- /* eslint-env mocha */
2
- import { expect } from 'chai'
3
- import fn from '../src/fill-object.js'
4
-
5
- describe('fillObject', function () {
6
- it('fills requested keys with default values', function () {
7
- expect(fn({ a: 1 }, ['a', 'b'], 0)).to.deep.equal({ a: 1, b: 0 })
8
- })
9
-
10
- it('treats null and undefined as missing values', function () {
11
- expect(fn({ a: null, b: undefined }, ['a', 'b'], 'x')).to.deep.equal({ a: 'x', b: 'x' })
12
- })
13
-
14
- it('returns empty object when key list is empty', function () {
15
- expect(fn({ a: 1 }, [], 0)).to.deep.equal({})
16
- })
17
- })
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/fill-object.js'
4
+
5
+ describe('fillObject', function () {
6
+ it('fills requested keys with default values', function () {
7
+ expect(fn({ a: 1 }, ['a', 'b'], 0)).to.deep.equal({ a: 1, b: 0 })
8
+ })
9
+
10
+ it('treats null and undefined as missing values', function () {
11
+ expect(fn({ a: null, b: undefined }, ['a', 'b'], 'x')).to.deep.equal({ a: 'x', b: 'x' })
12
+ })
13
+
14
+ it('returns empty object when key list is empty', function () {
15
+ expect(fn({ a: 1 }, [], 0)).to.deep.equal({})
16
+ })
17
+ })