was.js

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 39  →  ?path2? @ 40
/trunk/dist/was.js
@@ -1,4 +1,4 @@
/*! was.js - v1.0.1 - 2019-08-01
/*! was.js - v1.0.3 - 2019-08-01
* http://grimore.org
* Copyright (c) 2019 [object Object]; Licensed GPL-3.0 */
/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */
@@ -218,13 +218,12 @@
/*************************************************************************/
/* fuss/lambda_calculus/functional_programming/aggregators @ grimore.org */
/*************************************************************************/
// Vanilla ES6 JavaScript
function wasSwitch() {
if(arguments.length - 2 % 2 !== 0) {
if(arguments.length % 2 !== 0) {
throw "Pairs of predicates expected for cases";
}
(Array.isArray(arguments[0]) ? arguments[0] : [ arguments[0] ]).forEach((s) => {
(Array.isArray(arguments[0]) ? arguments[0] : [ arguments[0] ]).forEach(function(s) {
var m = false;
for(var i = 2; i < arguments.length; i += 2) {
if(!arguments[i](s)) {
/trunk/dist/was.min.js
@@ -1,5 +1,5 @@
/*! was.js - v1.0.1 - 2019-08-01
/*! was.js - v1.0.3 - 2019-08-01
* http://grimore.org
* Copyright (c) 2019 [object Object]; Licensed GPL-3.0 */
 
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(){if(arguments.length-0!=0)throw"Pairs of predicates expected for cases";(Array.isArray(arguments[0])?arguments[0]:[arguments[0]]).forEach(e=>{for(var r=!1,t=2;t<arguments.length;t+=2)arguments[t](e)&&arguments[t+1](e)&&(r=!0);r||arguments[1](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(){wasSwitch(this,arguments[0],arguments.slice(1))}),"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});
function wasProduct(e,t){for(var r=Math.max(e.length,t.length),n={},a=0;a<r;++a)n[e[a]]=t[a];return n}function wasStride(e,t){return e.filter(function(e,r){return r%t==0})}function wasChunk(e,t){return e.length?[e.slice(0,t)].concat(e.slice(t).wasChunk(t)):[]}function wasEquals(e,t){if(!t)return!1;if(e.length!==t.length)return!1;for(var r=0,n=e.length;r<n;r++)if(e[r]instanceof Array&&t[r]instanceof Array){if(!e[r].equals(t[r]))return!1}else if(e[r]!==t[r])return!1;return!0}function wasCSVToArray(e){var t=[],r=[],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(r[r.length-1]!==a){r.push(a);continue}r.pop()}else n+=a,e=e.slice(1,e.length);else{if('"'!==r[r.length-1]){t.push(n),n="";continue}n+=a}}while(""!==e);return t.push(n),t}function wasArrayToCSV(e){for(var t=[],r=0;r<e.length;++r){var n=e[r].toString().replace('"','""');/"\s,\r\n/.test(n)?t[r]='"'+n+'"':t[r]=n}return t.join()}function wasKeyValueToObject(e){var t={};return e.reduce(function(e,t,r){return e[r=Math.floor(r/2)]||(e[r]=[]),e[r].push(t),e},[]).forEach(function(e,r,n){t[e[0]]=e[1]},t),t}function wasSwitch(){if(arguments.length%2!=0)throw"Pairs of predicates expected for cases";(Array.isArray(arguments[0])?arguments[0]:[arguments[0]]).forEach(function(e){for(var t=!1,r=2;r<arguments.length;r+=2)arguments[r](e)&&arguments[r+1](e)&&(t=!0);t||arguments[1](e)})}function wasMapValueToRange(e,t,r,n,a){return n+(a-n)*(e-t)/(r-t)}function wasHexToRGB(e){e=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(e,t,r,n){return t+t+r+r+n+n});var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function wasRGBToHex(e,t,r){return"#"+((1<<24)+(e<<16)+(t<<8)+r).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,t){return wasChunk(this,t)}),"function"==typeof jQuery&&$.extend({chunk:wasChunk}),Array.prototype.equals||(Array.prototype.equals=function(e,t){return wasEquals(this,t)}),"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(){wasSwitch(this,arguments[0],arguments.slice(1))}),"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});
/trunk/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "was.js",
"version": "1.0.1",
"version": "1.0.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {