Comparing version 0.5.0 to 0.6.0
@@ -9,2 +9,4 @@ 'use strict'; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
@@ -14,11 +16,4 @@ | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
/* | ||
This module is meant to be a module that you can use without | ||
any dependencies. | ||
*/ | ||
// enumFromTo(x,y) = [x,x+1,x+2...y] | ||
// only guarantee to work on increasing sequences | ||
// override 'succ' and 'cond' for custom generating behavior | ||
var enumFromTo = function enumFromTo(frm, to) { | ||
@@ -28,5 +23,8 @@ var succ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (x) { | ||
}; | ||
var cond = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (x) { | ||
return x <= to; | ||
}; | ||
var arr = []; | ||
for (var i = frm; i <= to; i = succ(i)) { | ||
for (var i = frm; cond(i); i = succ(i)) { | ||
arr.push(i); | ||
@@ -47,22 +45,2 @@ }return arr; | ||
// "modifyArray(index,f)(xs)" keeps "xs" intact and returns a new array | ||
// whose element on "index" is modified by feeding original value to "f". | ||
// if "index" is out of range, "xs" itself is returned. | ||
var modifyArray = function modifyArray(index, f) { | ||
if (typeof index !== 'number') console.error('index is not a number'); | ||
if (typeof f !== 'function') console.error('modifier is not a function'); | ||
return function (xs) { | ||
if (index < 0 || index >= xs.length) return xs; | ||
var ys = [].concat(_toConsumableArray(xs)); | ||
var v = ys[index]; | ||
var newV = f(v); | ||
if (v !== newV) { | ||
ys[index] = newV; | ||
return ys; | ||
} else { | ||
return xs; | ||
} | ||
}; | ||
}; | ||
// modifyObject(propName,f)(xs)" is like "modifyArray" for Objects. | ||
@@ -105,11 +83,2 @@ // Additionally, if you set `removeUndefined` to true, | ||
var scan = function scan(xs, acc, zero) { | ||
var ys = new Array(xs.length + 1); | ||
ys[0] = zero; | ||
for (var i = 0; i < xs.length; ++i) { | ||
ys[i + 1] = acc(ys[i], xs[i]); | ||
} | ||
return ys; | ||
}; | ||
// copied from redux | ||
@@ -154,7 +123,5 @@ // originally https://github.com/reactjs/redux/blob/master/src/compose.js | ||
exports.not = not; | ||
exports.modifyArray = modifyArray; | ||
exports.modifyObject = modifyObject; | ||
exports.singObj = singObj; | ||
exports.scan = scan; | ||
exports.compose = compose; | ||
exports.precompose = precompose; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -10,21 +10,33 @@ | ||
Object.keys(_common).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _common[key]; | ||
} | ||
}); | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _common[key]; | ||
} | ||
}); | ||
}); | ||
var _arrayOps = require('./array-ops'); | ||
Object.keys(_arrayOps).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _arrayOps[key]; | ||
} | ||
}); | ||
}); | ||
var _memoizeFixedArity = require('./memoize-fixed-arity'); | ||
Object.keys(_memoizeFixedArity).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _memoizeFixedArity[key]; | ||
} | ||
}); | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _memoizeFixedArity[key]; | ||
} | ||
}); | ||
}); | ||
@@ -35,9 +47,9 @@ | ||
Object.keys(_objectZipper).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _objectZipper[key]; | ||
} | ||
}); | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _objectZipper[key]; | ||
} | ||
}); | ||
}); | ||
@@ -48,9 +60,9 @@ | ||
Object.keys(_sortedMap).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _sortedMap[key]; | ||
} | ||
}); | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _sortedMap[key]; | ||
} | ||
}); | ||
}); |
@@ -6,37 +6,40 @@ 'use strict'; | ||
}); | ||
exports.SortedMap = undefined; | ||
var _arrayOps = require('./array-ops'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } /* | ||
a SortedMap is a javascript Array whose elements are already sorted in some way. | ||
important terms: | ||
- `key` & `elementToKey` : every element of the Array should have an unique key | ||
which is determined by calling elementToKey(<element>) | ||
- `compareKey`: the way two keys are compared, following the same protocol as | ||
`compareFunction` in `Array.prototype.sort(<compareFunction>)` | ||
- `smContext`: an Object that at least has shaped `{ elementToKey, compareKey }`. | ||
assumption: | ||
- It is assumed that a SortedMap will not contain any `undefined` value, | ||
and if any edit attempt end up returning `undefined`, | ||
the corresponding element is removed from SortedMap | ||
*/ | ||
/* | ||
the default SortedMap context: | ||
assume that every element has a 'key' property, | ||
a SortedMap is a javascript Array whose elements are already sorted in some way. | ||
basically generalComparator works on any value that supports | ||
`===` and `<` and `>`, check its definition in ./array-ops.js for details. | ||
important terms: | ||
- `key` & `elementToKey` : every element of the Array should have an unique key | ||
which is determined by calling elementToKey(<element>) | ||
- `compareKey`: the way two keys are compared, following the same protocol as | ||
`compareFunction` in `Array.prototype.sort(<compareFunction>)` | ||
- `smContext`: an Object that at least has shaped `{ elementToKey, compareKey }`. | ||
assumption: | ||
- It is assumed that a SortedMap will not contain any `undefined` value, | ||
and if any edit attempt end up returning `undefined`, | ||
the corresponding element is removed from SortedMap | ||
*/ | ||
/* | ||
the default SortedMap context: | ||
assume that every element has a 'key' property, | ||
which can be compared by '<' and '>' | ||
it's assumed that `!(x < y) || !(x > y)` suggests x and y is equal. | ||
*/ | ||
var defaultSmContext = { | ||
@@ -46,5 +49,3 @@ elementToKey: function elementToKey(v) { | ||
}, | ||
compareKey: function compareKey(x, y) { | ||
return x > y ? 1 : x < y ? -1 : 0; | ||
} | ||
compareKey: _arrayOps.generalComparator | ||
@@ -115,7 +116,2 @@ /* | ||
// TODO: this one can be lifted into common | ||
var insertAt = function insertAt(ind, val) { | ||
return function (xs) { | ||
return [].concat(_toConsumableArray(xs.slice(0, ind)), [val], _toConsumableArray(xs.slice(ind, xs.length))); | ||
}; | ||
}; | ||
@@ -162,3 +158,3 @@ /* | ||
if (typeof _newVal !== 'undefined') { | ||
return insertAt(0, _newVal)(xs); | ||
return (0, _arrayOps.insertAt)(0, _newVal)(xs); | ||
} else { | ||
@@ -190,5 +186,5 @@ return xs; | ||
// xs[ind].key < key | ||
return insertAt(ind + 1, newVal)(xs); | ||
return (0, _arrayOps.insertAt)(ind + 1, newVal)(xs); | ||
} else { | ||
return insertAt(ind, newVal)(xs); | ||
return (0, _arrayOps.insertAt)(ind, newVal)(xs); | ||
} | ||
@@ -195,0 +191,0 @@ }; |
{ | ||
"name": "subtender", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Javran's utility functions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46036
11
831