Comparing version 1.1.2 to 1.2.1
@@ -1,15 +0,19 @@ | ||
const EventEmitter = require("events"); | ||
const staticValues = require("./static"); | ||
"use strict"; | ||
const eventList = function(number, type, options = {}) { | ||
const list = staticValues(number, type, options); | ||
var EventEmitter = require("events"); | ||
const defaults = { duration: 1000, repeat: false }; | ||
var staticValues = require("./static"); | ||
var eventList = function eventList(number, type) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var list = staticValues(number, type, options); | ||
var defaults = { | ||
duration: 1000, | ||
repeat: false | ||
}; | ||
options = Object.assign({}, defaults, options); | ||
const intervalTime = ~~(options.duration / number); | ||
const ee = new EventEmitter(); | ||
let index = 0; | ||
let id = setInterval(() => { | ||
var intervalTime = ~~(options.duration / number); | ||
var ee = new EventEmitter(); | ||
var index = 0; | ||
var id = setInterval(function () { | ||
ee.emit("data", list[index]); | ||
@@ -23,11 +27,11 @@ index++; | ||
} else { | ||
ee.emit("repeat") | ||
index = 0 | ||
ee.emit("repeat"); | ||
index = 0; | ||
} | ||
} | ||
}, intervalTime); | ||
ee.on("requestStop", () => { | ||
ee.on("requestStop", function () { | ||
clearInterval(id); | ||
ee.emit("end") | ||
}) | ||
ee.emit("end"); | ||
}); | ||
return ee; | ||
@@ -37,1 +41,2 @@ }; | ||
module.exports = exports = eventList; | ||
//# sourceMappingURL=event.js.map |
@@ -1,33 +0,50 @@ | ||
const funclist = {}; | ||
funclist["linear"] = function(x) { | ||
"use strict"; | ||
var funclist = {}; | ||
funclist["linear"] = function (x) { | ||
return x; | ||
}; | ||
funclist["quadratic"] = function(x) { | ||
funclist["quadratic"] = function (x) { | ||
return Math.pow(x, 2); | ||
}; | ||
funclist["cubic"] = function(x) { | ||
funclist["cubic"] = function (x) { | ||
return Math.pow(x, 3); | ||
}; | ||
funclist["quartic"] = function(x) { | ||
funclist["quartic"] = function (x) { | ||
return Math.pow(x, 4); | ||
}; | ||
funclist["quintic"] = function(x) { | ||
funclist["quintic"] = function (x) { | ||
return Math.pow(x, 5); | ||
}; | ||
const sinusoidal = function(x) { | ||
funclist["sigmoid"] = function (x) { | ||
return 1 / (1 + Math.exp(-x)); | ||
}; | ||
var sinusoidal = function sinusoidal(x) { | ||
return Math.sin(x * (Math.PI / 2)); | ||
}; | ||
funclist["sinusoidal"] = sinusoidal; | ||
funclist["sin"] = sinusoidal; | ||
var exponential = function(x) { | ||
var exponential = function exponential(x) { | ||
return Math.pow(2, 10 * (x - 1)); | ||
}; | ||
funclist["exponential"] = exponential; | ||
funclist["expo"] = exponential; | ||
funclist["exp"] = exponential; | ||
funclist["circular"] = function(x) { | ||
return 1 - Math.sqrt(1 - x*x) | ||
funclist["circular"] = function (x) { | ||
return 1 - Math.sqrt(1 - x * x); | ||
}; | ||
funclist["uniqueList"] = ["linear", "quadratic", "cubic", "quartic", "quintic", "sinusoidal", "exponential", "circular"]; | ||
funclist["uniqueList"] = ["linear", "quadratic", "cubic", "quartic", "quintic", "sinusoidal", "exponential", "circular", "sigmoid"]; | ||
module.exports = exports = funclist; | ||
//# sourceMappingURL=functions.js.map |
@@ -1,30 +0,42 @@ | ||
const funclist = require("./functions"); | ||
"use strict"; | ||
const round = function(val) { | ||
var funclist = require("./functions"); | ||
var round = function round(val) { | ||
return ~~(val * 1000) / 1000; | ||
}; | ||
const staticValues = function(number, type, options = {}) { | ||
const list = new Array(number); | ||
const step = 1 / (list.length - 1); | ||
var staticValues = function staticValues(number, type) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var list = new Array(number); | ||
options.start = options.start !== undefined ? options.start : 0; | ||
options.end = options.end !== undefined ? options.end : 1; | ||
var width = Math.abs(options.end - options.start); | ||
var step = width / (list.length - 1); | ||
for (var i = 1; i < list.length - 1; i++) { | ||
let val = round(funclist[type](i * step)); | ||
var x = i * step + options.start; | ||
var val = round(funclist[type](x)); | ||
list[i] = val; | ||
} | ||
list[0] = 0; | ||
list[list.length - 1] = 1; | ||
list[0] = round(funclist[type](options.start)); | ||
list[list.length - 1] = round(funclist[type](options.end)); | ||
if (options.endToEnd) { | ||
var mid = Math.floor(list.length / 2); | ||
for (var i = 1; i < mid; i++) { | ||
list[i] = list[i * 2]; | ||
} | ||
list[mid] = 1; | ||
for (var i = mid + 1; i < list.length - 1; i++) { | ||
list[i] = list[mid - (i - mid)]; | ||
} | ||
list[list.length - 1] = 0; | ||
} | ||
if (options.invert) { | ||
@@ -35,2 +47,3 @@ for (var i = 0; i < list.length; i++) { | ||
} | ||
return list; | ||
@@ -40,1 +53,2 @@ }; | ||
module.exports = exports = staticValues; | ||
//# sourceMappingURL=static.js.map |
@@ -1,16 +0,21 @@ | ||
const Stream = require("stream"); | ||
const staticValues = require("./static"); | ||
"use strict"; | ||
const streamList = function(number, type, options = {}) { | ||
const list = staticValues(number, type, options); | ||
var Stream = require("stream"); | ||
const defaults = { duration: 1000, repeat: false }; | ||
var staticValues = require("./static"); | ||
var streamList = function streamList(number, type) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var list = staticValues(number, type, options); | ||
var defaults = { | ||
duration: 1000, | ||
repeat: false | ||
}; | ||
options = Object.assign({}, defaults, options); | ||
var intervalTime = ~~(options.duration / number); | ||
var stream = new Stream.Readable(); | ||
var index = 0; | ||
const intervalTime = ~~(options.duration / number); | ||
const stream = new Stream.Readable(); | ||
let index = 0; | ||
stream._read = () => { | ||
setTimeout(() => { | ||
stream._read = function () { | ||
setTimeout(function () { | ||
if (index > list.length - 1) { | ||
@@ -24,2 +29,3 @@ return stream.push(null); | ||
}; | ||
return stream; | ||
@@ -29,1 +35,2 @@ }; | ||
module.exports = exports = streamList; | ||
//# sourceMappingURL=stream.js.map |
{ | ||
"author": "David Wee <rook2pawn@gmail.com> (http://rook2pawn.com)", | ||
"name": "easing", | ||
"version": "1.2.1", | ||
"description": "Easing Functions Without the Framework Cruft", | ||
"version": "1.1.2", | ||
"author": "David Wee <rook2pawn@gmail.com> (http://rook2pawn.com)", | ||
"contributors": [ | ||
"David Wee <rook2pawn@gmail.com> (http://rook2pawn.com)", | ||
"Joseph Kohlmann <kohlmannj@mac.com>" | ||
], | ||
"keywords": [ | ||
@@ -11,4 +15,18 @@ "easing", | ||
], | ||
"files": [ | ||
"dist", | ||
"docs", | ||
"lib", | ||
"src", | ||
"types/index.d.ts", | ||
"browser-easing.js", | ||
"index.html", | ||
"README.md" | ||
], | ||
"scripts": { | ||
"build-browser-standalone": "browserify -s Easing index.js -o browser-easing.js", | ||
"build": "npm run build:lib && npm run build:dist", | ||
"build:lib": "babel ./src --source-maps --out-dir ./lib", | ||
"build:dist": "webpack -p", | ||
"clean": "rimraf lib browser-easing.js", | ||
"prepublish": "npm run clean && npm run test && npm run build", | ||
"test": "nyc tape test/*.js | tap-spec", | ||
@@ -22,6 +40,9 @@ "coverage": "nyc report --reporter=text-lcov | coveralls" | ||
}, | ||
"main": "index.js", | ||
"main": "lib/index.js", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"browserify": "^16.2.0", | ||
"@babel/cli": "^7.0.0-beta.55", | ||
"@babel/core": "^7.0.0-beta.55", | ||
"@babel/preset-env": "^7.0.0-beta.55", | ||
"babel-loader": "^8.0.0-beta.4", | ||
"coveralls": "^3.0.0", | ||
@@ -31,4 +52,6 @@ "nyc": "^11.7.1", | ||
"tape": "^4.9.0", | ||
"through2": "^2.0.3" | ||
"through2": "^2.0.3", | ||
"webpack": "^4.16.4", | ||
"webpack-cli": "^3.1.0" | ||
} | ||
} |
@@ -41,3 +41,25 @@ | testing | coverage | | ||
## Differences from the Original Package | ||
This is a fork of [rook2pawn/node-easing](https://github.com/rook2pawn/node-easing) with the following changes: | ||
- Transpile source files with Babel | ||
- Create a library build using Webpack + babel-loader | ||
### Motivation | ||
As distributed, the original project's source files, including [rook2pawn/node-easing/browser-easing.js](https://github.com/rook2pawn/node-easing/blob/3a78daa45cb9f0f85f0acae1919e8a12594149f7/browser-easing.js#L16), are not valid ES5. This leads to knock-on issues, such as when bundling the library with a tool that uses [UglifyJS](https://github.com/mishoo/UglifyJS): | ||
<details><summary>Error from UglifyJS Showing "Unexpected token operator «=»" in browser-easing.js</summary> | ||
``` | ||
js/main-ec3d69cc.js from UglifyJs | ||
Unexpected token operator «=», expected punc «,» [../node_modules/easing/browser-easing.js:8,0][js/main-ec3d69cc.js:28118,46] | ||
``` | ||
</details> | ||
Hence, this fork transpiles the source files to valid ES5: | ||
- The **lib** folder contains individual transpiled source files | ||
- **browser-easing.js**, a UMD module as before, is also transpiled | ||
## Types of Easing | ||
@@ -44,0 +66,0 @@ |
Sorry, the diff of this file is too big to display
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 23 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
1852692
52
1106
155
0
11
24