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

doublescore

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

doublescore - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

test/timer.js

26

index.js

@@ -222,2 +222,27 @@ "use strict";

function timer() {
// account for overhead within this function, this may not be a good idea
var offset = 1;
var start = new Date().getTime() + offset;
return function( reset ) {
var diff = new Date().getTime() - start;
if ( diff < 0 ) {
diff = 0;
}
if ( reset ) {
start = new Date().getTime() + offset;
}
return diff;
};
}
module.exports = function( obj ) {

@@ -254,2 +279,3 @@ return {

module.exports.getType = getType;
module.exports.timer = timer;
module.exports.isArray = isArray;

@@ -256,0 +282,0 @@ module.exports.isNumber = isNumber;

3

package.json

@@ -5,3 +5,3 @@ {

"author": "Anthony Hildoer <anthony@bluerival.com>",
"version": "0.1.0",
"version": "0.2.0",
"repository": {

@@ -23,2 +23,3 @@ "type": "git",

"devDependencies": {
"async": "1.5.2",
"mocha": "2.3.4"

@@ -25,0 +26,0 @@ },

doublescore
====================
Some utility functions, such as an Object.isObject() method to parallel Array.isArray(), a clone() method on all objects and a mixin() method on all objects, and a getType() method.
Some utility functions for managing common tasks related to managing data structures and measurement.
isObject() will return TRUE for anything that is typeof object, is not an Array, and is not NULL.
getType() will return 'null' for NULL, 'array' for an Array, 'float' for a non-integer number, 'integer' for an integer number, and typeof result for all else.
clone() will return a distinct copy of the object it was called from. Date objects are cloned, arrays and objects are recursively cloned down 100 levels max and all else is just passed through.
mixin() will return a clone of the original object, with any passed in objects merged in recursively up to 100 levels max. mixin() accepts an arbitrary number of arguments, they will be mixed in from left to right.
Documentation
====================
isObject()
For the time being, please see the test cases in test/default.js to understand
exactly how getType(), isObject(), clone() and mixin() behave.
Will return TRUE for anything that is typeof object, is not an Array, and is not NULL.
TO DO
getType()
Will return 'null' for NULL, 'array' for an Array, 'float' for a non-integer number, 'integer' for an integer number, and typeof result for all else.
clone()
Will return a distinct copy of the object it was called from. Date objects are cloned, arrays and objects are recursively cloned down 100 levels max and all else is just passed through.
mixin()
Will return a clone of the original object, with any passed in objects merged in recursively up to 100 levels max. mixin() accepts an arbitrary number of arguments, they will be mixed in from left to right.
timer()
Will return a function that will track time deltas with 1ms resolution and < 0.1% error on average. The returned function accepts a single parameter: reset, which if true will reset the timer, returning the last interval
NOTE: timer() is experimental. 0.5% margin of error for both precision and accuracy at best, probably closer to 1% for most intervals of time. However, deviance is constant regardless of actual time interval measured. Thus, error rates for higher intervals (> 100ms) will be considerably lower than those for short intervals (< 50ms).
Documentation
====================
- write examples in this doc
- add support of custom clone functions based on object type
Please see the test cases in test/default.js

@@ -30,3 +45,3 @@

Copyright (c) 2012 BlueRival Software <anthony@bluerival.com>
Copyright (c) 2016 BlueRival Software <anthony@bluerival.com>

@@ -33,0 +48,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation

@@ -8,1 +8,2 @@ 'use strict';

require( './mixin' );
require( './timer' );
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