@jdeighan/coffee-utils 10.0.8 → 10.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "10.0.8",
4
+ "version": "10.0.9",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -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+/)
@@ -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+/);