New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@arction/xydata

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arction/xydata - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

12

CHANGELOG.md

@@ -18,5 +18,15 @@ # Change Log

## [1.1.0] - 2019-01-31
## [1.2.0] - 2020-04-02
### Added
- Node JS Support
### Changed
- Upgraded dependencies to latest released versions
- Updated documentation using latest TypeDoc generator
## [1.1.0] - 2020-01-31
### Added
- Parametric Function Generator

@@ -23,0 +33,0 @@

@@ -42,5 +42,5 @@ /*! *****************************************************************************

function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
return {
if (o && typeof o.length === "number") return {
next: function () {

@@ -51,2 +51,3 @@ if (o && i >= o.length) o = void 0;

};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}

@@ -279,2 +280,19 @@

var perfNow;
if (typeof window !== 'undefined' && window.performance && window.performance.now) {
perfNow = window.performance.now;
}
else {
try {
if (typeof require !== 'undefined') {
perfNow = require('perf_hooks').performance.now;
}
else {
throw new Error();
}
}
catch (e) {
throw new Error('Failed to detect "performance.now" API');
}
}
var DataGenerator = (function () {

@@ -296,5 +314,5 @@ function DataGenerator(args) {

DataGenerator.prototype.generateChunks = function (baseIndex, total, dataHost) {
var startTime = window.performance.now();
var startTime = perfNow();
var points = [];
for (var i = 0; window.performance.now() - startTime < 15 && baseIndex < total; i++) {
for (var i = 0; perfNow() - startTime < 15 && baseIndex < total; i++) {
var point = this.generateDataPoint(baseIndex);

@@ -301,0 +319,0 @@ baseIndex++;

2

dist/xydata.iife.js

@@ -1,1 +0,1 @@

var xydata=function(t){"use strict";var n=function(t,i){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])})(t,i)};function i(t,i){function r(){this.constructor=t}n(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var n,i=1,r=arguments.length;i<r;i++)for(var s in n=arguments[i])Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s]);return t}).apply(this,arguments)};var s=function(){function t(t,n){this.options=t,this.streamActive=!1,this.data=[],this.interval=this.options.interval||1e3,this.batchSize=this.options.batchSize||1,this.batchesLeft=-2,this.runStream=this.runStream.bind(this),this.infiniteReset=n,void 0!==t.repeat&&("boolean"==typeof t.repeat?this.batchesLeft=t.repeat?-1:-2:"number"==typeof t.repeat?this.batchesLeft=t.repeat+1:"function"==typeof t.repeat&&(this.continueHandler=t.repeat))}return t.prototype.consume=function(){var t=this,n=this.batchSize;this.data.length<this.batchSize&&(n=this.data.length);var i=this.data.splice(0,n);if((this.batchesLeft>0||-1===this.batchesLeft)&&i.length>0&&(this.data=this.data.concat(i.map(function(n){return t.infiniteReset(n)})),i.length<this.batchSize))for(;i.length<this.batchSize;){var r=this.data.splice(0,1)[0];this.data=this.data.concat(this.infiniteReset(r)),i.push(r)}return i},t.prototype.checkStreamContinue=function(){var t=this.batchesLeft>0||-1===this.batchesLeft||-2===this.batchesLeft&&this.data.length>0;return this.continueHandler&&(t=!0===this.continueHandler()),t},t.prototype.runStream=function(){var t=this.checkStreamContinue();if(this.data&&this.data.length>0&&t){if(this.streamHandler){var n=this.consume();this.streamHandler(n)}setTimeout(this.runStream,this.interval)}else this.streamActive=!1;this.batchesLeft>0&&this.batchesLeft--},t.prototype.activateStream=function(){this.streamActive||(this.streamActive=!0,this.runStream())},t.prototype.push=function(t){Array.isArray(t)?this.data=this.data.concat(t):this.data.push(t),this.activateStream()},t.prototype.map=function(n){return this.outputStream=new t(r(r({},this.options),{repeat:!1}),this.infiniteReset),this.mapHandler=n,this.streamHandler=this.i,this.activateStream(),this.outputStream},t.prototype.i=function(t){if(this.mapHandler&&this.outputStream){var n=t.map(this.mapHandler);this.outputStream.push(n)}},t.prototype.forEach=function(t){this.forEachHandler=t,this.streamHandler=this.s,this.activateStream()},t.prototype.s=function(t){this.forEachHandler&&t.forEach(this.forEachHandler)},t}(),u=function(){function t(t,n){this.data=[],this.derivativeDataHosts=[],this.promisesToResolve=[],this.streamsToPush=[],this.infiniteReset=this.infiniteReset.bind(this),this.infiniteResetHandler=t;var i={interval:n.interval,batchSize:n.batchSize,repeat:void 0!==n.repeat&&n.repeat};this.streamOptions=Object.freeze(i)}return t.prototype.toStream=function(){var t=new s(this.streamOptions,this.infiniteReset);return this.frozenData?t.push(this.frozenData):this.streamsToPush.push(t),t},t.prototype.toPromise=function(){var t=this;return this.frozenData?Promise.resolve(this.frozenData):new Promise(function(n){t.promisesToResolve.push(n)})},t.prototype.infiniteReset=function(t){return this.infiniteResetHandler(t,this.frozenData?this.frozenData:[])},t.prototype.push=function(t){var n,i;if(!this.frozenData)if(Array.isArray(t))try{for(var r=function(t){var n="function"==typeof Symbol&&t[Symbol.iterator],i=0;return n?n.call(t):{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}}}(t),s=r.next();!s.done;s=r.next()){var u=s.value;this.data.push(u)}}catch(t){n={error:t}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}else this.data.push(t)},t.prototype.setData=function(t){this.data=t},t.prototype.freeze=function(){var t=this;this.frozenData||(this.frozenData=this.data,setTimeout(function(){t.promisesToResolve.forEach(function(n){return n(t.frozenData)}),t.promisesToResolve=[]},0),setTimeout(function(){t.streamsToPush.forEach(function(n){return n.push(t.frozenData||[])}),t.streamsToPush=[]},0),setTimeout(function(){t.handleDerivativeDataHosts()},0),this.data=[])},t.prototype.getPointCount=function(){return this.frozenData?this.frozenData.length:0},t.prototype.handleDerivativeDataHosts=function(){var t=this;this.frozenData&&this.derivativeDataHosts.length>0&&(this.derivativeDataHosts.forEach(function(n){t.frozenData&&n.setData(t.frozenData),n.freeze()}),this.derivativeDataHosts=[])},t.prototype.setStreamInterval=function(n){var i=new t(this.infiniteResetHandler,r(r({},this.streamOptions),{interval:n}));return this.derivativeDataHosts.push(i),this.handleDerivativeDataHosts(),i},t.prototype.setStreamBatchSize=function(n){var i=new t(this.infiniteResetHandler,r(r({},this.streamOptions),{batchSize:n}));return this.derivativeDataHosts.push(i),this.handleDerivativeDataHosts(),i},t.prototype.setStreamRepeat=function(n){var i=new t(this.infiniteResetHandler,r(r({},this.streamOptions),{repeat:n}));return this.derivativeDataHosts.push(i),this.handleDerivativeDataHosts(),i},t}(),e=function(){function t(t){this.options=t}return t.prototype.generate=function(){var t=new u(this.infiniteReset,{interval:500,batchSize:10,repeat:!1}),n=this.getPointCount(),i=this.generateChunks.bind(this,0,n,t);return setTimeout(i,0),t},t.prototype.generateChunks=function(t,n,i){for(var r=window.performance.now(),s=[],u=0;window.performance.now()-r<15&&t<n;u++){var e=this.generateDataPoint(t);t++,s.push(e)}if(i.push(s),t<n){var h=this.generateChunks.bind(this,t,n,i);setTimeout(h,0)}else i.freeze()},t}();var h=function(t){function n(n){var i=t.call(this,n)||this;i.offset=.5;var r={numberOfPoints:n.numberOfPoints,offsetStep:0===n.offsetStep?0:n.offsetStep,offsetDeltaMax:Math.min(n.offsetDeltaMax,1),offsetDeltaMin:Math.max(0===n.offsetDeltaMin?0:n.offsetDeltaMin,0),dataMax:Math.min(n.dataMax,1)};return i.options=Object.freeze(r),i}return i(n,t),n.prototype.setNumberOfPoints=function(t){return new n(r(r({},this.options),{numberOfPoints:t}))},n.prototype.setOffsetStep=function(t){return new n(r(r({},this.options),{offsetStep:t}))},n.prototype.setOffsetDeltaMax=function(t){return new n(r(r({},this.options),{offsetDeltaMax:t}))},n.prototype.setOffsetDeltaMin=function(t){return new n(r(r({},this.options),{offsetDeltaMin:t}))},n.prototype.setDataMax=function(t){return new n(r(r({},this.options),{dataMax:t}))},n.prototype.getPointCount=function(){return this.options.numberOfPoints},n.prototype.generateDataPoint=function(t){if(t%this.options.offsetStep==0||0===t){var n=Math.random()*(this.options.offsetDeltaMax-this.options.offsetDeltaMin)+this.options.offsetDeltaMin;this.offset=Math.random()>.5?this.offset+n:this.offset-n}return this.offset+this.options.dataMax>1?this.offset=1-this.options.dataMax:this.offset<0&&(this.offset=0),{x:t,y:this.offset+Math.random()*this.options.dataMax}},n.prototype.infiniteReset=function(t,n){return{x:t.x+n.length,y:t.y}},n}(e);var o=function(t){function n(n){var i=t.call(this,n)||this;i.previousPoint={x:0,y:0};var r={numberOfPoints:n.numberOfPoints};return i.options=Object.freeze(r),i}return i(n,t),n.prototype.setNumberOfPoints=function(t){return new n(r(r({},this.options),{numberOfPoints:t}))},n.prototype.getPointCount=function(){return this.options.numberOfPoints},n.prototype.generateDataPoint=function(t){var n={x:t,y:this.previousPoint.y+2*(Math.random()-.5)};return this.previousPoint=n,n},n.prototype.infiniteReset=function(t,n){return{x:t.x+n.length,y:t.y}},n}(e);var f=function(t){function n(n){var i=t.call(this,n)||this;i.x=i.options.start;var r={samplingFunction:n.samplingFunction,start:n.start,end:n.end,step:n.step};return i.options=Object.freeze(r),i.numberOfPoints=Math.ceil(Math.abs(r.end-r.start)/r.step),i}return i(n,t),n.prototype.setSamplingFunction=function(t){return new n(r(r({},this.options),{samplingFunction:t}))},n.prototype.setStart=function(t){return new n(r(r({},this.options),{start:t}))},n.prototype.setEnd=function(t){return new n(r(r({},this.options),{end:t}))},n.prototype.setStep=function(t){return new n(r(r({},this.options),{step:t}))},n.prototype.getPointCount=function(){return this.numberOfPoints},n.prototype.generateDataPoint=function(){var t={x:this.x,y:this.options.samplingFunction(this.x)};return this.x=this.x+this.options.step,t},n.prototype.infiniteReset=function(t,n){return{x:t.x+n.length*(n[n.length-1].x-n[n.length-2].x),y:t.y}},n}(e);var a=function(t){function n(n){var i=t.call(this,n)||this;i.previous={x:0,y:0};var r={numberOfPoints:n.numberOfPoints};return i.options=Object.freeze(r),i}return i(n,t),n.prototype.setNumberOfPoints=function(t){return new n(r(r({},this.options),{numberOfPoints:t}))},n.prototype.getPointCount=function(){return this.options.numberOfPoints},n.prototype.generateDataPoint=function(){var t={x:this.previous.x+2*(Math.random()-.5),y:this.previous.y+2*(Math.random()-.5)};return this.previous=t,t},n.prototype.infiniteReset=function(t,n){return{x:t.x+n[n.length-1].x,y:t.y+n[n.length-1].y}},n}(e);var c=function(t){function n(n){var i=t.call(this,n)||this;return i.prevPoint=[i.options.startTimestamp,i.options.start,i.options.start,i.options.start,i.options.start],i}return i(n,t),n.prototype.setNumberOfPoints=function(t){return new n(r(r({},this.options),{numberOfPoints:t}))},n.prototype.setStartTimestamp=function(t){return new n(r(r({},this.options),{startTimestamp:t}))},n.prototype.setDataFrequency=function(t){return new n(r(r({},this.options),{dataFreq:t}))},n.prototype.setStart=function(t){return new n(r(r({},this.options),{start:t}))},n.prototype.setVolatility=function(t){return new n(r(r({},this.options),{volatility:t}))},n.prototype.getPointCount=function(){return this.options.numberOfPoints},n.prototype.generateDataPoint=function(t){var n,i=this,r=this.options.startTimestamp+this.options.dataFreq*t,s=Math.random()>.5?1:-1,u=Array.from(Array(4)).map(function(t){var n=Math.random()*i.options.volatility*s;return i.prevPoint[4]+n<0&&(n*=-1),i.prevPoint[4]+n}).sort(function(t,n){return t-n});return-1===s&&(u=[u[0],u[2],u[1],u[3]]),n=[r,u[1],u[3],u[0],u[2]],this.prevPoint=n,n},n.prototype.infiniteReset=function(t,n){return[t[0]+n.length*(n[n.length-1][0]-n[n.length-2][0]),t[1],t[2],t[3],t[4]]},n}(e);var v=function(t){function n(n){var i=t.call(this,n)||this;i.lastSpike=0;var r={numberOfPoints:n.numberOfPoints,minGap:n.minGap,maxGap:n.maxGap,minAmplitude:n.minAmplitude,maxAmplitude:n.maxAmplitude,probability:n.probability};return i.options=Object.freeze(r),i}return i(n,t),n.prototype.setNumberOfPoints=function(t){return new n(r(r({},this.options),{numberOfPoints:t}))},n.prototype.setMinGap=function(t){return new n(r(r({},this.options),{minGap:t}))},n.prototype.setMaxGap=function(t){return new n(r(r({},this.options),{maxGap:t}))},n.prototype.setMinAmplitude=function(t){return new n(r(r({},this.options),{minAmplitude:t}))},n.prototype.setMaxAmplitude=function(t){return new n(r(r({},this.options),{maxAmplitude:t}))},n.prototype.setProbability=function(t){return new n(r(r({},this.options),{probability:t}))},n.prototype.getPointCount=function(){return this.options.numberOfPoints},n.prototype.generateDataPoint=function(t){var n=t-this.lastSpike,i={x:t,y:0};(n>this.options.minGap||-1===this.options.minGap)&&(n<this.options.maxGap||-1===this.options.maxGap?Math.random()>1-this.options.probability&&(i.y=Math.random()*(this.options.maxAmplitude-this.options.minAmplitude)+this.options.minAmplitude,this.lastSpike=t):n>=this.options.maxGap&&(i.y=Math.random()*(this.options.maxAmplitude-this.options.minAmplitude)+this.options.minAmplitude,this.lastSpike=t));return i},n.prototype.infiniteReset=function(t,n){return{x:t.x+n.length,y:t.y}},n}(e);var m=function(t){function n(n){var i=t.call(this,n)||this,r={numberOfPoints:n.numberOfPoints};return i.options=Object.freeze(r),i}return i(n,t),n.prototype.setNumberOfPoints=function(t){return new n(this.options?r(r({},this.options),{numberOfPoints:t}):{numberOfPoints:t})},n.prototype.getPointCount=function(){return this.options.numberOfPoints},n.prototype.generateDataPoint=function(t){return{x:t,y:2*(Math.random()-.5)}},n.prototype.infiniteReset=function(t,n){return{x:t.x+n[n.length-1].x,y:t.y+n[n.length-1].y}},n}(e);var w=function(t){function n(n){var i=t.call(this,n)||this;i.interval=1/(i.options.samplingFrequency||10);var r={inputData:n.inputData,samplingFrequency:n.samplingFrequency,step:n.step};return i.options=Object.freeze(r),i}return i(n,t),n.prototype.setInputData=function(t){return new n(r(r({},this.options),{inputData:t}))},n.prototype.setSamplingFrequency=function(t){return new n(r(r({},this.options),{samplingFrequency:t}))},n.prototype.setStep=function(t){return new n(r(r({},this.options),{step:t}))},n.prototype.getPointCount=function(){return this.options.inputData.length},n.prototype.generateDataPoint=function(t){return{timestamp:t*this.interval+t*this.options.step,data:this.options.inputData[t]}},n.prototype.infiniteReset=function(t,n){return{timestamp:t.timestamp+n[n.length-1].timestamp,data:t.data}},n}(e);var p=function(t){function n(n){var i=t.call(this,n)||this;i.t=i.options.start;var r={xFunction:n.xFunction,yFunction:n.yFunction,start:n.start,end:n.end,step:n.step};return i.options=Object.freeze(r),i.numberOfPoints=Math.ceil(Math.abs(r.end-r.start)/r.step),i}return i(n,t),n.prototype.setXFunction=function(t){return new n(r(r({},this.options),{xFunction:t}))},n.prototype.setYFunction=function(t){return new n(r(r({},this.options),{yFunction:t}))},n.prototype.setStart=function(t){return new n(r(r({},this.options),{start:t}))},n.prototype.setEnd=function(t){return new n(r(r({},this.options),{end:t}))},n.prototype.setStep=function(t){return new n(r(r({},this.options),{step:t}))},n.prototype.getPointCount=function(){return this.numberOfPoints},n.prototype.generateDataPoint=function(){var t={x:this.options.xFunction(this.t),y:this.options.yFunction(this.t)};return this.t=this.t+this.options.step,t},n.prototype.infiniteReset=function(t,n){return{x:t.x,y:t.y}},n}(e);return t.DataGenerator=e,t.DataHost=u,t.Stream=s,t.createDeltaFunctionGenerator=function(){return new v({numberOfPoints:1e3,minGap:1,maxGap:-1,minAmplitude:.1,maxAmplitude:1,probability:.02})},t.createOHLCGenerator=function(){return new c({numberOfPoints:1e3,startTimestamp:0,dataFreq:1,start:100,volatility:.1})},t.createParametricFunctionGenerator=function(){return new p({xFunction:function(t){return 3*Math.cos(3*t)},yFunction:function(t){return 3*Math.sin(4*t)},start:0,end:1e3,step:.5})},t.createProgressiveFunctionGenerator=function(){return new f({samplingFunction:function(t){return t*t},start:0,end:100,step:1})},t.createProgressiveRandomGenerator=function(){return new h({numberOfPoints:1e3,offsetStep:10,offsetDeltaMax:.3,offsetDeltaMin:.1,dataMax:.5})},t.createProgressiveTraceGenerator=function(){return new o({numberOfPoints:1e3})},t.createSampledDataGenerator=function(){return new w({inputData:[],samplingFrequency:50,step:0})},t.createTraceGenerator=function(){return new a({numberOfPoints:1e3})},t.createWhiteNoiseGenerator=function(){return new m({numberOfPoints:1e3})},t}({});
var xydata=function(t){"use strict";var n=function(t,i){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])})(t,i)};function i(t,i){function r(){this.constructor=t}n(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var n,i=1,r=arguments.length;i<r;i++)for(var e in n=arguments[i])Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e]);return t}).apply(this,arguments)};var e,s=function(){function t(t,n){this.options=t,this.streamActive=!1,this.data=[],this.interval=this.options.interval||1e3,this.batchSize=this.options.batchSize||1,this.batchesLeft=-2,this.runStream=this.runStream.bind(this),this.infiniteReset=n,void 0!==t.repeat&&("boolean"==typeof t.repeat?this.batchesLeft=t.repeat?-1:-2:"number"==typeof t.repeat?this.batchesLeft=t.repeat+1:"function"==typeof t.repeat&&(this.continueHandler=t.repeat))}return t.prototype.consume=function(){var t=this,n=this.batchSize;this.data.length<this.batchSize&&(n=this.data.length);var i=this.data.splice(0,n);if((this.batchesLeft>0||-1===this.batchesLeft)&&i.length>0&&(this.data=this.data.concat(i.map(function(n){return t.infiniteReset(n)})),i.length<this.batchSize))for(;i.length<this.batchSize;){var r=this.data.splice(0,1)[0];this.data=this.data.concat(this.infiniteReset(r)),i.push(r)}return i},t.prototype.checkStreamContinue=function(){var t=this.batchesLeft>0||-1===this.batchesLeft||-2===this.batchesLeft&&this.data.length>0;return this.continueHandler&&(t=!0===this.continueHandler()),t},t.prototype.runStream=function(){var t=this.checkStreamContinue();if(this.data&&this.data.length>0&&t){if(this.streamHandler){var n=this.consume();this.streamHandler(n)}setTimeout(this.runStream,this.interval)}else this.streamActive=!1;this.batchesLeft>0&&this.batchesLeft--},t.prototype.activateStream=function(){this.streamActive||(this.streamActive=!0,this.runStream())},t.prototype.push=function(t){Array.isArray(t)?this.data=this.data.concat(t):this.data.push(t),this.activateStream()},t.prototype.map=function(n){return this.outputStream=new t(r(r({},this.options),{repeat:!1}),this.infiniteReset),this.mapHandler=n,this.streamHandler=this.i,this.activateStream(),this.outputStream},t.prototype.i=function(t){if(this.mapHandler&&this.outputStream){var n=t.map(this.mapHandler);this.outputStream.push(n)}},t.prototype.forEach=function(t){this.forEachHandler=t,this.streamHandler=this.s,this.activateStream()},t.prototype.s=function(t){this.forEachHandler&&t.forEach(this.forEachHandler)},t}(),u=function(){function t(t,n){this.data=[],this.derivativeDataHosts=[],this.promisesToResolve=[],this.streamsToPush=[],this.infiniteReset=this.infiniteReset.bind(this),this.infiniteResetHandler=t;var i={interval:n.interval,batchSize:n.batchSize,repeat:void 0!==n.repeat&&n.repeat};this.streamOptions=Object.freeze(i)}return t.prototype.toStream=function(){var t=new s(this.streamOptions,this.infiniteReset);return this.frozenData?t.push(this.frozenData):this.streamsToPush.push(t),t},t.prototype.toPromise=function(){var t=this;return this.frozenData?Promise.resolve(this.frozenData):new Promise(function(n){t.promisesToResolve.push(n)})},t.prototype.infiniteReset=function(t){return this.infiniteResetHandler(t,this.frozenData?this.frozenData:[])},t.prototype.push=function(t){var n,i;if(!this.frozenData)if(Array.isArray(t))try{for(var r=function(t){var n="function"==typeof Symbol&&Symbol.iterator,i=n&&t[n],r=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}(t),e=r.next();!e.done;e=r.next()){var s=e.value;this.data.push(s)}}catch(t){n={error:t}}finally{try{e&&!e.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}else this.data.push(t)},t.prototype.setData=function(t){this.data=t},t.prototype.freeze=function(){var t=this;this.frozenData||(this.frozenData=this.data,setTimeout(function(){t.promisesToResolve.forEach(function(n){return n(t.frozenData)}),t.promisesToResolve=[]},0),setTimeout(function(){t.streamsToPush.forEach(function(n){return n.push(t.frozenData||[])}),t.streamsToPush=[]},0),setTimeout(function(){t.handleDerivativeDataHosts()},0),this.data=[])},t.prototype.getPointCount=function(){return this.frozenData?this.frozenData.length:0},t.prototype.handleDerivativeDataHosts=function(){var t=this;this.frozenData&&this.derivativeDataHosts.length>0&&(this.derivativeDataHosts.forEach(function(n){t.frozenData&&n.setData(t.frozenData),n.freeze()}),this.derivativeDataHosts=[])},t.prototype.setStreamInterval=function(n){var i=new t(this.infiniteResetHandler,r(r({},this.streamOptions),{interval:n}));return this.derivativeDataHosts.push(i),this.handleDerivativeDataHosts(),i},t.prototype.setStreamBatchSize=function(n){var i=new t(this.infiniteResetHandler,r(r({},this.streamOptions),{batchSize:n}));return this.derivativeDataHosts.push(i),this.handleDerivativeDataHosts(),i},t.prototype.setStreamRepeat=function(n){var i=new t(this.infiniteResetHandler,r(r({},this.streamOptions),{repeat:n}));return this.derivativeDataHosts.push(i),this.handleDerivativeDataHosts(),i},t}();if("undefined"!=typeof window&&window.performance&&window.performance.now)e=window.performance.now;else try{if("undefined"==typeof require)throw new Error;e=require("perf_hooks").performance.now}catch(t){throw new Error('Failed to detect "performance.now" API')}var h=function(){function t(t){this.options=t}return t.prototype.generate=function(){var t=new u(this.infiniteReset,{interval:500,batchSize:10,repeat:!1}),n=this.getPointCount(),i=this.generateChunks.bind(this,0,n,t);return setTimeout(i,0),t},t.prototype.generateChunks=function(t,n,i){for(var r=e(),s=[],u=0;e()-r<15&&t<n;u++){var h=this.generateDataPoint(t);t++,s.push(h)}if(i.push(s),t<n){var o=this.generateChunks.bind(this,t,n,i);setTimeout(o,0)}else i.freeze()},t}();var o=function(t){function n(n){var i=t.call(this,n)||this;i.offset=.5;var r={numberOfPoints:n.numberOfPoints,offsetStep:0===n.offsetStep?0:n.offsetStep,offsetDeltaMax:Math.min(n.offsetDeltaMax,1),offsetDeltaMin:Math.max(0===n.offsetDeltaMin?0:n.offsetDeltaMin,0),dataMax:Math.min(n.dataMax,1)};return i.options=Object.freeze(r),i}return i(n,t),n.prototype.setNumberOfPoints=function(t){return new n(r(r({},this.options),{numberOfPoints:t}))},n.prototype.setOffsetStep=function(t){return new n(r(r({},this.options),{offsetStep:t}))},n.prototype.setOffsetDeltaMax=function(t){return new n(r(r({},this.options),{offsetDeltaMax:t}))},n.prototype.setOffsetDeltaMin=function(t){return new n(r(r({},this.options),{offsetDeltaMin:t}))},n.prototype.setDataMax=function(t){return new n(r(r({},this.options),{dataMax:t}))},n.prototype.getPointCount=function(){return this.options.numberOfPoints},n.prototype.generateDataPoint=function(t){if(t%this.options.offsetStep==0||0===t){var n=Math.random()*(this.options.offsetDeltaMax-this.options.offsetDeltaMin)+this.options.offsetDeltaMin;this.offset=Math.random()>.5?this.offset+n:this.offset-n}return this.offset+this.options.dataMax>1?this.offset=1-this.options.dataMax:this.offset<0&&(this.offset=0),{x:t,y:this.offset+Math.random()*this.options.dataMax}},n.prototype.infiniteReset=function(t,n){return{x:t.x+n.length,y:t.y}},n}(h);var f=function(t){function n(n){var i=t.call(this,n)||this;i.previousPoint={x:0,y:0};var r={numberOfPoints:n.numberOfPoints};return i.options=Object.freeze(r),i}return i(n,t),n.prototype.setNumberOfPoints=function(t){return new n(r(r({},this.options),{numberOfPoints:t}))},n.prototype.getPointCount=function(){return this.options.numberOfPoints},n.prototype.generateDataPoint=function(t){var n={x:t,y:this.previousPoint.y+2*(Math.random()-.5)};return this.previousPoint=n,n},n.prototype.infiniteReset=function(t,n){return{x:t.x+n.length,y:t.y}},n}(h);var a=function(t){function n(n){var i=t.call(this,n)||this;i.x=i.options.start;var r={samplingFunction:n.samplingFunction,start:n.start,end:n.end,step:n.step};return i.options=Object.freeze(r),i.numberOfPoints=Math.ceil(Math.abs(r.end-r.start)/r.step),i}return i(n,t),n.prototype.setSamplingFunction=function(t){return new n(r(r({},this.options),{samplingFunction:t}))},n.prototype.setStart=function(t){return new n(r(r({},this.options),{start:t}))},n.prototype.setEnd=function(t){return new n(r(r({},this.options),{end:t}))},n.prototype.setStep=function(t){return new n(r(r({},this.options),{step:t}))},n.prototype.getPointCount=function(){return this.numberOfPoints},n.prototype.generateDataPoint=function(){var t={x:this.x,y:this.options.samplingFunction(this.x)};return this.x=this.x+this.options.step,t},n.prototype.infiniteReset=function(t,n){return{x:t.x+n.length*(n[n.length-1].x-n[n.length-2].x),y:t.y}},n}(h);var c=function(t){function n(n){var i=t.call(this,n)||this;i.previous={x:0,y:0};var r={numberOfPoints:n.numberOfPoints};return i.options=Object.freeze(r),i}return i(n,t),n.prototype.setNumberOfPoints=function(t){return new n(r(r({},this.options),{numberOfPoints:t}))},n.prototype.getPointCount=function(){return this.options.numberOfPoints},n.prototype.generateDataPoint=function(){var t={x:this.previous.x+2*(Math.random()-.5),y:this.previous.y+2*(Math.random()-.5)};return this.previous=t,t},n.prototype.infiniteReset=function(t,n){return{x:t.x+n[n.length-1].x,y:t.y+n[n.length-1].y}},n}(h);var v=function(t){function n(n){var i=t.call(this,n)||this;return i.prevPoint=[i.options.startTimestamp,i.options.start,i.options.start,i.options.start,i.options.start],i}return i(n,t),n.prototype.setNumberOfPoints=function(t){return new n(r(r({},this.options),{numberOfPoints:t}))},n.prototype.setStartTimestamp=function(t){return new n(r(r({},this.options),{startTimestamp:t}))},n.prototype.setDataFrequency=function(t){return new n(r(r({},this.options),{dataFreq:t}))},n.prototype.setStart=function(t){return new n(r(r({},this.options),{start:t}))},n.prototype.setVolatility=function(t){return new n(r(r({},this.options),{volatility:t}))},n.prototype.getPointCount=function(){return this.options.numberOfPoints},n.prototype.generateDataPoint=function(t){var n,i=this,r=this.options.startTimestamp+this.options.dataFreq*t,e=Math.random()>.5?1:-1,s=Array.from(Array(4)).map(function(t){var n=Math.random()*i.options.volatility*e;return i.prevPoint[4]+n<0&&(n*=-1),i.prevPoint[4]+n}).sort(function(t,n){return t-n});return-1===e&&(s=[s[0],s[2],s[1],s[3]]),n=[r,s[1],s[3],s[0],s[2]],this.prevPoint=n,n},n.prototype.infiniteReset=function(t,n){return[t[0]+n.length*(n[n.length-1][0]-n[n.length-2][0]),t[1],t[2],t[3],t[4]]},n}(h);var m=function(t){function n(n){var i=t.call(this,n)||this;i.lastSpike=0;var r={numberOfPoints:n.numberOfPoints,minGap:n.minGap,maxGap:n.maxGap,minAmplitude:n.minAmplitude,maxAmplitude:n.maxAmplitude,probability:n.probability};return i.options=Object.freeze(r),i}return i(n,t),n.prototype.setNumberOfPoints=function(t){return new n(r(r({},this.options),{numberOfPoints:t}))},n.prototype.setMinGap=function(t){return new n(r(r({},this.options),{minGap:t}))},n.prototype.setMaxGap=function(t){return new n(r(r({},this.options),{maxGap:t}))},n.prototype.setMinAmplitude=function(t){return new n(r(r({},this.options),{minAmplitude:t}))},n.prototype.setMaxAmplitude=function(t){return new n(r(r({},this.options),{maxAmplitude:t}))},n.prototype.setProbability=function(t){return new n(r(r({},this.options),{probability:t}))},n.prototype.getPointCount=function(){return this.options.numberOfPoints},n.prototype.generateDataPoint=function(t){var n=t-this.lastSpike,i={x:t,y:0};(n>this.options.minGap||-1===this.options.minGap)&&(n<this.options.maxGap||-1===this.options.maxGap?Math.random()>1-this.options.probability&&(i.y=Math.random()*(this.options.maxAmplitude-this.options.minAmplitude)+this.options.minAmplitude,this.lastSpike=t):n>=this.options.maxGap&&(i.y=Math.random()*(this.options.maxAmplitude-this.options.minAmplitude)+this.options.minAmplitude,this.lastSpike=t));return i},n.prototype.infiniteReset=function(t,n){return{x:t.x+n.length,y:t.y}},n}(h);var w=function(t){function n(n){var i=t.call(this,n)||this,r={numberOfPoints:n.numberOfPoints};return i.options=Object.freeze(r),i}return i(n,t),n.prototype.setNumberOfPoints=function(t){return new n(this.options?r(r({},this.options),{numberOfPoints:t}):{numberOfPoints:t})},n.prototype.getPointCount=function(){return this.options.numberOfPoints},n.prototype.generateDataPoint=function(t){return{x:t,y:2*(Math.random()-.5)}},n.prototype.infiniteReset=function(t,n){return{x:t.x+n[n.length-1].x,y:t.y+n[n.length-1].y}},n}(h);var p=function(t){function n(n){var i=t.call(this,n)||this;i.interval=1/(i.options.samplingFrequency||10);var r={inputData:n.inputData,samplingFrequency:n.samplingFrequency,step:n.step};return i.options=Object.freeze(r),i}return i(n,t),n.prototype.setInputData=function(t){return new n(r(r({},this.options),{inputData:t}))},n.prototype.setSamplingFrequency=function(t){return new n(r(r({},this.options),{samplingFrequency:t}))},n.prototype.setStep=function(t){return new n(r(r({},this.options),{step:t}))},n.prototype.getPointCount=function(){return this.options.inputData.length},n.prototype.generateDataPoint=function(t){return{timestamp:t*this.interval+t*this.options.step,data:this.options.inputData[t]}},n.prototype.infiniteReset=function(t,n){return{timestamp:t.timestamp+n[n.length-1].timestamp,data:t.data}},n}(h);var b=function(t){function n(n){var i=t.call(this,n)||this;i.t=i.options.start;var r={xFunction:n.xFunction,yFunction:n.yFunction,start:n.start,end:n.end,step:n.step};return i.options=Object.freeze(r),i.numberOfPoints=Math.ceil(Math.abs(r.end-r.start)/r.step),i}return i(n,t),n.prototype.setXFunction=function(t){return new n(r(r({},this.options),{xFunction:t}))},n.prototype.setYFunction=function(t){return new n(r(r({},this.options),{yFunction:t}))},n.prototype.setStart=function(t){return new n(r(r({},this.options),{start:t}))},n.prototype.setEnd=function(t){return new n(r(r({},this.options),{end:t}))},n.prototype.setStep=function(t){return new n(r(r({},this.options),{step:t}))},n.prototype.getPointCount=function(){return this.numberOfPoints},n.prototype.generateDataPoint=function(){var t={x:this.options.xFunction(this.t),y:this.options.yFunction(this.t)};return this.t=this.t+this.options.step,t},n.prototype.infiniteReset=function(t,n){return{x:t.x,y:t.y}},n}(h);return t.DataGenerator=h,t.DataHost=u,t.Stream=s,t.createDeltaFunctionGenerator=function(){return new m({numberOfPoints:1e3,minGap:1,maxGap:-1,minAmplitude:.1,maxAmplitude:1,probability:.02})},t.createOHLCGenerator=function(){return new v({numberOfPoints:1e3,startTimestamp:0,dataFreq:1,start:100,volatility:.1})},t.createParametricFunctionGenerator=function(){return new b({xFunction:function(t){return 3*Math.cos(3*t)},yFunction:function(t){return 3*Math.sin(4*t)},start:0,end:1e3,step:.5})},t.createProgressiveFunctionGenerator=function(){return new a({samplingFunction:function(t){return t*t},start:0,end:100,step:1})},t.createProgressiveRandomGenerator=function(){return new o({numberOfPoints:1e3,offsetStep:10,offsetDeltaMax:.3,offsetDeltaMin:.1,dataMax:.5})},t.createProgressiveTraceGenerator=function(){return new f({numberOfPoints:1e3})},t.createSampledDataGenerator=function(){return new p({inputData:[],samplingFrequency:50,step:0})},t.createTraceGenerator=function(){return new c({numberOfPoints:1e3})},t.createWhiteNoiseGenerator=function(){return new w({numberOfPoints:1e3})},t}({});

@@ -46,5 +46,5 @@ 'use strict';

function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
return {
if (o && typeof o.length === "number") return {
next: function () {

@@ -55,2 +55,3 @@ if (o && i >= o.length) o = void 0;

};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}

@@ -283,2 +284,19 @@

var perfNow;
if (typeof window !== 'undefined' && window.performance && window.performance.now) {
perfNow = window.performance.now;
}
else {
try {
if (typeof require !== 'undefined') {
perfNow = require('perf_hooks').performance.now;
}
else {
throw new Error();
}
}
catch (e) {
throw new Error('Failed to detect "performance.now" API');
}
}
var DataGenerator = (function () {

@@ -300,5 +318,5 @@ function DataGenerator(args) {

DataGenerator.prototype.generateChunks = function (baseIndex, total, dataHost) {
var startTime = window.performance.now();
var startTime = perfNow();
var points = [];
for (var i = 0; window.performance.now() - startTime < 15 && baseIndex < total; i++) {
for (var i = 0; perfNow() - startTime < 15 && baseIndex < total; i++) {
var point = this.generateDataPoint(baseIndex);

@@ -305,0 +323,0 @@ baseIndex++;

{
"name": "@arction/xydata",
"version": "1.1.0",
"version": "1.2.0",
"description": "A random data generation library.",

@@ -37,13 +37,13 @@ "keywords": [

"ci:watch": "gulp ciWatch",
"docs": "gulp docs",
"docs": "typedoc --options typedoc.json",
"lint": "gulp lintWatch",
"prepublishOnly": "gulp build",
"test": "gulp testWatch",
"version": "gulp docs"
"version": "npm run docs && git add docs"
},
"devDependencies": {
"@types/chai": "^4.2.8",
"@types/mocha": "^7.0.1",
"@types/node": "^12.6.9",
"@wessberg/rollup-plugin-ts": "^1.2.15",
"@types/chai": "^4.2.11",
"@types/mocha": "^7.0.2",
"@types/node": "^13.9.8",
"@wessberg/rollup-plugin-ts": "^1.2.23",
"chai": "^4.2.0",

@@ -56,12 +56,11 @@ "del": "^5.1.0",

"gulp-tslint": "^8.1.4",
"gulp-typedoc": "^2.2.4",
"mocha": "^7.0.1",
"rollup": "^1.31.0",
"mocha": "^7.1.1",
"rollup": "^2.3.2",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.5.0",
"ts-node": "^8.6.2",
"tslint": "^6.0.0",
"typedoc": "^0.16.9",
"typescript": "^3.7.5"
"ts-node": "^8.8.1",
"tslint": "^6.1.1",
"typedoc": "^0.17.3",
"typescript": "^3.8.3"
},

@@ -68,0 +67,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc