@jdeighan/coffee-utils 4.1.15 → 4.1.19
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +4 -1
- package/src/call_stack.coffee +5 -2
- package/src/call_stack.js +6 -2
- package/src/coffee_utils.coffee +12 -0
- package/src/coffee_utils.js +14 -0
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jdeighan/coffee-utils",
|
3
3
|
"type": "module",
|
4
|
-
"version": "4.1.
|
4
|
+
"version": "4.1.19",
|
5
5
|
"description": "A set of utility functions for CoffeeScript",
|
6
6
|
"main": "coffee_utils.js",
|
7
7
|
"exports": {
|
@@ -19,6 +19,9 @@
|
|
19
19
|
"engines": {
|
20
20
|
"node": ">=12.0.0"
|
21
21
|
},
|
22
|
+
"ava": {
|
23
|
+
"verbose": false
|
24
|
+
},
|
22
25
|
"scripts": {
|
23
26
|
"build": "cls && rm -f ./src/*.js && coffee -c ./src",
|
24
27
|
"old_pretest": "npm run build && rm -f ./test/*.js && rm -f ./test/*.coffee && cielo -fq ./test",
|
package/src/call_stack.coffee
CHANGED
@@ -22,8 +22,11 @@ export class CallStack
|
|
22
22
|
|
23
23
|
returnFrom: (fName) ->
|
24
24
|
|
25
|
+
if @lStack.length == 0
|
26
|
+
croak "returnFrom('#{fName}') but stack is empty"
|
25
27
|
{funcName, hInfo} = @lStack.pop()
|
26
28
|
if funcName != fName
|
29
|
+
@dump()
|
27
30
|
croak "returnFrom('#{fName}') but TOS is '#{funcName}'"
|
28
31
|
return hInfo
|
29
32
|
|
@@ -37,7 +40,7 @@ export class CallStack
|
|
37
40
|
|
38
41
|
dump: (label='CALL STACK') ->
|
39
42
|
|
40
|
-
log "#{label}:"
|
43
|
+
console.log "#{label}:"
|
41
44
|
for item, i in @lStack
|
42
|
-
log "#{i}: #{JSON.stringify(item)}"
|
45
|
+
console.log "#{i}: #{JSON.stringify(item)}"
|
43
46
|
return
|
package/src/call_stack.js
CHANGED
@@ -23,8 +23,12 @@ export var CallStack = class CallStack {
|
|
23
23
|
// ........................................................................
|
24
24
|
returnFrom(fName) {
|
25
25
|
var funcName, hInfo;
|
26
|
+
if (this.lStack.length === 0) {
|
27
|
+
croak(`returnFrom('${fName}') but stack is empty`);
|
28
|
+
}
|
26
29
|
({funcName, hInfo} = this.lStack.pop());
|
27
30
|
if (funcName !== fName) {
|
31
|
+
this.dump();
|
28
32
|
croak(`returnFrom('${fName}') but TOS is '${funcName}'`);
|
29
33
|
}
|
30
34
|
return hInfo;
|
@@ -38,11 +42,11 @@ export var CallStack = class CallStack {
|
|
38
42
|
// ........................................................................
|
39
43
|
dump(label = 'CALL STACK') {
|
40
44
|
var i, item, j, len, ref;
|
41
|
-
log(`${label}:`);
|
45
|
+
console.log(`${label}:`);
|
42
46
|
ref = this.lStack;
|
43
47
|
for (i = j = 0, len = ref.length; j < len; i = ++j) {
|
44
48
|
item = ref[i];
|
45
|
-
log(`${i}: ${JSON.stringify(item)}`);
|
49
|
+
console.log(`${i}: ${JSON.stringify(item)}`);
|
46
50
|
}
|
47
51
|
}
|
48
52
|
|
package/src/coffee_utils.coffee
CHANGED
@@ -1,12 +1,24 @@
|
|
1
1
|
# coffee_utils.coffee
|
2
2
|
|
3
3
|
import getline from 'readline-sync'
|
4
|
+
import {execSync} from 'child_process'
|
5
|
+
|
4
6
|
import {log} from '@jdeighan/coffee-utils/log'
|
5
7
|
|
6
8
|
export sep_dash = '-'.repeat(42)
|
7
9
|
export sep_eq = '='.repeat(42)
|
8
10
|
`export const undef = undefined`
|
9
11
|
|
12
|
+
# ---------------------------------------------------------------------------
|
13
|
+
# exec - run external commands
|
14
|
+
|
15
|
+
export exec = (cmd) ->
|
16
|
+
|
17
|
+
buffer = execSync cmd, {
|
18
|
+
windowsHide: true
|
19
|
+
}
|
20
|
+
return buffer.toString()
|
21
|
+
|
10
22
|
# ---------------------------------------------------------------------------
|
11
23
|
# pass - do nothing
|
12
24
|
|
package/src/coffee_utils.js
CHANGED
@@ -4,6 +4,10 @@ var commentRegExp;
|
|
4
4
|
|
5
5
|
import getline from 'readline-sync';
|
6
6
|
|
7
|
+
import {
|
8
|
+
execSync
|
9
|
+
} from 'child_process';
|
10
|
+
|
7
11
|
import {
|
8
12
|
log
|
9
13
|
} from '@jdeighan/coffee-utils/log';
|
@@ -14,6 +18,16 @@ export var sep_eq = '='.repeat(42);
|
|
14
18
|
|
15
19
|
export const undef = undefined;
|
16
20
|
|
21
|
+
// ---------------------------------------------------------------------------
|
22
|
+
// exec - run external commands
|
23
|
+
export var exec = function(cmd) {
|
24
|
+
var buffer;
|
25
|
+
buffer = execSync(cmd, {
|
26
|
+
windowsHide: true
|
27
|
+
});
|
28
|
+
return buffer.toString();
|
29
|
+
};
|
30
|
+
|
17
31
|
// ---------------------------------------------------------------------------
|
18
32
|
// pass - do nothing
|
19
33
|
export var pass = function() {};
|