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

chronolite

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chronolite - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

LICENSE.txt

5

.eslintrc.js

@@ -7,3 +7,6 @@ module.exports = {

"globals": {
"chronolite": true
"chronolite": true,
"test": true,
"expect": true,
"require": true,
},

@@ -10,0 +13,0 @@ "extends": "eslint:recommended",

15

chronolite.js

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

module.exports = class chronolite {
export default class chronolite {
constructor() {

@@ -14,4 +13,4 @@ this.defaultIterations = 20;

}
if (obj.fn === undefined) {
return [false, "function (fn) is undefined: " + objStr];
if (typeof obj.fn !== "function") {
return [false, "function (fn) is not a function type: " + objStr];
}

@@ -21,4 +20,5 @@ if (obj.fnArgs !== undefined && !Array.isArray(obj.fnArgs)) {

}
if (obj.binding !== undefined && typeof obj.binding !== obj) {
return [false, "binding is defined but not an object : " + objStr];
if (obj.binding !== undefined && typeof obj.binding !== "object") {
return [false, "binding is defined but not an object (got " +
typeof obj + ") with value: " + objStr];
}

@@ -30,3 +30,2 @@ return [true, ""];

// Time code
_setup(fnToTime) {

@@ -163,2 +162,2 @@ const valid = this.validInput(fnToTime);

}
};
{
"name": "chronolite",
"version": "0.0.1",
"version": "0.0.2",
"source": "chronolite.js",

@@ -8,8 +8,26 @@ "main": "dist/chronolite.js",

"scripts": {
"build": "microbundle"
"build": "microbundle",
"test": "jest",
"test:coverage": "jest --coverage"
},
"keywords": [
"performance",
"benchmark",
"timing",
"timer",
"perf",
"compare",
"functions"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git@github.com:JamesMilnerUK/chronolite.git"
},
"bugs": "https://github.com/JamesMilnerUK/chronolite/issues",
"devDependencies": {
"eslint": "^4.16.0",
"jest": "^22.4.3",
"microbundle": "^0.4.3"
}
}

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

# chronolite
# chronolite 🕰️
chronolite is a microlibrary for timing, comparing and benchmarking JavaScript functions. It supports both synchronous and asynchronous functions. Common use cases include performance benchmarking for a function, and benchmarking multiple functions against each other.
## Install
For npm:
``` npm install chronolite ```
For yarn:
``` yarn add chronolite ```
## Usage
chronolite has 4 core methods:
* **time** - Return the running time of a synchronous function
* **timeAsync** - Return the running time of a async function (function must return a promise)
* **compare** - Find the fastest function out of an array of functions
* **compareAsync** - Find the fastest function out of an array of async functions
Methods take objects or arrays of objects of the following schema:
```javascript
{
id: "someFunction", // - string (optional)
binding: null // object (optional) - The object to bind the function to (defaults to null)
fn: someFunc, // function
fnArgs: [1, 2, 3], // array - The array of arguments
}
```
Here is an example of using the time method:
```javascript
var timer = new chronolite();
var fn = function(input) {
// Synthetic wait
const ms = input * (Math.random() * 1);
const start = Date.now();
let now = start;
while (now - start < ms) {
now = Date.now();
}
return "finished";
};
var arg = [10];
var iterations = 15;
var time = timer.time({
fn: first,
fnArgs: arg,
}, iterations);
console.log("time", time.averageTime);
```
## License
MIT
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