@jdeighan/coffee-utils 10.0.14 → 10.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/coffee_utils.coffee +14 -0
- package/src/coffee_utils.js +19 -0
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jdeighan/coffee-utils",
|
3
3
|
"type": "module",
|
4
|
-
"version": "10.0.
|
4
|
+
"version": "10.0.16",
|
5
5
|
"description": "A set of utility functions for CoffeeScript",
|
6
6
|
"main": "coffee_utils.js",
|
7
7
|
"exports": {
|
@@ -54,9 +54,9 @@
|
|
54
54
|
"js-yaml": "^4.1.0",
|
55
55
|
"n-readlines": "^1.0.1",
|
56
56
|
"readline-sync": "^1.4.10",
|
57
|
-
"svelte": "^3.
|
57
|
+
"svelte": "^3.50.1"
|
58
58
|
},
|
59
59
|
"devDependencies": {
|
60
|
-
"@jdeighan/unit-tester": "^2.0.
|
60
|
+
"@jdeighan/unit-tester": "^2.0.24"
|
61
61
|
}
|
62
62
|
}
|
package/src/coffee_utils.coffee
CHANGED
@@ -633,3 +633,17 @@ export setCharsAt = (str, pos, str2) ->
|
|
633
633
|
else
|
634
634
|
return str.substring(0, pos) + str2 + str.substring(pos + str2.length)
|
635
635
|
|
636
|
+
# ---------------------------------------------------------------------------
|
637
|
+
|
638
|
+
export getOptions = (hOptions, hDefault={}) ->
|
639
|
+
# --- If hOptions is a string, break into words and set each to true
|
640
|
+
|
641
|
+
if isString(hOptions)
|
642
|
+
h = {}
|
643
|
+
for word in words(hOptions)
|
644
|
+
h[word] = true
|
645
|
+
return h
|
646
|
+
else if isHash(hOptions)
|
647
|
+
return hOptions
|
648
|
+
else
|
649
|
+
return hDefault
|
package/src/coffee_utils.js
CHANGED
@@ -712,3 +712,22 @@ export var setCharsAt = function(str, pos, str2) {
|
|
712
712
|
return str.substring(0, pos) + str2 + str.substring(pos + str2.length);
|
713
713
|
}
|
714
714
|
};
|
715
|
+
|
716
|
+
// ---------------------------------------------------------------------------
|
717
|
+
export var getOptions = function(hOptions, hDefault = {}) {
|
718
|
+
var h, i, len1, ref, word;
|
719
|
+
// --- If hOptions is a string, break into words and set each to true
|
720
|
+
if (isString(hOptions)) {
|
721
|
+
h = {};
|
722
|
+
ref = words(hOptions);
|
723
|
+
for (i = 0, len1 = ref.length; i < len1; i++) {
|
724
|
+
word = ref[i];
|
725
|
+
h[word] = true;
|
726
|
+
}
|
727
|
+
return h;
|
728
|
+
} else if (isHash(hOptions)) {
|
729
|
+
return hOptions;
|
730
|
+
} else {
|
731
|
+
return hDefault;
|
732
|
+
}
|
733
|
+
};
|