@jdeighan/coffee-utils 10.0.15 → 10.0.16
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 +1 -1
- package/src/coffee_utils.coffee +14 -0
- package/src/coffee_utils.js +19 -0
package/package.json
CHANGED
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
|
+
};
|