| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.filter = exports.map = exports.headOp = exports.tail = exports.head = exports.join = undefined; | ||
| var _fp = require("../fp"); | ||
| 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 _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); } | ||
| var join = exports.join = (0, _fp.curry)(function (st, ar) { | ||
| return ar.join(st); | ||
| }); | ||
| var head = exports.head = function head(_ref) { | ||
| var _ref2 = _toArray(_ref), | ||
| x = _ref2[0], | ||
| xs = _ref2.slice(1); | ||
| return x; | ||
| }; | ||
| var tail = exports.tail = function tail(_ref3) { | ||
| var _ref4 = _toArray(_ref3), | ||
| x = _ref4[0], | ||
| xs = _ref4.slice(1); | ||
| return xs; | ||
| }; | ||
| var headOp = exports.headOp = (0, _fp.curry)(function (fn, x) { | ||
| return [fn(head(x))].concat(_toConsumableArray(tail(x))); | ||
| }); | ||
| var map = exports.map = (0, _fp.curry)(function (fn, arr) { | ||
| return arr.map(fn); | ||
| }); | ||
| var filter = exports.filter = (0, _fp.curry)(function (fn, x) { | ||
| return x.filter(fn); | ||
| }); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.safeProp = exports.prop = undefined; | ||
| var _Either = require("../Either"); | ||
| var _fp = require("../fp"); | ||
| var prop = exports.prop = (0, _fp.curry)(function (prop, obj) { | ||
| return obj[prop]; | ||
| }); | ||
| var safeProp = exports.safeProp = (0, _fp.curry)(function (p, obj) { | ||
| return (0, _fp.compose)(_Either.fromNullable, prop(p))(obj); | ||
| }); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.capitalize = exports.notEmptyString = exports.isEmptyString = exports.firstCapital = exports.concat = exports.fromCharCode = exports.getCharCode = exports.split = exports.replace = exports.toLower = exports.toUpper = exports.trim = undefined; | ||
| var _fp = require("../fp"); | ||
| var _array = require("../array"); | ||
| var trim = exports.trim = function trim(x) { | ||
| return x.trim(); | ||
| }; | ||
| var toUpper = exports.toUpper = function toUpper(str) { | ||
| return str.toUpperCase(); | ||
| }; | ||
| var toLower = exports.toLower = function toLower(str) { | ||
| return str.toLowerCase(); | ||
| }; | ||
| var replace = exports.replace = (0, _fp.curry)(function (match, withStr, str) { | ||
| return str.replace(match, withStr); | ||
| }); | ||
| var split = exports.split = (0, _fp.curry)(function (sp, str) { | ||
| return str.split(sp); | ||
| }); | ||
| var getCharCode = exports.getCharCode = function getCharCode(x) { | ||
| return x.charCodeAt(0); | ||
| }; | ||
| var fromCharCode = exports.fromCharCode = function fromCharCode(x) { | ||
| return String.fromCharCode(x); | ||
| }; | ||
| var concat = exports.concat = (0, _fp.curry)(function (x, y) { | ||
| return x.concat(y); | ||
| }); | ||
| var firstCapital = exports.firstCapital = (0, _fp.compose)((0, _array.join)(""), (0, _array.headOp)(toUpper), trim); | ||
| var isEmptyString = exports.isEmptyString = function isEmptyString(x) { | ||
| return x === ""; | ||
| }; | ||
| var notEmptyString = exports.notEmptyString = function notEmptyString(x) { | ||
| return x !== ""; | ||
| }; | ||
| var capitalize = exports.capitalize = (0, _fp.compose)((0, _array.join)(" "), (0, _array.map)(firstCapital), (0, _array.filter)(notEmptyString), split(/\s+/g)); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| var throttle = exports.throttle = function throttle(callback) { | ||
| var sec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
| var currentTime = 0; | ||
| return function () { | ||
| var presentTime = Date.now(); | ||
| if (presentTime - currentTime >= sec) { | ||
| callback.apply(undefined, arguments); | ||
| currentTime = presentTime; | ||
| } | ||
| }; | ||
| }; |
+1
-11
@@ -6,6 +6,3 @@ "use strict"; | ||
| }); | ||
| exports.safeProp = exports.prop = exports.compose = exports.curry = undefined; | ||
| var _Either = require("../Either"); | ||
| 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); } } | ||
@@ -38,9 +35,2 @@ | ||
| }; | ||
| }; | ||
| var prop = exports.prop = curry(function (prop, obj) { | ||
| return obj[prop]; | ||
| }); | ||
| var safeProp = exports.safeProp = curry(function (p, obj) { | ||
| return compose(_Either.fromNullable, prop(p))(obj); | ||
| }); | ||
| }; |
+48
-0
@@ -49,2 +49,50 @@ "use strict"; | ||
| var _object = require("./object"); | ||
| Object.keys(_object).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function get() { | ||
| return _object[key]; | ||
| } | ||
| }); | ||
| }); | ||
| var _string = require("./string"); | ||
| Object.keys(_string).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function get() { | ||
| return _string[key]; | ||
| } | ||
| }); | ||
| }); | ||
| var _array = require("./array"); | ||
| Object.keys(_array).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function get() { | ||
| return _array[key]; | ||
| } | ||
| }); | ||
| }); | ||
| var _throttle = require("./throttle"); | ||
| Object.keys(_throttle).forEach(function (key) { | ||
| if (key === "default" || key === "__esModule") return; | ||
| Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: function get() { | ||
| return _throttle[key]; | ||
| } | ||
| }); | ||
| }); | ||
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
+3
-2
| { | ||
| "name": "fp-small", | ||
| "version": "1.1.3", | ||
| "version": "1.2.0", | ||
| "description": "A small functional programming library", | ||
@@ -12,3 +12,4 @@ "main": "dist/index.js", | ||
| "build": "babel --out-dir dist --ignore *.test.js src", | ||
| "pre-build": "rimraf dist" | ||
| "pre-build": "rimraf dist", | ||
| "test:watch": "jest --watch" | ||
| }, | ||
@@ -15,0 +16,0 @@ "repository": { |
14781
43.01%12
50%379
50.4%