was.js

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 33  →  ?path2? @ 34
/trunk/dist/was.js
@@ -1,6 +1,6 @@
/*! 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 */
/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
function wasProduct(a, b) {
@@ -113,12 +113,14 @@
/*************************************************************************/
/* Node.JS package export. */
/*************************************************************************/
module.exports.collections = {
product: wasProduct,
stride: wasStride,
chunk: wasChunk,
equals: wasEquals
};
if(typeof variable !== 'undefined') {
module.exports.collections = {
product: wasProduct,
stride: wasStride,
chunk: wasChunk,
equals: wasEquals
};
}
 
/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
@@ -179,10 +181,13 @@
/*************************************************************************/
/* Node.JS package export. */
/*************************************************************************/
module.exports.formats = {
CSVToArray: wasCSVToArray,
ArrayToCSV: wasArrayToCSV
};
if(typeof variable !== 'undefined') {
module.exports.formats = {
CSVToArray: wasCSVToArray,
ArrayToCSV: wasArrayToCSV
};
}
 
/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
function wasKeyValueToObject(a) {
@@ -203,9 +208,12 @@
/*************************************************************************/
/* Node.JS package export. */
/*************************************************************************/
module.exports.formats = {
KeyValueToObject: wasKeyValueToObject
};
if(typeof variable !== 'undefined') {
module.exports.formats = {
KeyValueToObject: wasKeyValueToObject
};
}
 
/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
/* fuss/lambda_calculus/functional_programming/aggregators @ grimore.org */
@@ -248,9 +256,11 @@
/*************************************************************************/
/* Node.JS package export. */
/*************************************************************************/
module.exports.lambda = {
switch: wasSwitch
};
if(typeof variable !== 'undefined') {
module.exports.lambda = {
switch: wasSwitch
};
}
 
/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
@@ -263,9 +273,11 @@
/*************************************************************************/
/* Node.JS package export. */
/*************************************************************************/
module.exports.mathematics = {
MapValueToRange: wasMapValueToRange
};
if(typeof variable !== 'undefined') {
module.exports.mathematics = {
MapValueToRange: wasMapValueToRange
};
}
 
/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */
/*************************************************************************/
@@ -301,7 +313,9 @@
/*************************************************************************/
/* Node.JS package export. */
/*************************************************************************/
module.exports.physics = {
HexToRGB: wasHexToRGB,
RGBToHex: wasRGBToHex
};
if(typeof variable !== 'undefined') {
module.exports.physics = {
HexToRGB: wasHexToRGB,
RGBToHex: wasRGBToHex
};
}
/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});
/trunk/lib/collections/arrays/arrays.js
@@ -111,9 +111,11 @@
/*************************************************************************/
/* Node.JS package export. */
/*************************************************************************/
module.exports.collections = {
product: wasProduct,
stride: wasStride,
chunk: wasChunk,
equals: wasEquals
};
if(typeof variable !== 'undefined') {
module.exports.collections = {
product: wasProduct,
stride: wasStride,
chunk: wasChunk,
equals: wasEquals
};
}
/trunk/lib/formats/csv/csv.js
@@ -58,7 +58,9 @@
/*************************************************************************/
/* Node.JS package export. */
/*************************************************************************/
module.exports.formats = {
CSVToArray: wasCSVToArray,
ArrayToCSV: wasArrayToCSV
};
if(typeof variable !== 'undefined') {
module.exports.formats = {
CSVToArray: wasCSVToArray,
ArrayToCSV: wasArrayToCSV
};
}
/trunk/lib/formats/kvp/kvp.js
@@ -19,6 +19,8 @@
/*************************************************************************/
/* Node.JS package export. */
/*************************************************************************/
module.exports.formats = {
KeyValueToObject: wasKeyValueToObject
};
if(typeof variable !== 'undefined') {
module.exports.formats = {
KeyValueToObject: wasKeyValueToObject
};
}
/trunk/lib/lambda/aggregators.js
@@ -41,6 +41,8 @@
/*************************************************************************/
/* Node.JS package export. */
/*************************************************************************/
module.exports.lambda = {
switch: wasSwitch
};
if(typeof variable !== 'undefined') {
module.exports.lambda = {
switch: wasSwitch
};
}
/trunk/lib/mathematics/algebra.js
@@ -10,6 +10,8 @@
/*************************************************************************/
/* Node.JS package export. */
/*************************************************************************/
module.exports.mathematics = {
MapValueToRange: wasMapValueToRange
};
if(typeof variable !== 'undefined') {
module.exports.mathematics = {
MapValueToRange: wasMapValueToRange
};
}
/trunk/lib/physics/colorimetry.js
@@ -33,7 +33,9 @@
/*************************************************************************/
/* Node.JS package export. */
/*************************************************************************/
module.exports.physics = {
HexToRGB: wasHexToRGB,
RGBToHex: wasRGBToHex
};
if(typeof variable !== 'undefined') {
module.exports.physics = {
HexToRGB: wasHexToRGB,
RGBToHex: wasRGBToHex
};
}
/trunk/package.json
@@ -44,5 +44,5 @@
"scripts": {
"test": "tap test/*.js"
},
"version": "1.0.0"
"version": "1.0.1"
}