@jdeighan/coffee-utils 13.0.16 → 14.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +4 -4
- package/src/DataStores.coffee +2 -2
- package/src/DataStores.js +7 -7
- package/src/KeyedSet.coffee +8 -6
- package/src/KeyedSet.js +20 -14
- package/src/Section.coffee +3 -4
- package/src/Section.js +3 -6
- package/src/SectionMap.coffee +8 -6
- package/src/SectionMap.js +15 -9
- package/src/block.coffee +8 -13
- package/src/block.js +11 -20
- package/src/browser.coffee +1 -1
- package/src/browser.js +1 -1
- package/src/{utils.coffee → coffee-utils.coffee} +7 -31
- package/src/{utils.js → coffee-utils.js} +4 -66
- package/src/fs.coffee +8 -7
- package/src/fs.js +23 -19
- package/src/fsa.coffee +3 -4
- package/src/fsa.js +3 -6
- package/src/html.coffee +3 -4
- package/src/html.js +4 -7
- package/src/indent.coffee +3 -4
- package/src/indent.js +4 -7
- package/src/svelte.coffee +2 -2
- package/src/svelte.js +2 -2
package/package.json
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jdeighan/coffee-utils",
|
3
3
|
"type": "module",
|
4
|
-
"version": "
|
4
|
+
"version": "14.0.1",
|
5
5
|
"description": "A set of utility functions for CoffeeScript",
|
6
6
|
"main": "coffee_utils.js",
|
7
7
|
"exports": {
|
8
|
-
".": "./src/utils.js",
|
8
|
+
".": "./src/coffee-utils.js",
|
9
9
|
"./server": "./src/server.js",
|
10
10
|
"./browser": "./src/browser.js",
|
11
11
|
"./fs": "./src/fs.js",
|
@@ -50,13 +50,13 @@
|
|
50
50
|
},
|
51
51
|
"homepage": "https://github.com/johndeighan/coffee-utils#readme",
|
52
52
|
"dependencies": {
|
53
|
-
"@jdeighan/base-utils": "^
|
53
|
+
"@jdeighan/base-utils": "^3.0.3",
|
54
54
|
"cross-env": "^7.0.3",
|
55
55
|
"n-readlines": "^1.0.1",
|
56
56
|
"readline-sync": "^1.4.10",
|
57
57
|
"svelte": "^3.55.0"
|
58
58
|
},
|
59
59
|
"devDependencies": {
|
60
|
-
"@jdeighan/unit-tester": "^3.0.
|
60
|
+
"@jdeighan/unit-tester": "^3.0.16"
|
61
61
|
}
|
62
62
|
}
|
package/src/DataStores.coffee
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
import pathlib from 'path'
|
4
4
|
import {writable, readable, get} from 'svelte/store'
|
5
5
|
|
6
|
-
import {
|
6
|
+
import {undef, pass, range} from '@jdeighan/base-utils'
|
7
|
+
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
7
8
|
import {fromTAML} from '@jdeighan/base-utils/taml'
|
8
|
-
import {undef, pass, range} from '@jdeighan/coffee-utils'
|
9
9
|
import {localStore} from '@jdeighan/coffee-utils/browser'
|
10
10
|
import {
|
11
11
|
withExt, slurp, barf, newerDestFileExists,
|
package/src/DataStores.js
CHANGED
@@ -8,21 +8,21 @@ import {
|
|
8
8
|
get
|
9
9
|
} from 'svelte/store';
|
10
10
|
|
11
|
+
import {
|
12
|
+
undef,
|
13
|
+
pass,
|
14
|
+
range
|
15
|
+
} from '@jdeighan/base-utils';
|
16
|
+
|
11
17
|
import {
|
12
18
|
assert,
|
13
19
|
croak
|
14
|
-
} from '@jdeighan/base-utils';
|
20
|
+
} from '@jdeighan/base-utils/exceptions';
|
15
21
|
|
16
22
|
import {
|
17
23
|
fromTAML
|
18
24
|
} from '@jdeighan/base-utils/taml';
|
19
25
|
|
20
|
-
import {
|
21
|
-
undef,
|
22
|
-
pass,
|
23
|
-
range
|
24
|
-
} from '@jdeighan/coffee-utils';
|
25
|
-
|
26
26
|
import {
|
27
27
|
localStore
|
28
28
|
} from '@jdeighan/coffee-utils/browser';
|
package/src/KeyedSet.coffee
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
# KeyedSet.coffee
|
2
2
|
|
3
|
-
import {assert, croak, LOG, LOGVALUE} from '@jdeighan/base-utils'
|
4
|
-
import {
|
5
|
-
dbgEnter, dbgReturn, dbg,
|
6
|
-
} from '@jdeighan/base-utils/debug'
|
7
3
|
import {
|
8
4
|
undef, defined, notdefined, OL, deepCopy,
|
9
|
-
isString, isNonEmptyString, isArray, isHash,
|
5
|
+
isString, isNonEmptyString, isArray, isHash,
|
10
6
|
isEmpty, nonEmpty,
|
11
|
-
} from '@jdeighan/
|
7
|
+
} from '@jdeighan/base-utils'
|
8
|
+
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
9
|
+
import {LOG, LOGVALUE} from '@jdeighan/base-utils/log'
|
10
|
+
import {
|
11
|
+
dbgEnter, dbgReturn, dbg,
|
12
|
+
} from '@jdeighan/base-utils/debug'
|
13
|
+
import {isArrayOfStrings} from '@jdeighan/coffee-utils'
|
12
14
|
|
13
15
|
# ---------------------------------------------------------------------------
|
14
16
|
|
package/src/KeyedSet.js
CHANGED
@@ -1,18 +1,5 @@
|
|
1
1
|
// Generated by CoffeeScript 2.7.0
|
2
2
|
// KeyedSet.coffee
|
3
|
-
import {
|
4
|
-
assert,
|
5
|
-
croak,
|
6
|
-
LOG,
|
7
|
-
LOGVALUE
|
8
|
-
} from '@jdeighan/base-utils';
|
9
|
-
|
10
|
-
import {
|
11
|
-
dbgEnter,
|
12
|
-
dbgReturn,
|
13
|
-
dbg
|
14
|
-
} from '@jdeighan/base-utils/debug';
|
15
|
-
|
16
3
|
import {
|
17
4
|
undef,
|
18
5
|
defined,
|
@@ -23,9 +10,28 @@ import {
|
|
23
10
|
isNonEmptyString,
|
24
11
|
isArray,
|
25
12
|
isHash,
|
26
|
-
isArrayOfStrings,
|
27
13
|
isEmpty,
|
28
14
|
nonEmpty
|
15
|
+
} from '@jdeighan/base-utils';
|
16
|
+
|
17
|
+
import {
|
18
|
+
assert,
|
19
|
+
croak
|
20
|
+
} from '@jdeighan/base-utils/exceptions';
|
21
|
+
|
22
|
+
import {
|
23
|
+
LOG,
|
24
|
+
LOGVALUE
|
25
|
+
} from '@jdeighan/base-utils/log';
|
26
|
+
|
27
|
+
import {
|
28
|
+
dbgEnter,
|
29
|
+
dbgReturn,
|
30
|
+
dbg
|
31
|
+
} from '@jdeighan/base-utils/debug';
|
32
|
+
|
33
|
+
import {
|
34
|
+
isArrayOfStrings
|
29
35
|
} from '@jdeighan/coffee-utils';
|
30
36
|
|
31
37
|
// ---------------------------------------------------------------------------
|
package/src/Section.coffee
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# Section.coffee
|
2
2
|
|
3
|
-
import {assert, croak} from '@jdeighan/base-utils'
|
3
|
+
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
4
4
|
import {dbg, dbgEnter, dbgReturn} from '@jdeighan/base-utils/debug'
|
5
5
|
import {
|
6
|
-
pass, undef, defined, isArray, isEmpty, isFunction,
|
7
|
-
} from '@jdeighan/
|
8
|
-
import {toBlock} from '@jdeighan/coffee-utils/block'
|
6
|
+
pass, undef, defined, isArray, isEmpty, isFunction, toBlock,
|
7
|
+
} from '@jdeighan/base-utils'
|
9
8
|
|
10
9
|
# ---------------------------------------------------------------------------
|
11
10
|
|
package/src/Section.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
import {
|
4
4
|
assert,
|
5
5
|
croak
|
6
|
-
} from '@jdeighan/base-utils';
|
6
|
+
} from '@jdeighan/base-utils/exceptions';
|
7
7
|
|
8
8
|
import {
|
9
9
|
dbg,
|
@@ -17,12 +17,9 @@ import {
|
|
17
17
|
defined,
|
18
18
|
isArray,
|
19
19
|
isEmpty,
|
20
|
-
isFunction
|
21
|
-
} from '@jdeighan/coffee-utils';
|
22
|
-
|
23
|
-
import {
|
20
|
+
isFunction,
|
24
21
|
toBlock
|
25
|
-
} from '@jdeighan/
|
22
|
+
} from '@jdeighan/base-utils';
|
26
23
|
|
27
24
|
// ---------------------------------------------------------------------------
|
28
25
|
export var Section = class Section {
|
package/src/SectionMap.coffee
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
# SectionMap.coffee
|
2
2
|
|
3
|
-
import {
|
4
|
-
|
5
|
-
|
3
|
+
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
4
|
+
import {LOG, LOGVALUE, LOGTAML} from '@jdeighan/base-utils/log'
|
5
|
+
import {isTAML, fromTAML} from '@jdeighan/base-utils/taml'
|
6
6
|
import {
|
7
7
|
dbg, dbgEnter, dbgReturn, dbgYield, dbgResume,
|
8
8
|
} from '@jdeighan/base-utils/debug'
|
9
9
|
import {
|
10
10
|
pass, undef, defined, notdefined, OL, isEmpty, nonEmpty,
|
11
|
-
isString, isHash, isArray,
|
12
|
-
|
11
|
+
isString, isHash, isArray, isNonEmptyString,
|
12
|
+
isFunction, jsType, toBlock,
|
13
|
+
} from '@jdeighan/base-utils'
|
14
|
+
import {
|
15
|
+
isArrayOfStrings, isNonEmptyArray, isUniqueTree,
|
13
16
|
} from '@jdeighan/coffee-utils'
|
14
|
-
import {toBlock} from '@jdeighan/coffee-utils/block'
|
15
17
|
import {Section} from '@jdeighan/coffee-utils/section'
|
16
18
|
|
17
19
|
# ---------------------------------------------------------------------------
|
package/src/SectionMap.js
CHANGED
@@ -4,13 +4,19 @@ var isSectionName, isSetName;
|
|
4
4
|
|
5
5
|
import {
|
6
6
|
assert,
|
7
|
-
croak
|
7
|
+
croak
|
8
|
+
} from '@jdeighan/base-utils/exceptions';
|
9
|
+
|
10
|
+
import {
|
8
11
|
LOG,
|
9
12
|
LOGVALUE,
|
10
|
-
LOGTAML
|
13
|
+
LOGTAML
|
14
|
+
} from '@jdeighan/base-utils/log';
|
15
|
+
|
16
|
+
import {
|
11
17
|
isTAML,
|
12
18
|
fromTAML
|
13
|
-
} from '@jdeighan/base-utils';
|
19
|
+
} from '@jdeighan/base-utils/taml';
|
14
20
|
|
15
21
|
import {
|
16
22
|
dbg,
|
@@ -31,17 +37,17 @@ import {
|
|
31
37
|
isString,
|
32
38
|
isHash,
|
33
39
|
isArray,
|
34
|
-
isUniqueTree,
|
35
40
|
isNonEmptyString,
|
36
|
-
isNonEmptyArray,
|
37
41
|
isFunction,
|
38
42
|
jsType,
|
39
|
-
|
40
|
-
} from '@jdeighan/
|
43
|
+
toBlock
|
44
|
+
} from '@jdeighan/base-utils';
|
41
45
|
|
42
46
|
import {
|
43
|
-
|
44
|
-
|
47
|
+
isArrayOfStrings,
|
48
|
+
isNonEmptyArray,
|
49
|
+
isUniqueTree
|
50
|
+
} from '@jdeighan/coffee-utils';
|
45
51
|
|
46
52
|
import {
|
47
53
|
Section
|
package/src/block.coffee
CHANGED
@@ -3,17 +3,12 @@
|
|
3
3
|
import fs from 'fs'
|
4
4
|
import readline from 'readline'
|
5
5
|
|
6
|
-
import {assert, croak} from '@jdeighan/base-utils'
|
6
|
+
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
7
7
|
import {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
isEmpty, isString, isArray, nonEmpty, isArrayOfStrings,
|
13
|
-
rtrim, OL,
|
14
|
-
} from '@jdeighan/coffee-utils'
|
15
|
-
|
16
|
-
export {blockToArray, arrayToBlock, toArray, toBlock}
|
8
|
+
undef, pass, defined, notdefined, rtrim, OL,
|
9
|
+
isEmpty, isString, isArray, nonEmpty, toArray, toBlock,
|
10
|
+
} from '@jdeighan/base-utils'
|
11
|
+
import {isArrayOfStrings} from '@jdeighan/coffee-utils'
|
17
12
|
|
18
13
|
# ---------------------------------------------------------------------------
|
19
14
|
|
@@ -57,7 +52,7 @@ export normalizeBlock = (content) ->
|
|
57
52
|
|
58
53
|
if typeof content != 'string'
|
59
54
|
throw new Error("normalizeBlock(): not a string")
|
60
|
-
lLines = for line in
|
55
|
+
lLines = for line in toArray(content)
|
61
56
|
line = line.trim()
|
62
57
|
line.replace(/\s+/g, ' ')
|
63
58
|
lLines = lLines.filter (line) -> line != ''
|
@@ -68,9 +63,9 @@ export normalizeBlock = (content) ->
|
|
68
63
|
|
69
64
|
export truncateBlock = (str, numLines) ->
|
70
65
|
|
71
|
-
lLines =
|
66
|
+
lLines = toArray str
|
72
67
|
lLines.length = numLines
|
73
|
-
return
|
68
|
+
return toBlock lLines
|
74
69
|
|
75
70
|
# ---------------------------------------------------------------------------
|
76
71
|
|
package/src/block.js
CHANGED
@@ -7,35 +7,26 @@ import readline from 'readline';
|
|
7
7
|
import {
|
8
8
|
assert,
|
9
9
|
croak
|
10
|
-
} from '@jdeighan/base-utils';
|
11
|
-
|
12
|
-
import {
|
13
|
-
blockToArray,
|
14
|
-
arrayToBlock,
|
15
|
-
toArray,
|
16
|
-
toBlock
|
17
|
-
} from '@jdeighan/base-utils/utils';
|
10
|
+
} from '@jdeighan/base-utils/exceptions';
|
18
11
|
|
19
12
|
import {
|
20
13
|
undef,
|
21
14
|
pass,
|
22
15
|
defined,
|
23
16
|
notdefined,
|
17
|
+
rtrim,
|
18
|
+
OL,
|
24
19
|
isEmpty,
|
25
20
|
isString,
|
26
21
|
isArray,
|
27
22
|
nonEmpty,
|
28
|
-
isArrayOfStrings,
|
29
|
-
rtrim,
|
30
|
-
OL
|
31
|
-
} from '@jdeighan/coffee-utils';
|
32
|
-
|
33
|
-
export {
|
34
|
-
blockToArray,
|
35
|
-
arrayToBlock,
|
36
23
|
toArray,
|
37
24
|
toBlock
|
38
|
-
};
|
25
|
+
} from '@jdeighan/base-utils';
|
26
|
+
|
27
|
+
import {
|
28
|
+
isArrayOfStrings
|
29
|
+
} from '@jdeighan/coffee-utils';
|
39
30
|
|
40
31
|
// ---------------------------------------------------------------------------
|
41
32
|
export var splitBlock = function(block) {
|
@@ -83,7 +74,7 @@ export var normalizeBlock = function(content) {
|
|
83
74
|
}
|
84
75
|
lLines = (function() {
|
85
76
|
var i, len, ref, results;
|
86
|
-
ref =
|
77
|
+
ref = toArray(content);
|
87
78
|
results = [];
|
88
79
|
for (i = 0, len = ref.length; i < len; i++) {
|
89
80
|
line = ref[i];
|
@@ -102,9 +93,9 @@ export var normalizeBlock = function(content) {
|
|
102
93
|
// truncateBlock - limit block to a certain number of lines
|
103
94
|
export var truncateBlock = function(str, numLines) {
|
104
95
|
var lLines;
|
105
|
-
lLines =
|
96
|
+
lLines = toArray(str);
|
106
97
|
lLines.length = numLines;
|
107
|
-
return
|
98
|
+
return toBlock(lLines);
|
108
99
|
};
|
109
100
|
|
110
101
|
// ---------------------------------------------------------------------------
|
package/src/browser.coffee
CHANGED
package/src/browser.js
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
# utils.coffee
|
1
|
+
# coffee-utils.coffee
|
2
2
|
|
3
|
-
import {assert, croak} from '@jdeighan/base-utils'
|
4
|
-
import {
|
3
|
+
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
4
|
+
import {
|
5
|
+
LOG, LOGVALUE, sep_dash, sep_eq,
|
6
|
+
} from '@jdeighan/base-utils/log'
|
5
7
|
import {
|
6
8
|
dbgEnter, dbgReturn, dbgYield, dbgResume, dbg, setDebugging,
|
7
9
|
} from '@jdeighan/base-utils/debug'
|
@@ -10,21 +12,9 @@ import {
|
|
10
12
|
deepCopy, escapeStr, unescapeStr, hasChar, quoted, OL,
|
11
13
|
isString, isNumber, isInteger, isHash, isArray, isBoolean,
|
12
14
|
isConstructor, isFunction, isRegExp, isObject, getClassName,
|
13
|
-
jsType, oneof,
|
14
|
-
isEmpty, nonEmpty, chomp, rtrim, setCharsAt, words, getOptions,
|
15
|
-
} from '@jdeighan/base-utils/utils'
|
16
|
-
|
17
|
-
export {
|
18
|
-
assert, croak,
|
19
|
-
LOG, LOGVALUE, sep_dash, sep_eq,
|
20
|
-
dbgEnter, dbgReturn, dbgYield, dbgResume, dbg, setDebugging,
|
21
|
-
undef, pass, defined, notdefined,
|
22
|
-
deepCopy, escapeStr, unescapeStr, hasChar, quoted, OL,
|
23
|
-
isString, isNumber, isInteger, isHash, isArray, isBoolean,
|
24
|
-
isConstructor, isFunction, isRegExp, isObject, getClassName,
|
25
|
-
jsType, oneof,
|
15
|
+
jsType, oneof, isIterable,
|
26
16
|
isEmpty, nonEmpty, chomp, rtrim, setCharsAt, words, getOptions,
|
27
|
-
}
|
17
|
+
} from '@jdeighan/base-utils'
|
28
18
|
|
29
19
|
# ---------------------------------------------------------------------------
|
30
20
|
|
@@ -347,14 +337,6 @@ export replaceVars = (line, hVars={}, rx=/__(env\.)?([A-Za-z_]\w*)__/g) ->
|
|
347
337
|
|
348
338
|
# ---------------------------------------------------------------------------
|
349
339
|
|
350
|
-
export isIterable = (obj) ->
|
351
|
-
|
352
|
-
if (obj == undef) || (obj == null)
|
353
|
-
return false
|
354
|
-
return typeof obj[Symbol.iterator] == 'function'
|
355
|
-
|
356
|
-
# ---------------------------------------------------------------------------
|
357
|
-
|
358
340
|
export className = (aClass) ->
|
359
341
|
|
360
342
|
if lMatches = aClass.toString().match(/class\s+(\w+)/)
|
@@ -364,12 +346,6 @@ export className = (aClass) ->
|
|
364
346
|
|
365
347
|
# ---------------------------------------------------------------------------
|
366
348
|
|
367
|
-
export range = (n) ->
|
368
|
-
|
369
|
-
return [0..n-1]
|
370
|
-
|
371
|
-
# ---------------------------------------------------------------------------
|
372
|
-
|
373
349
|
export timestamp = () ->
|
374
350
|
|
375
351
|
return new Date().toLocaleTimeString("en-US")
|
@@ -1,11 +1,11 @@
|
|
1
1
|
// Generated by CoffeeScript 2.7.0
|
2
|
-
// utils.coffee
|
2
|
+
// coffee-utils.coffee
|
3
3
|
var hasProp = {}.hasOwnProperty;
|
4
4
|
|
5
5
|
import {
|
6
6
|
assert,
|
7
7
|
croak
|
8
|
-
} from '@jdeighan/base-utils';
|
8
|
+
} from '@jdeighan/base-utils/exceptions';
|
9
9
|
|
10
10
|
import {
|
11
11
|
LOG,
|
@@ -47,6 +47,7 @@ import {
|
|
47
47
|
getClassName,
|
48
48
|
jsType,
|
49
49
|
oneof,
|
50
|
+
isIterable,
|
50
51
|
isEmpty,
|
51
52
|
nonEmpty,
|
52
53
|
chomp,
|
@@ -54,52 +55,7 @@ import {
|
|
54
55
|
setCharsAt,
|
55
56
|
words,
|
56
57
|
getOptions
|
57
|
-
} from '@jdeighan/base-utils
|
58
|
-
|
59
|
-
export {
|
60
|
-
assert,
|
61
|
-
croak,
|
62
|
-
LOG,
|
63
|
-
LOGVALUE,
|
64
|
-
sep_dash,
|
65
|
-
sep_eq,
|
66
|
-
dbgEnter,
|
67
|
-
dbgReturn,
|
68
|
-
dbgYield,
|
69
|
-
dbgResume,
|
70
|
-
dbg,
|
71
|
-
setDebugging,
|
72
|
-
undef,
|
73
|
-
pass,
|
74
|
-
defined,
|
75
|
-
notdefined,
|
76
|
-
deepCopy,
|
77
|
-
escapeStr,
|
78
|
-
unescapeStr,
|
79
|
-
hasChar,
|
80
|
-
quoted,
|
81
|
-
OL,
|
82
|
-
isString,
|
83
|
-
isNumber,
|
84
|
-
isInteger,
|
85
|
-
isHash,
|
86
|
-
isArray,
|
87
|
-
isBoolean,
|
88
|
-
isConstructor,
|
89
|
-
isFunction,
|
90
|
-
isRegExp,
|
91
|
-
isObject,
|
92
|
-
getClassName,
|
93
|
-
jsType,
|
94
|
-
oneof,
|
95
|
-
isEmpty,
|
96
|
-
nonEmpty,
|
97
|
-
chomp,
|
98
|
-
rtrim,
|
99
|
-
setCharsAt,
|
100
|
-
words,
|
101
|
-
getOptions
|
102
|
-
};
|
58
|
+
} from '@jdeighan/base-utils';
|
103
59
|
|
104
60
|
// ---------------------------------------------------------------------------
|
105
61
|
export var isHashComment = (line) => {
|
@@ -459,14 +415,6 @@ export var replaceVars = function(line, hVars = {}, rx = /__(env\.)?([A-Za-z_]\w
|
|
459
415
|
return line.replace(rx, replacerFunc);
|
460
416
|
};
|
461
417
|
|
462
|
-
// ---------------------------------------------------------------------------
|
463
|
-
export var isIterable = function(obj) {
|
464
|
-
if ((obj === undef) || (obj === null)) {
|
465
|
-
return false;
|
466
|
-
}
|
467
|
-
return typeof obj[Symbol.iterator] === 'function';
|
468
|
-
};
|
469
|
-
|
470
418
|
// ---------------------------------------------------------------------------
|
471
419
|
export var className = function(aClass) {
|
472
420
|
var lMatches;
|
@@ -477,16 +425,6 @@ export var className = function(aClass) {
|
|
477
425
|
}
|
478
426
|
};
|
479
427
|
|
480
|
-
// ---------------------------------------------------------------------------
|
481
|
-
export var range = function(n) {
|
482
|
-
var ref;
|
483
|
-
return (function() {
|
484
|
-
var results = [];
|
485
|
-
for (var i = 0, ref = n - 1; 0 <= ref ? i <= ref : i >= ref; 0 <= ref ? i++ : i--){ results.push(i); }
|
486
|
-
return results;
|
487
|
-
}).apply(this);
|
488
|
-
};
|
489
|
-
|
490
428
|
// ---------------------------------------------------------------------------
|
491
429
|
export var timestamp = function() {
|
492
430
|
return new Date().toLocaleTimeString("en-US");
|
package/src/fs.coffee
CHANGED
@@ -6,13 +6,14 @@ import fs from 'fs'
|
|
6
6
|
import readline from 'readline'
|
7
7
|
import NReadLines from 'n-readlines'
|
8
8
|
|
9
|
-
import {assert, croak, LOG, fromTAML} from '@jdeighan/base-utils'
|
10
|
-
import {dbg, dbgEnter, dbgReturn} from '@jdeighan/base-utils/debug'
|
11
9
|
import {
|
12
10
|
undef, pass, defined, rtrim, isEmpty, nonEmpty, getOptions,
|
13
|
-
isString, isArray, isHash, isRegExp, isFunction, OL,
|
14
|
-
} from '@jdeighan/
|
15
|
-
import {
|
11
|
+
isString, isArray, isHash, isRegExp, isFunction, OL, toBlock,
|
12
|
+
} from '@jdeighan/base-utils'
|
13
|
+
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
14
|
+
import {LOG, LOGVALUE} from '@jdeighan/base-utils/log'
|
15
|
+
import {dbg, dbgEnter, dbgReturn} from '@jdeighan/base-utils/debug'
|
16
|
+
import {fromTAML} from '@jdeighan/base-utils/taml'
|
16
17
|
|
17
18
|
# ---------------------------------------------------------------------------
|
18
19
|
# mydir() - pass argument import.meta.url and it will return
|
@@ -216,7 +217,7 @@ export slurp = (filepath, maxLines=undef) ->
|
|
216
217
|
forEachLine filepath, (line, nLines) ->
|
217
218
|
lLines.push line
|
218
219
|
return (nLines >= maxLines)
|
219
|
-
contents =
|
220
|
+
contents = toBlock(lLines)
|
220
221
|
else
|
221
222
|
filepath = filepath.replace(/\//g, "\\")
|
222
223
|
contents = fs.readFileSync(filepath, 'utf8').toString()
|
@@ -230,7 +231,7 @@ export barf = (filepath, contents) ->
|
|
230
231
|
if isEmpty(contents)
|
231
232
|
return
|
232
233
|
if isArray(contents)
|
233
|
-
contents =
|
234
|
+
contents = toBlock(contents)
|
234
235
|
else if ! isString(contents)
|
235
236
|
croak "barf(): Invalid contents"
|
236
237
|
contents = rtrim(contents) + "\n"
|
package/src/fs.js
CHANGED
@@ -12,19 +12,6 @@ import readline from 'readline';
|
|
12
12
|
|
13
13
|
import NReadLines from 'n-readlines';
|
14
14
|
|
15
|
-
import {
|
16
|
-
assert,
|
17
|
-
croak,
|
18
|
-
LOG,
|
19
|
-
fromTAML
|
20
|
-
} from '@jdeighan/base-utils';
|
21
|
-
|
22
|
-
import {
|
23
|
-
dbg,
|
24
|
-
dbgEnter,
|
25
|
-
dbgReturn
|
26
|
-
} from '@jdeighan/base-utils/debug';
|
27
|
-
|
28
15
|
import {
|
29
16
|
undef,
|
30
17
|
pass,
|
@@ -38,12 +25,29 @@ import {
|
|
38
25
|
isHash,
|
39
26
|
isRegExp,
|
40
27
|
isFunction,
|
41
|
-
OL
|
42
|
-
|
28
|
+
OL,
|
29
|
+
toBlock
|
30
|
+
} from '@jdeighan/base-utils';
|
43
31
|
|
44
32
|
import {
|
45
|
-
|
46
|
-
|
33
|
+
assert,
|
34
|
+
croak
|
35
|
+
} from '@jdeighan/base-utils/exceptions';
|
36
|
+
|
37
|
+
import {
|
38
|
+
LOG,
|
39
|
+
LOGVALUE
|
40
|
+
} from '@jdeighan/base-utils/log';
|
41
|
+
|
42
|
+
import {
|
43
|
+
dbg,
|
44
|
+
dbgEnter,
|
45
|
+
dbgReturn
|
46
|
+
} from '@jdeighan/base-utils/debug';
|
47
|
+
|
48
|
+
import {
|
49
|
+
fromTAML
|
50
|
+
} from '@jdeighan/base-utils/taml';
|
47
51
|
|
48
52
|
// ---------------------------------------------------------------------------
|
49
53
|
// mydir() - pass argument import.meta.url and it will return
|
@@ -252,7 +256,7 @@ export var slurp = function(filepath, maxLines = undef) {
|
|
252
256
|
lLines.push(line);
|
253
257
|
return nLines >= maxLines;
|
254
258
|
});
|
255
|
-
contents =
|
259
|
+
contents = toBlock(lLines);
|
256
260
|
} else {
|
257
261
|
filepath = filepath.replace(/\//g, "\\");
|
258
262
|
contents = fs.readFileSync(filepath, 'utf8').toString();
|
@@ -267,7 +271,7 @@ export var barf = function(filepath, contents) {
|
|
267
271
|
return;
|
268
272
|
}
|
269
273
|
if (isArray(contents)) {
|
270
|
-
contents =
|
274
|
+
contents = toBlock(contents);
|
271
275
|
} else if (!isString(contents)) {
|
272
276
|
croak("barf(): Invalid contents");
|
273
277
|
}
|
package/src/fsa.coffee
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# fsa.coffee
|
2
2
|
|
3
|
-
import {assert, croak} from '@jdeighan/base-utils'
|
3
|
+
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
4
4
|
import {LOG} from '@jdeighan/base-utils/log'
|
5
5
|
import {dbg, dbgEnter, dbgReturn} from '@jdeighan/base-utils/debug'
|
6
6
|
import {
|
7
7
|
undef, defined, notdefined, words, isEmpty, nonEmpty,
|
8
|
-
isString, OL,
|
9
|
-
} from '@jdeighan/
|
10
|
-
import {toArray} from '@jdeighan/coffee-utils/block'
|
8
|
+
isString, OL, toArray,
|
9
|
+
} from '@jdeighan/base-utils'
|
11
10
|
|
12
11
|
# ---------------------------------------------------------------------------
|
13
12
|
|
package/src/fsa.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
import {
|
4
4
|
assert,
|
5
5
|
croak
|
6
|
-
} from '@jdeighan/base-utils';
|
6
|
+
} from '@jdeighan/base-utils/exceptions';
|
7
7
|
|
8
8
|
import {
|
9
9
|
LOG
|
@@ -23,12 +23,9 @@ import {
|
|
23
23
|
isEmpty,
|
24
24
|
nonEmpty,
|
25
25
|
isString,
|
26
|
-
OL
|
27
|
-
} from '@jdeighan/coffee-utils';
|
28
|
-
|
29
|
-
import {
|
26
|
+
OL,
|
30
27
|
toArray
|
31
|
-
} from '@jdeighan/
|
28
|
+
} from '@jdeighan/base-utils';
|
32
29
|
|
33
30
|
// ---------------------------------------------------------------------------
|
34
31
|
export var FSA = class FSA {
|
package/src/html.coffee
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# html.coffee
|
2
2
|
|
3
|
-
import {assert, croak} from '@jdeighan/base-utils'
|
3
|
+
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
4
4
|
import {
|
5
|
-
undef, pass, words, isEmpty, nonEmpty,
|
6
|
-
} from '@jdeighan/
|
5
|
+
undef, pass, words, isEmpty, nonEmpty, toBlock,
|
6
|
+
} from '@jdeighan/base-utils'
|
7
7
|
import {indented} from '@jdeighan/coffee-utils/indent'
|
8
|
-
import {toBlock} from '@jdeighan/coffee-utils/block'
|
9
8
|
|
10
9
|
hNoEnd = {}
|
11
10
|
for tagName in words('area base br col command embed hr img input' \
|
package/src/html.js
CHANGED
@@ -5,24 +5,21 @@ var hNoEnd, i, len, ref, tagName;
|
|
5
5
|
import {
|
6
6
|
assert,
|
7
7
|
croak
|
8
|
-
} from '@jdeighan/base-utils';
|
8
|
+
} from '@jdeighan/base-utils/exceptions';
|
9
9
|
|
10
10
|
import {
|
11
11
|
undef,
|
12
12
|
pass,
|
13
13
|
words,
|
14
14
|
isEmpty,
|
15
|
-
nonEmpty
|
16
|
-
|
15
|
+
nonEmpty,
|
16
|
+
toBlock
|
17
|
+
} from '@jdeighan/base-utils';
|
17
18
|
|
18
19
|
import {
|
19
20
|
indented
|
20
21
|
} from '@jdeighan/coffee-utils/indent';
|
21
22
|
|
22
|
-
import {
|
23
|
-
toBlock
|
24
|
-
} from '@jdeighan/coffee-utils/block';
|
25
|
-
|
26
23
|
hNoEnd = {};
|
27
24
|
|
28
25
|
ref = words('area base br col command embed hr img input' + ' keygen link meta param source track wbr');
|
package/src/indent.coffee
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# indent.coffee
|
2
2
|
|
3
|
-
import {assert, croak} from '@jdeighan/base-utils'
|
3
|
+
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
4
4
|
import {
|
5
|
-
undef, defined, notdefined,
|
5
|
+
undef, defined, notdefined, toArray, toBlock,
|
6
6
|
OL, isInteger, isString, isArray, isEmpty, rtrim,
|
7
|
-
} from '@jdeighan/
|
8
|
-
import {toArray, toBlock} from '@jdeighan/coffee-utils/block'
|
7
|
+
} from '@jdeighan/base-utils'
|
9
8
|
|
10
9
|
# ---------------------------------------------------------------------------
|
11
10
|
|
package/src/indent.js
CHANGED
@@ -3,24 +3,21 @@
|
|
3
3
|
import {
|
4
4
|
assert,
|
5
5
|
croak
|
6
|
-
} from '@jdeighan/base-utils';
|
6
|
+
} from '@jdeighan/base-utils/exceptions';
|
7
7
|
|
8
8
|
import {
|
9
9
|
undef,
|
10
10
|
defined,
|
11
11
|
notdefined,
|
12
|
+
toArray,
|
13
|
+
toBlock,
|
12
14
|
OL,
|
13
15
|
isInteger,
|
14
16
|
isString,
|
15
17
|
isArray,
|
16
18
|
isEmpty,
|
17
19
|
rtrim
|
18
|
-
} from '@jdeighan/
|
19
|
-
|
20
|
-
import {
|
21
|
-
toArray,
|
22
|
-
toBlock
|
23
|
-
} from '@jdeighan/coffee-utils/block';
|
20
|
+
} from '@jdeighan/base-utils';
|
24
21
|
|
25
22
|
// ---------------------------------------------------------------------------
|
26
23
|
export var getOneIndent = function(str) {
|
package/src/svelte.coffee
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# svelte.coffee
|
2
2
|
|
3
|
-
import {assert, croak} from '@jdeighan/base-utils'
|
3
|
+
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
4
4
|
import {LOG} from '@jdeighan/base-utils/log'
|
5
|
-
import {isFunction} from '@jdeighan/
|
5
|
+
import {isFunction} from '@jdeighan/base-utils'
|
6
6
|
|
7
7
|
# ---------------------------------------------------------------------------
|
8
8
|
# svelteSourceCodeEsc - to display source code for a *.starbucks page
|
package/src/svelte.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
import {
|
4
4
|
assert,
|
5
5
|
croak
|
6
|
-
} from '@jdeighan/base-utils';
|
6
|
+
} from '@jdeighan/base-utils/exceptions';
|
7
7
|
|
8
8
|
import {
|
9
9
|
LOG
|
@@ -11,7 +11,7 @@ import {
|
|
11
11
|
|
12
12
|
import {
|
13
13
|
isFunction
|
14
|
-
} from '@jdeighan/
|
14
|
+
} from '@jdeighan/base-utils';
|
15
15
|
|
16
16
|
// ---------------------------------------------------------------------------
|
17
17
|
// svelteSourceCodeEsc - to display source code for a *.starbucks page
|