@jdeighan/coffee-utils 10.0.8 → 10.0.9
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/coffee_utils.coffee +16 -0
- package/src/coffee_utils.js +15 -0
package/package.json
CHANGED
package/src/coffee_utils.coffee
CHANGED
@@ -223,6 +223,22 @@ export nonEmpty = (x) ->
|
|
223
223
|
|
224
224
|
# ---------------------------------------------------------------------------
|
225
225
|
|
226
|
+
export notInArray = (lItems, item) ->
|
227
|
+
|
228
|
+
return (lItems.indexOf(item) == -1)
|
229
|
+
|
230
|
+
# ---------------------------------------------------------------------------
|
231
|
+
|
232
|
+
export pushCond = (lItems, item, doPush=notInArray) ->
|
233
|
+
|
234
|
+
if doPush(lItems, item)
|
235
|
+
lItems.push item
|
236
|
+
return true
|
237
|
+
else
|
238
|
+
return false
|
239
|
+
|
240
|
+
# ---------------------------------------------------------------------------
|
241
|
+
|
226
242
|
export words = (str) ->
|
227
243
|
|
228
244
|
return str.trim().split(/\s+/)
|
package/src/coffee_utils.js
CHANGED
@@ -236,6 +236,21 @@ export var nonEmpty = function(x) {
|
|
236
236
|
}
|
237
237
|
};
|
238
238
|
|
239
|
+
// ---------------------------------------------------------------------------
|
240
|
+
export var notInArray = function(lItems, item) {
|
241
|
+
return lItems.indexOf(item) === -1;
|
242
|
+
};
|
243
|
+
|
244
|
+
// ---------------------------------------------------------------------------
|
245
|
+
export var pushCond = function(lItems, item, doPush = notInArray) {
|
246
|
+
if (doPush(lItems, item)) {
|
247
|
+
lItems.push(item);
|
248
|
+
return true;
|
249
|
+
} else {
|
250
|
+
return false;
|
251
|
+
}
|
252
|
+
};
|
253
|
+
|
239
254
|
// ---------------------------------------------------------------------------
|
240
255
|
export var words = function(str) {
|
241
256
|
return str.trim().split(/\s+/);
|