Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

drain-js

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drain-js - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

20

dist/index.js

@@ -1,4 +0,3 @@

function drain(val, newVal, callback) {
var start = parseInt(val, 0);
var end = parseInt(newVal, 0);
function drain(_a) {
var start = _a.start, end = _a.end, onInterval = _a.onInterval, onComplete = _a.onComplete;
var diff = Math.abs(end - start);

@@ -8,10 +7,13 @@ var direction = end - start > 0 ? "up" : "down";

if (diff > 10000)
step = 9999;
step = 9494;
else if (diff > 1000)
step = 999;
step = 949;
else if (diff > 100)
step = 99;
step = 94;
else if (diff > 10)
step = 9;
if (diff === 0) {
if (typeof onComplete === "function") {
onComplete(start);
}
return;

@@ -25,7 +27,9 @@ }

}
callback(start);
if (typeof onInterval === "function") {
onInterval(start);
}
setTimeout(function () {
drain(start, end, callback);
drain({ start: start, end: end, onInterval: onInterval, onComplete: onComplete });
}, 100);
}
export default drain;

2

package.json
{
"name": "drain-js",
"version": "0.1.1",
"version": "0.1.2",
"description": "Number change animator",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -13,3 +13,10 @@ # Drain.js

`drain(start: Number, end: Number, callback: Function)`
```ts
drain({
start: Number,
end: Number,
onInterval?: Function,
onComplete?: Function
});
```

@@ -21,3 +28,3 @@ ### Sample

drain(3000, 2750, console.log);
drain({ start: 3000, end: 2750, onInterval: console.log });

@@ -24,0 +31,0 @@ // Output

@@ -1,5 +0,9 @@

function drain(val, newVal, callback: Function) {
let start: number = parseInt(val, 0);
let end: number = parseInt(newVal, 0);
type drainArgs = {
start: number,
end: number,
onInterval?: Function,
onComplete?: Function
}
function drain({ start, end, onInterval, onComplete }: drainArgs) {
let diff = Math.abs(end - start);

@@ -9,8 +13,11 @@ let direction = end - start > 0 ? "up" : "down";

if (diff > 10000) step = 9999;
else if (diff > 1000) step = 999;
else if (diff > 100) step = 99;
if (diff > 10000) step = 9494;
else if (diff > 1000) step = 949;
else if (diff > 100) step = 94;
else if (diff > 10) step = 9;
if (diff === 0) {
if (typeof onComplete === "function") {
onComplete(start);
}
return;

@@ -25,6 +32,8 @@ }

callback(start);
if (typeof onInterval === "function") {
onInterval(start);
}
setTimeout(() => {
drain(start, end, callback);
drain({ start: start, end: end, onInterval, onComplete });
}, 100);

@@ -31,0 +40,0 @@ }

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