curve-store
Advanced tools
@@ -7,3 +7,3 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
@@ -14,12 +14,24 @@ var _utils = require('./utils'); | ||
var _lodash = require('lodash'); | ||
var _lodash = require('lodash.isfunction'); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _lodash3 = require('lodash.isobject'); | ||
var _lodash4 = _interopRequireDefault(_lodash3); | ||
var _lodash5 = require('lodash.isarray'); | ||
var _lodash6 = _interopRequireDefault(_lodash5); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var runSampler = function runSampler(sampler, time, state, sample) { | ||
if ((0, _lodash.isFunction)(sampler)) { | ||
if ((0, _lodash2.default)(sampler)) { | ||
return sampler(time, state, sample); | ||
} else if ((0, _lodash.isArray)(sampler)) { | ||
} else if ((0, _lodash6.default)(sampler)) { | ||
return sampler.map(function (s) { | ||
runSampler(s, time, state, sample); | ||
}); | ||
} else if ((0, _lodash.isObject)(sampler)) { | ||
} else if ((0, _lodash4.default)(sampler)) { | ||
var _ret = function () { | ||
@@ -78,7 +90,7 @@ var retObj = {}; | ||
if (typeof keys === 'string') { | ||
var s = (0, _lodash.isFunction)(samplers[keys]) ? samplers[keys] : (0, _samplers.linear)(keys); | ||
var s = (0, _lodash2.default)(samplers[keys]) ? samplers[keys] : (0, _samplers.linear)(keys); | ||
return runSampler(s, time, state); | ||
} | ||
var checkKeys = (0, _lodash.isArray)(keys); | ||
var checkKeys = (0, _lodash6.default)(keys); | ||
@@ -85,0 +97,0 @@ Object.keys(samplers).forEach(function (samplerName) { |
@@ -10,4 +10,12 @@ 'use strict'; | ||
var _lodash = require('lodash'); | ||
var _lodash = require('lodash.isfunction'); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _lodash3 = require('lodash.memoize'); | ||
var _lodash4 = _interopRequireDefault(_lodash3); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var linear = function linear(name) { | ||
@@ -36,3 +44,3 @@ return function (t, state) { | ||
var x2 = void 0; | ||
if ((0, _lodash.isFunction)(name)) { | ||
if ((0, _lodash2.default)(name)) { | ||
x1 = name(t - delta, state, sample); | ||
@@ -51,3 +59,3 @@ x2 = name(t, state, sample); | ||
var recursiveIntegral = (0, _lodash.memoize)(function (t, state, sample) { | ||
var recursiveIntegral = (0, _lodash4.default)(function (t, state, sample) { | ||
if (t === 0) { | ||
@@ -54,0 +62,0 @@ return 0; |
@@ -8,7 +8,11 @@ 'use strict'; | ||
var _lodash = require('lodash'); | ||
var _lodash = require('lodash.sortedindexby'); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var set = function set(array, time, value) { | ||
var arrayObj = { time: time, value: value }; | ||
var index = (0, _lodash.sortedIndexBy)(array, arrayObj, 'time'); | ||
var index = (0, _lodash2.default)(array, arrayObj, 'time'); | ||
array.splice(index, 0, value); | ||
@@ -19,3 +23,3 @@ }; | ||
var arrayObj = { time: time, value: value }; | ||
var index = (0, _lodash.sortedIndexBy)(array, arrayObj, 'time'); | ||
var index = (0, _lodash2.default)(array, arrayObj, 'time'); | ||
array.splice(index, array.length - index, arrayObj); | ||
@@ -25,3 +29,3 @@ }; | ||
var getPointsBefore = function getPointsBefore(array, time, n) { | ||
var index = (0, _lodash.sortedIndexBy)(array, { time: time }, 'time'); | ||
var index = (0, _lodash2.default)(array, { time: time }, 'time'); | ||
return array.slice(Math.max(0, index - n), index); | ||
@@ -31,3 +35,3 @@ }; | ||
var getPointsAfter = function getPointsAfter(array, time, n) { | ||
var index = (0, _lodash.sortedIndexBy)(array, { time: time }, 'time'); | ||
var index = (0, _lodash2.default)(array, { time: time }, 'time'); | ||
return array.slice(index, index + n); | ||
@@ -34,0 +38,0 @@ }; |
{ | ||
"name": "curve-store", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Redux-inspired store for dealing with continuous values", | ||
@@ -23,3 +23,7 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"lodash": "^4.15.0" | ||
"lodash.isarray": "^4.0.0", | ||
"lodash.isfunction": "^3.0.8", | ||
"lodash.isobject": "^3.0.2", | ||
"lodash.memoize": "^4.1.2", | ||
"lodash.sortedindexby": "^4.6.0" | ||
}, | ||
@@ -26,0 +30,0 @@ "devDependencies": { |
import { setAsLastPoint } from './utils'; | ||
import { linear } from './samplers'; | ||
import { isArray, isObject, isFunction } from 'lodash'; | ||
import isFunction from 'lodash.isfunction'; | ||
import isObject from 'lodash.isobject'; | ||
import isArray from 'lodash.isarray'; | ||
@@ -5,0 +7,0 @@ const runSampler = (sampler, time, state, sample) => { |
import { getPointBefore, getPointAfter, snap } from '../utils'; | ||
import { isFunction, memoize } from 'lodash'; | ||
import isFunction from 'lodash.isfunction'; | ||
import memoize from 'lodash.memoize'; | ||
@@ -4,0 +5,0 @@ const linear = (name) => { |
@@ -1,2 +0,2 @@ | ||
import { sortedIndexBy } from 'lodash'; | ||
import sortedIndexBy from 'lodash.sortedindexby'; | ||
@@ -3,0 +3,0 @@ const set = (array, time, value) => { |
24249
4.12%579
2.66%5
400%