@xassist/xassist-array
Version:
helper functions for javascript arrays
7 lines • 899 B
JavaScript
/**
* @preserve
* https://github.com/GregBee2/xassist-array#readme Version 1.0.2.
* Copyright 2018 Gregory Beirens.
* Created on Tue, 17 Apr 2018 10:36:22 GMT.
*/
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(n.xa=n.xa||{})}(this,function(n){"use strict";n.array=function(n){return{pushUnique:function(n,e,u){return(u=void 0===u||!!u)&&-1!==n.indexOf(e)?n.length:n.push(e)}.bind(null,n),groupSequence:function(n,r){return n.reduce(function(n,e,u,t){return u&&r(t[u-1],e)?n[n.length-1].push(e):n.push([e]),n},[])}.bind(null,n),replaceNull:function(n,u){var e,t=[];e=Array.isArray(u)?function(n,e){return u[e]}:"function"==typeof u?u:function(){return u};for(var r,i=0,o=n.length;i<o;i++)null==(r=n[i])?t.push(e(r,i)):t.push(r);return t}.bind(null,n)}},Object.defineProperty(n,"__esModule",{value:!0})});