@jdeighan/coffee-utils 11.0.14 → 11.0.16
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +3 -3
- package/src/utils.coffee +17 -2
- package/src/utils.js +29 -3
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jdeighan/coffee-utils",
|
3
3
|
"type": "module",
|
4
|
-
"version": "11.0.
|
4
|
+
"version": "11.0.16",
|
5
5
|
"description": "A set of utility functions for CoffeeScript",
|
6
6
|
"main": "coffee_utils.js",
|
7
7
|
"exports": {
|
@@ -50,7 +50,7 @@
|
|
50
50
|
},
|
51
51
|
"homepage": "https://github.com/johndeighan/coffee-utils#readme",
|
52
52
|
"dependencies": {
|
53
|
-
"@jdeighan/exceptions": "^1.0.
|
53
|
+
"@jdeighan/exceptions": "^1.0.12",
|
54
54
|
"cross-env": "^7.0.3",
|
55
55
|
"js-yaml": "^4.1.0",
|
56
56
|
"n-readlines": "^1.0.1",
|
@@ -58,6 +58,6 @@
|
|
58
58
|
"svelte": "^3.52.0"
|
59
59
|
},
|
60
60
|
"devDependencies": {
|
61
|
-
"@jdeighan/unit-tester": "^2.0.
|
61
|
+
"@jdeighan/unit-tester": "^2.0.37"
|
62
62
|
}
|
63
63
|
}
|
package/src/utils.coffee
CHANGED
@@ -21,9 +21,8 @@ export {
|
|
21
21
|
}
|
22
22
|
|
23
23
|
# ---------------------------------------------------------------------------
|
24
|
-
# TEMP!!!!!
|
25
24
|
|
26
|
-
export
|
25
|
+
export isHashComment = (line) =>
|
27
26
|
|
28
27
|
lMatches = line.match(///^
|
29
28
|
\s*
|
@@ -75,6 +74,22 @@ export oneof = (word, lWords...) ->
|
|
75
74
|
|
76
75
|
# ---------------------------------------------------------------------------
|
77
76
|
|
77
|
+
export removeKeys = (h, lKeys) =>
|
78
|
+
|
79
|
+
for key in lKeys
|
80
|
+
delete h[key]
|
81
|
+
for own key,value of h
|
82
|
+
if defined(value)
|
83
|
+
if isArray(value)
|
84
|
+
for item in value
|
85
|
+
if isHash(item)
|
86
|
+
removeKeys(item, lKeys)
|
87
|
+
else if (typeof value == 'object')
|
88
|
+
removeKeys value, lKeys
|
89
|
+
return
|
90
|
+
|
91
|
+
# ---------------------------------------------------------------------------
|
92
|
+
|
78
93
|
export isNonEmptyString = (x) ->
|
79
94
|
|
80
95
|
if typeof x != 'string' && x ! instanceof String
|
package/src/utils.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
// Generated by CoffeeScript 2.7.0
|
2
|
-
|
2
|
+
// utils.coffee
|
3
|
+
var hasProp = {}.hasOwnProperty;
|
4
|
+
|
3
5
|
import {
|
4
6
|
assert,
|
5
7
|
croak
|
@@ -76,8 +78,7 @@ export {
|
|
76
78
|
};
|
77
79
|
|
78
80
|
// ---------------------------------------------------------------------------
|
79
|
-
|
80
|
-
export var isComment = (line) => {
|
81
|
+
export var isHashComment = (line) => {
|
81
82
|
var lMatches;
|
82
83
|
lMatches = line.match(/^\s*\#(\s|$)/);
|
83
84
|
return defined(lMatches);
|
@@ -122,6 +123,31 @@ export var oneof = function(word, ...lWords) {
|
|
122
123
|
return lWords.indexOf(word) >= 0;
|
123
124
|
};
|
124
125
|
|
126
|
+
// ---------------------------------------------------------------------------
|
127
|
+
export var removeKeys = (h, lKeys) => {
|
128
|
+
var i, item, j, key, len, len1, value;
|
129
|
+
for (i = 0, len = lKeys.length; i < len; i++) {
|
130
|
+
key = lKeys[i];
|
131
|
+
delete h[key];
|
132
|
+
}
|
133
|
+
for (key in h) {
|
134
|
+
if (!hasProp.call(h, key)) continue;
|
135
|
+
value = h[key];
|
136
|
+
if (defined(value)) {
|
137
|
+
if (isArray(value)) {
|
138
|
+
for (j = 0, len1 = value.length; j < len1; j++) {
|
139
|
+
item = value[j];
|
140
|
+
if (isHash(item)) {
|
141
|
+
removeKeys(item, lKeys);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
} else if (typeof value === 'object') {
|
145
|
+
removeKeys(value, lKeys);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
149
|
+
};
|
150
|
+
|
125
151
|
// ---------------------------------------------------------------------------
|
126
152
|
export var isNonEmptyString = function(x) {
|
127
153
|
if (typeof x !== 'string' && !(x instanceof String)) {
|