@jdeighan/coffee-utils 11.0.2 → 11.0.3
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.
- package/package.json +14 -13
- package/src/DataStores.coffee +6 -15
- package/src/DataStores.js +8 -21
- package/src/Section.coffee +1 -1
- package/src/Section.js +1 -2
- package/src/SectionMap.coffee +5 -7
- package/src/SectionMap.js +6 -14
- package/src/arrow.coffee +1 -1
- package/src/arrow.js +1 -1
- package/src/{block_utils.coffee → block.coffee} +5 -5
- package/src/{block_utils.js → block.js} +4 -6
- package/src/{browser_utils.coffee → browser.coffee} +1 -1
- package/src/{browser_utils.js → browser.js} +1 -1
- package/src/{debug_utils.coffee → debug.coffee} +7 -12
- package/src/{debug_utils.js → debug.js} +6 -25
- package/src/{fs_utils.coffee → fs.coffee} +5 -40
- package/src/{fs_utils.js → fs.js} +9 -51
- package/src/fsa.coffee +1 -2
- package/src/fsa.js +2 -5
- package/src/{html_utils.coffee → html.coffee} +5 -6
- package/src/{html_utils.js → html.js} +5 -10
- package/src/{indent_utils.coffee → indent.coffee} +7 -9
- package/src/{indent_utils.js → indent.js} +7 -9
- package/src/{log_utils.coffee → log.coffee} +5 -44
- package/src/{log_utils.js → log.js} +6 -55
- package/src/placeholders.coffee +1 -1
- package/src/placeholders.js +1 -2
- package/src/{server_utils.coffee → server.coffee} +1 -1
- package/src/{server_utils.js → server.js} +1 -1
- package/src/{call_stack.coffee → stack.coffee} +2 -2
- package/src/{call_stack.js → stack.js} +2 -2
- package/src/{svelte_utils.coffee → svelte.coffee} +4 -5
- package/src/{svelte_utils.js → svelte.js} +6 -10
- package/src/taml.coffee +20 -25
- package/src/taml.js +25 -34
- package/src/{coffee_utils.coffee → utils.coffee} +3 -4
- package/src/{coffee_utils.js → utils.js} +8 -15
package/package.json
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jdeighan/coffee-utils",
|
3
3
|
"type": "module",
|
4
|
-
"version": "11.0.
|
4
|
+
"version": "11.0.3",
|
5
5
|
"description": "A set of utility functions for CoffeeScript",
|
6
6
|
"main": "coffee_utils.js",
|
7
7
|
"exports": {
|
8
|
-
".": "./src/
|
9
|
-
"./server": "./src/
|
10
|
-
"./browser": "./src/
|
11
|
-
"./fs": "./src/
|
12
|
-
"./log": "./src/
|
13
|
-
"./block": "./src/
|
14
|
-
"./indent": "./src/
|
15
|
-
"./html": "./src/
|
16
|
-
"./stack": "./src/
|
17
|
-
"./debug": "./src/
|
8
|
+
".": "./src/utils.js",
|
9
|
+
"./server": "./src/server.js",
|
10
|
+
"./browser": "./src/browser.js",
|
11
|
+
"./fs": "./src/fs.js",
|
12
|
+
"./log": "./src/log.js",
|
13
|
+
"./block": "./src/block.js",
|
14
|
+
"./indent": "./src/indent.js",
|
15
|
+
"./html": "./src/html.js",
|
16
|
+
"./stack": "./src/stack.js",
|
17
|
+
"./debug": "./src/debug.js",
|
18
18
|
"./arrow": "./src/arrow.js",
|
19
|
-
"./svelte": "./src/
|
19
|
+
"./svelte": "./src/svelte.js",
|
20
20
|
"./store": "./src/DataStores.js",
|
21
21
|
"./taml": "./src/taml.js",
|
22
22
|
"./placeholders": "./src/placeholders.js",
|
@@ -50,6 +50,7 @@
|
|
50
50
|
},
|
51
51
|
"homepage": "https://github.com/johndeighan/coffee-utils#readme",
|
52
52
|
"dependencies": {
|
53
|
+
"@jdeighan/exceptions": "^1.0.3",
|
53
54
|
"cross-env": "^7.0.3",
|
54
55
|
"js-yaml": "^4.1.0",
|
55
56
|
"n-readlines": "^1.0.1",
|
@@ -57,6 +58,6 @@
|
|
57
58
|
"svelte": "^3.50.1"
|
58
59
|
},
|
59
60
|
"devDependencies": {
|
60
|
-
"@jdeighan/unit-tester": "^2.0.
|
61
|
+
"@jdeighan/unit-tester": "^2.0.27"
|
61
62
|
}
|
62
63
|
}
|
package/src/DataStores.coffee
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
# DataStores.coffee
|
2
2
|
|
3
3
|
import pathlib from 'path'
|
4
|
-
import yaml from 'js-yaml'
|
5
4
|
import {writable, readable, get} from 'svelte/store'
|
6
5
|
|
7
|
-
import {assert,
|
8
|
-
import {undef, pass
|
6
|
+
import {assert, croak} from '@jdeighan/exceptions'
|
7
|
+
import {undef, pass} from '@jdeighan/coffee-utils'
|
9
8
|
import {localStore} from '@jdeighan/coffee-utils/browser'
|
10
9
|
import {
|
11
10
|
withExt, slurp, barf, newerDestFileExists,
|
12
11
|
} from '@jdeighan/coffee-utils/fs'
|
13
|
-
import {
|
12
|
+
import {fromTAML} from '@jdeighan/coffee-utils/taml'
|
14
13
|
|
15
14
|
# ---------------------------------------------------------------------------
|
16
15
|
|
@@ -46,7 +45,7 @@ export class LocalStorageDataStore extends WritableDataStore
|
|
46
45
|
|
47
46
|
set: (value) ->
|
48
47
|
if ! value?
|
49
|
-
|
48
|
+
croak "LocalStorageStore.set(): cannont set to undef"
|
50
49
|
super value
|
51
50
|
localStore @masterKey, value
|
52
51
|
|
@@ -63,7 +62,7 @@ export class PropsDataStore extends LocalStorageDataStore
|
|
63
62
|
|
64
63
|
setProp: (name, value) ->
|
65
64
|
if ! name?
|
66
|
-
|
65
|
+
croak "PropStore.setProp(): empty key"
|
67
66
|
@update (hPrefs) ->
|
68
67
|
hPrefs[name] = value
|
69
68
|
return hPrefs
|
@@ -122,20 +121,12 @@ export class TAMLDataStore extends WritableDataStore
|
|
122
121
|
|
123
122
|
constructor: (str) ->
|
124
123
|
|
125
|
-
super
|
124
|
+
super fromTAML(str)
|
126
125
|
|
127
126
|
# ---------------------------------------------------------------------------
|
128
127
|
# UTILITIES
|
129
128
|
# ---------------------------------------------------------------------------
|
130
129
|
|
131
|
-
export taml = (text) ->
|
132
|
-
|
133
|
-
if ! text?
|
134
|
-
return undef
|
135
|
-
return yaml.load(untabify(text, 1), {skipInvalid: true})
|
136
|
-
|
137
|
-
# ---------------------------------------------------------------------------
|
138
|
-
|
139
130
|
export brewTamlStr = (code, stub) ->
|
140
131
|
|
141
132
|
return """
|
package/src/DataStores.js
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
// DataStores.coffee
|
3
3
|
import pathlib from 'path';
|
4
4
|
|
5
|
-
import yaml from 'js-yaml';
|
6
|
-
|
7
5
|
import {
|
8
6
|
writable,
|
9
7
|
readable,
|
@@ -12,13 +10,12 @@ import {
|
|
12
10
|
|
13
11
|
import {
|
14
12
|
assert,
|
15
|
-
|
16
|
-
} from '@jdeighan/
|
13
|
+
croak
|
14
|
+
} from '@jdeighan/exceptions';
|
17
15
|
|
18
16
|
import {
|
19
17
|
undef,
|
20
|
-
pass
|
21
|
-
isEmpty
|
18
|
+
pass
|
22
19
|
} from '@jdeighan/coffee-utils';
|
23
20
|
|
24
21
|
import {
|
@@ -33,8 +30,8 @@ import {
|
|
33
30
|
} from '@jdeighan/coffee-utils/fs';
|
34
31
|
|
35
32
|
import {
|
36
|
-
|
37
|
-
} from '@jdeighan/coffee-utils/
|
33
|
+
fromTAML
|
34
|
+
} from '@jdeighan/coffee-utils/taml';
|
38
35
|
|
39
36
|
// ---------------------------------------------------------------------------
|
40
37
|
export var WritableDataStore = class WritableDataStore {
|
@@ -72,7 +69,7 @@ export var LocalStorageDataStore = class LocalStorageDataStore extends WritableD
|
|
72
69
|
// set() will also be called
|
73
70
|
set(value) {
|
74
71
|
if (value == null) {
|
75
|
-
|
72
|
+
croak("LocalStorageStore.set(): cannont set to undef");
|
76
73
|
}
|
77
74
|
super.set(value);
|
78
75
|
return localStore(this.masterKey, value);
|
@@ -93,7 +90,7 @@ export var PropsDataStore = class PropsDataStore extends LocalStorageDataStore {
|
|
93
90
|
|
94
91
|
setProp(name, value) {
|
95
92
|
if (name == null) {
|
96
|
-
|
93
|
+
croak("PropStore.setProp(): empty key");
|
97
94
|
}
|
98
95
|
return this.update(function(hPrefs) {
|
99
96
|
hPrefs[name] = value;
|
@@ -166,23 +163,13 @@ export var MousePosDataStore = class MousePosDataStore extends ReadableDataStore
|
|
166
163
|
// ---------------------------------------------------------------------------
|
167
164
|
export var TAMLDataStore = class TAMLDataStore extends WritableDataStore {
|
168
165
|
constructor(str) {
|
169
|
-
super(
|
166
|
+
super(fromTAML(str));
|
170
167
|
}
|
171
168
|
|
172
169
|
};
|
173
170
|
|
174
171
|
// ---------------------------------------------------------------------------
|
175
172
|
// UTILITIES
|
176
|
-
// ---------------------------------------------------------------------------
|
177
|
-
export var taml = function(text) {
|
178
|
-
if (text == null) {
|
179
|
-
return undef;
|
180
|
-
}
|
181
|
-
return yaml.load(untabify(text, 1), {
|
182
|
-
skipInvalid: true
|
183
|
-
});
|
184
|
-
};
|
185
|
-
|
186
173
|
// ---------------------------------------------------------------------------
|
187
174
|
export var brewTamlStr = function(code, stub) {
|
188
175
|
return `import {TAMLDataStore} from '@jdeighan/starbucks/stores';
|
package/src/Section.coffee
CHANGED
package/src/Section.js
CHANGED
package/src/SectionMap.coffee
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
# SectionMap.coffee
|
2
2
|
|
3
|
-
import {
|
3
|
+
import {LOG, assert, croak} from '@jdeighan/exceptions'
|
4
4
|
import {
|
5
5
|
pass, undef, defined, notdefined, OL, isEmpty, nonEmpty,
|
6
6
|
isString, isHash, isArray, isUniqueTree, isNonEmptyString,
|
7
7
|
isNonEmptyArray,
|
8
8
|
} from '@jdeighan/coffee-utils'
|
9
|
-
import {
|
10
|
-
import {indented} from '@jdeighan/coffee-utils/indent'
|
11
|
-
import {LOG} from '@jdeighan/coffee-utils/log'
|
9
|
+
import {toBlock} from '@jdeighan/coffee-utils/block'
|
12
10
|
import {debug} from '@jdeighan/coffee-utils/debug'
|
13
|
-
import {isTAML,
|
11
|
+
import {isTAML, fromTAML} from '@jdeighan/coffee-utils/taml'
|
14
12
|
import {Section} from '@jdeighan/coffee-utils/section'
|
15
13
|
|
16
14
|
# ---------------------------------------------------------------------------
|
@@ -35,7 +33,7 @@ export class SectionMap
|
|
35
33
|
debug "enter SectionMap()", @lSectionTree
|
36
34
|
|
37
35
|
if isTAML(@lSectionTree)
|
38
|
-
@SectionTree =
|
36
|
+
@SectionTree = fromTAML(@lSectionTree)
|
39
37
|
|
40
38
|
assert isArray(@lSectionTree), "not an array"
|
41
39
|
|
@@ -127,7 +125,7 @@ export class SectionMap
|
|
127
125
|
else
|
128
126
|
croak "Bad item: #{OL(item)}"
|
129
127
|
|
130
|
-
block =
|
128
|
+
block = toBlock(lBlocks)
|
131
129
|
debug "block is", block
|
132
130
|
if defined(setName)
|
133
131
|
if defined(proc = hReplacers[setName])
|
package/src/SectionMap.js
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
var isSectionName, isSetName;
|
4
4
|
|
5
5
|
import {
|
6
|
+
LOG,
|
6
7
|
assert,
|
7
|
-
error,
|
8
8
|
croak
|
9
|
-
} from '@jdeighan/
|
9
|
+
} from '@jdeighan/exceptions';
|
10
10
|
|
11
11
|
import {
|
12
12
|
pass,
|
@@ -25,24 +25,16 @@ import {
|
|
25
25
|
} from '@jdeighan/coffee-utils';
|
26
26
|
|
27
27
|
import {
|
28
|
-
|
28
|
+
toBlock
|
29
29
|
} from '@jdeighan/coffee-utils/block';
|
30
30
|
|
31
|
-
import {
|
32
|
-
indented
|
33
|
-
} from '@jdeighan/coffee-utils/indent';
|
34
|
-
|
35
|
-
import {
|
36
|
-
LOG
|
37
|
-
} from '@jdeighan/coffee-utils/log';
|
38
|
-
|
39
31
|
import {
|
40
32
|
debug
|
41
33
|
} from '@jdeighan/coffee-utils/debug';
|
42
34
|
|
43
35
|
import {
|
44
36
|
isTAML,
|
45
|
-
|
37
|
+
fromTAML
|
46
38
|
} from '@jdeighan/coffee-utils/taml';
|
47
39
|
|
48
40
|
import {
|
@@ -66,7 +58,7 @@ export var SectionMap = class SectionMap {
|
|
66
58
|
// --- lSectionTree is a tree of section/set names
|
67
59
|
debug("enter SectionMap()", this.lSectionTree);
|
68
60
|
if (isTAML(this.lSectionTree)) {
|
69
|
-
this.SectionTree =
|
61
|
+
this.SectionTree = fromTAML(this.lSectionTree);
|
70
62
|
}
|
71
63
|
assert(isArray(this.lSectionTree), "not an array");
|
72
64
|
// --- keys are section names, values are Section objects
|
@@ -162,7 +154,7 @@ export var SectionMap = class SectionMap {
|
|
162
154
|
croak(`Bad item: ${OL(item)}`);
|
163
155
|
}
|
164
156
|
}
|
165
|
-
block =
|
157
|
+
block = toBlock(lBlocks);
|
166
158
|
debug("block is", block);
|
167
159
|
if (defined(setName)) {
|
168
160
|
if (defined(proc = hReplacers[setName])) {
|
package/src/arrow.coffee
CHANGED
package/src/arrow.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# block.coffee
|
2
2
|
|
3
3
|
import fs from 'fs'
|
4
4
|
import readline from 'readline'
|
5
5
|
|
6
|
-
import {assert,
|
6
|
+
import {assert, croak} from '@jdeighan/exceptions'
|
7
7
|
import {
|
8
8
|
undef, pass, defined, notdefined,
|
9
9
|
isEmpty, isString, isArray, nonEmpty, isArrayOfStrings,
|
10
|
-
|
10
|
+
rtrim, OL,
|
11
11
|
} from '@jdeighan/coffee-utils'
|
12
12
|
|
13
13
|
# ---------------------------------------------------------------------------
|
@@ -208,7 +208,7 @@ export forEachBlock = (filepath, func, regexp = /^-{16,}$/) ->
|
|
208
208
|
earlyExit = true
|
209
209
|
return true
|
210
210
|
else if result?
|
211
|
-
|
211
|
+
croak "forEachBlock() - callback returned '#{result}'"
|
212
212
|
lLines = []
|
213
213
|
firstLineNum = lineNum+1
|
214
214
|
else
|
@@ -240,7 +240,7 @@ export forEachSetOfBlocks = (filepath, func,
|
|
240
240
|
earlyExit = true
|
241
241
|
return true
|
242
242
|
else if result?
|
243
|
-
|
243
|
+
croak "forEachSetOfBlocks() - callback returned '#{result}'"
|
244
244
|
lBlocks = []
|
245
245
|
firstLineNum = lineNum+1
|
246
246
|
else if (line.match(block_regexp))
|
@@ -1,14 +1,13 @@
|
|
1
1
|
// Generated by CoffeeScript 2.7.0
|
2
|
-
//
|
2
|
+
// block.coffee
|
3
3
|
import fs from 'fs';
|
4
4
|
|
5
5
|
import readline from 'readline';
|
6
6
|
|
7
7
|
import {
|
8
8
|
assert,
|
9
|
-
error,
|
10
9
|
croak
|
11
|
-
} from '@jdeighan/
|
10
|
+
} from '@jdeighan/exceptions';
|
12
11
|
|
13
12
|
import {
|
14
13
|
undef,
|
@@ -20,7 +19,6 @@ import {
|
|
20
19
|
isArray,
|
21
20
|
nonEmpty,
|
22
21
|
isArrayOfStrings,
|
23
|
-
escapeStr,
|
24
22
|
rtrim,
|
25
23
|
OL
|
26
24
|
} from '@jdeighan/coffee-utils';
|
@@ -254,7 +252,7 @@ export var forEachBlock = async function(filepath, func, regexp = /^-{16,}$/) {
|
|
254
252
|
earlyExit = true;
|
255
253
|
return true;
|
256
254
|
} else if (result != null) {
|
257
|
-
|
255
|
+
croak(`forEachBlock() - callback returned '${result}'`);
|
258
256
|
}
|
259
257
|
}
|
260
258
|
lLines = [];
|
@@ -286,7 +284,7 @@ export var forEachSetOfBlocks = async function(filepath, func, block_regexp = /^
|
|
286
284
|
earlyExit = true;
|
287
285
|
return true;
|
288
286
|
} else if (result != null) {
|
289
|
-
|
287
|
+
croak(`forEachSetOfBlocks() - callback returned '${result}'`);
|
290
288
|
}
|
291
289
|
}
|
292
290
|
lBlocks = [];
|
@@ -1,20 +1,15 @@
|
|
1
|
-
#
|
1
|
+
# debug.coffee
|
2
2
|
|
3
|
-
import {
|
3
|
+
import {LOG, assert, croak} from '@jdeighan/exceptions'
|
4
4
|
import {
|
5
|
-
undef,
|
6
|
-
isString, isFunction, isBoolean,
|
7
|
-
OL,
|
5
|
+
undef, defined, notdefined,
|
6
|
+
isString, isFunction, isBoolean, isArray,
|
7
|
+
OL, words, pass,
|
8
8
|
} from '@jdeighan/coffee-utils'
|
9
|
-
import {blockToArray} from '@jdeighan/coffee-utils/block'
|
10
|
-
import {untabify} from '@jdeighan/coffee-utils/indent'
|
11
|
-
import {slurp} from '@jdeighan/coffee-utils/fs'
|
12
9
|
import {CallStack} from '@jdeighan/coffee-utils/stack'
|
10
|
+
import {prefix} from '@jdeighan/coffee-utils/arrow'
|
13
11
|
import {
|
14
|
-
|
15
|
-
} from '@jdeighan/coffee-utils/arrow'
|
16
|
-
import {
|
17
|
-
log, logItem, logBareItem, LOG, shortEnough,
|
12
|
+
log, logItem, logBareItem, shortEnough,
|
18
13
|
} from '@jdeighan/coffee-utils/log'
|
19
14
|
|
20
15
|
# --- set in resetDebugging() and setDebugging()
|
@@ -1,58 +1,39 @@
|
|
1
1
|
// Generated by CoffeeScript 2.7.0
|
2
|
-
//
|
2
|
+
// debug.coffee
|
3
3
|
var lFuncList, reMethod, strFuncList,
|
4
4
|
indexOf = [].indexOf;
|
5
5
|
|
6
6
|
import {
|
7
|
+
LOG,
|
7
8
|
assert,
|
8
|
-
error,
|
9
9
|
croak
|
10
|
-
} from '@jdeighan/
|
10
|
+
} from '@jdeighan/exceptions';
|
11
11
|
|
12
12
|
import {
|
13
13
|
undef,
|
14
|
-
warn,
|
15
14
|
defined,
|
15
|
+
notdefined,
|
16
16
|
isString,
|
17
17
|
isFunction,
|
18
18
|
isBoolean,
|
19
|
-
patchStr,
|
20
|
-
OL,
|
21
|
-
escapeStr,
|
22
|
-
isNumber,
|
23
19
|
isArray,
|
20
|
+
OL,
|
24
21
|
words,
|
25
22
|
pass
|
26
23
|
} from '@jdeighan/coffee-utils';
|
27
24
|
|
28
|
-
import {
|
29
|
-
blockToArray
|
30
|
-
} from '@jdeighan/coffee-utils/block';
|
31
|
-
|
32
|
-
import {
|
33
|
-
untabify
|
34
|
-
} from '@jdeighan/coffee-utils/indent';
|
35
|
-
|
36
|
-
import {
|
37
|
-
slurp
|
38
|
-
} from '@jdeighan/coffee-utils/fs';
|
39
|
-
|
40
25
|
import {
|
41
26
|
CallStack
|
42
27
|
} from '@jdeighan/coffee-utils/stack';
|
43
28
|
|
44
29
|
import {
|
45
|
-
prefix
|
46
|
-
addArrow,
|
47
|
-
removeLastVbar,
|
48
|
-
vbar
|
30
|
+
prefix
|
49
31
|
} from '@jdeighan/coffee-utils/arrow';
|
50
32
|
|
51
33
|
import {
|
52
34
|
log,
|
53
35
|
logItem,
|
54
36
|
logBareItem,
|
55
|
-
LOG,
|
56
37
|
shortEnough
|
57
38
|
} from '@jdeighan/coffee-utils/log';
|
58
39
|
|