was.js

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 33  →  ?path2? @ 34
/trunk/dist/was.min.js
@@ -1,5 +1,5 @@
/*! was.js - v1.0.0 - 2018-02-11
/*! was.js - v1.0.1 - 2019-03-04
* http://grimore.org
* Copyright (c) 2018 [object Object]; Licensed GPL-3.0 */
* Copyright (c) 2019 [object Object]; Licensed GPL-3.0 */
 
function wasProduct(r,t){for(var e=Math.max(r.length,t.length),n={},a=0;a<e;++a)n[r[a]]=t[a];return n}function wasStride(r,t){return r.filter(function(r,e){return e%t==0})}function wasChunk(r,t){return r.length?[r.slice(0,t)].concat(r.slice(t).wasChunk(t)):[]}function wasEquals(r,t){if(!t)return!1;if(r.length!==t.length)return!1;for(var e=0,n=r.length;e<n;e++)if(r[e]instanceof Array&&t[e]instanceof Array){if(!r[e].equals(t[e]))return!1}else if(r[e]!==t[e])return!1;return!0}function wasCSVToArray(r){var t=[],e=[],n="";do{var a=r.charAt(0);if(r=r.slice(1,r.length),","!==a)if('"'!==a||r.charAt(0)!==a)if('"'!==a)n+=a;else{if(e[e.length-1]!==a){e.push(a);continue}e.pop()}else n+=a,r=r.slice(1,r.length);else{if('"'!==e[e.length-1]){t.push(n),n="";continue}n+=a}}while(""!==r);return t.push(n),t}function wasArrayToCSV(r){for(var t=[],e=0;e<r.length;++e){var n=r[e].toString().replace('"','""');/"\s,\r\n/.test(n)?t[e]='"'+n+'"':t[e]=n}return t.join()}function wasKeyValueToObject(r){var t={};return r.reduce(function(r,t,e){return r[e=Math.floor(e/2)]||(r[e]=[]),r[e].push(t),r},[]).forEach(function(r,e,n){t[r[0]]=r[1]},t),t}function wasSwitch(r,t,...e){if(e.length%2!=0)throw"Pairs of predicates expected for cases";(Array.isArray(r)?r:[r]).forEach(r=>{for(var n=!1,a=0;a<e.length;a+=2)e[a](r)&&e[a+1](r)&&(n=!0);n||t(r)})}function wasMapValueToRange(r,t,e,n,a){return n+(a-n)*(r-t)/(e-t)}function wasHexToRGB(r){r=r.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(r,t,e,n){return t+t+e+e+n+n});var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function wasRGBToHex(r,t,e){return"#"+((1<<24)+(r<<16)+(t<<8)+e).toString(16).slice(1)}Array.prototype.product||(Array.prototype.product=function(r){return wasProduct(this,r)}),"function"==typeof jQuery&&$.extend({product:wasProduct}),Array.prototype.stride||(Array.prototype.stride=function(r){return wasStride(this,r)}),"function"==typeof jQuery&&$.extend({stride:wasStride}),Array.prototype.chunk||(Array.prototype.chunk=function(r,t){return wasChunk(this,t)}),"function"==typeof jQuery&&$.extend({chunk:wasChunk}),Array.prototype.equals||(Array.prototype.equals=function(r,t){return wasEquals(this,t)}),"function"==typeof jQuery&&$.extend({equals:wasEquals}),module.exports.collections={product:wasProduct,stride:wasStride,chunk:wasChunk,equals:wasEquals},module.exports.formats={CSVToArray:wasCSVToArray,ArrayToCSV:wasArrayToCSV},module.exports.formats={KeyValueToObject:wasKeyValueToObject},Array.prototype.switch||(Array.prototype.switch=function(r,...t){wasSwitch(this,r,...t)}),"function"==typeof jQuery&&$.extend({switch:wasSwitch}),module.exports.lambda={switch:wasSwitch},module.exports.mathematics={MapValueToRange:wasMapValueToRange},module.exports.physics={HexToRGB:wasHexToRGB,RGBToHex:wasRGBToHex};
function wasProduct(e,r){for(var t=Math.max(e.length,r.length),n={},a=0;a<t;++a)n[e[a]]=r[a];return n}function wasStride(e,r){return e.filter(function(e,t){return t%r==0})}function wasChunk(e,r){return e.length?[e.slice(0,r)].concat(e.slice(r).wasChunk(r)):[]}function wasEquals(e,r){if(!r)return!1;if(e.length!==r.length)return!1;for(var t=0,n=e.length;t<n;t++)if(e[t]instanceof Array&&r[t]instanceof Array){if(!e[t].equals(r[t]))return!1}else if(e[t]!==r[t])return!1;return!0}function wasCSVToArray(e){var r=[],t=[],n="";do{var a=e.charAt(0);if(e=e.slice(1,e.length),","!==a)if('"'!==a||e.charAt(0)!==a)if('"'!==a)n+=a;else{if(t[t.length-1]!==a){t.push(a);continue}t.pop()}else n+=a,e=e.slice(1,e.length);else{if('"'!==t[t.length-1]){r.push(n),n="";continue}n+=a}}while(""!==e);return r.push(n),r}function wasArrayToCSV(e){for(var r=[],t=0;t<e.length;++t){var n=e[t].toString().replace('"','""');/"\s,\r\n/.test(n)?r[t]='"'+n+'"':r[t]=n}return r.join()}function wasKeyValueToObject(e){var r={};return e.reduce(function(e,r,t){return e[t=Math.floor(t/2)]||(e[t]=[]),e[t].push(r),e},[]).forEach(function(e,t,n){r[e[0]]=e[1]},r),r}function wasSwitch(e,r,...t){if(t.length%2!=0)throw"Pairs of predicates expected for cases";(Array.isArray(e)?e:[e]).forEach(e=>{for(var n=!1,a=0;a<t.length;a+=2)t[a](e)&&t[a+1](e)&&(n=!0);n||r(e)})}function wasMapValueToRange(e,r,t,n,a){return n+(a-n)*(e-r)/(t-r)}function wasHexToRGB(e){e=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(e,r,t,n){return r+r+t+t+n+n});var r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return r?{r:parseInt(r[1],16),g:parseInt(r[2],16),b:parseInt(r[3],16)}:null}function wasRGBToHex(e,r,t){return"#"+((1<<24)+(e<<16)+(r<<8)+t).toString(16).slice(1)}Array.prototype.product||(Array.prototype.product=function(e){return wasProduct(this,e)}),"function"==typeof jQuery&&$.extend({product:wasProduct}),Array.prototype.stride||(Array.prototype.stride=function(e){return wasStride(this,e)}),"function"==typeof jQuery&&$.extend({stride:wasStride}),Array.prototype.chunk||(Array.prototype.chunk=function(e,r){return wasChunk(this,r)}),"function"==typeof jQuery&&$.extend({chunk:wasChunk}),Array.prototype.equals||(Array.prototype.equals=function(e,r){return wasEquals(this,r)}),"function"==typeof jQuery&&$.extend({equals:wasEquals}),"undefined"!=typeof variable&&(module.exports.collections={product:wasProduct,stride:wasStride,chunk:wasChunk,equals:wasEquals}),"undefined"!=typeof variable&&(module.exports.formats={CSVToArray:wasCSVToArray,ArrayToCSV:wasArrayToCSV}),"undefined"!=typeof variable&&(module.exports.formats={KeyValueToObject:wasKeyValueToObject}),Array.prototype.switch||(Array.prototype.switch=function(e,...r){wasSwitch(this,e,...r)}),"function"==typeof jQuery&&$.extend({switch:wasSwitch}),"undefined"!=typeof variable&&(module.exports.lambda={switch:wasSwitch}),"undefined"!=typeof variable&&(module.exports.mathematics={MapValueToRange:wasMapValueToRange}),"undefined"!=typeof variable&&(module.exports.physics={HexToRGB:wasHexToRGB,RGBToHex:wasRGBToHex});