@peerbit/time
Advanced tools
Comparing version 2.0.5 to 2.0.6-a4f88b6
{ | ||
"name": "@peerbit/time", | ||
"version": "2.0.5", | ||
"description": "Utility functions for time", | ||
"type": "module", | ||
"sideEffects": false, | ||
"module": "lib/esm/index.js", | ||
"types": "lib/esm/index.d.ts", | ||
"exports": { | ||
"import": "./lib/esm/index.js", | ||
"require": "./lib/cjs/index.js" | ||
}, | ||
"files": [ | ||
"lib", | ||
"src", | ||
"!src/**/__tests__", | ||
"!lib/**/__tests__", | ||
"LICENSE" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"clean": "shx rm -rf lib/*", | ||
"build": "yarn clean && tsc -p tsconfig.json", | ||
"test": "node ../../../node_modules/.bin/jest test -c ../../../jest.config.ts --runInBand --forceExit", | ||
"test:unit": "node ../../../node_modules/.bin/jest test -c ../../../jest.config.unit.ts --runInBand --forceExit", | ||
"test:integration": "node ../node_modules/.bin/jest test -c ../../../jest.config.integration.ts --runInBand --forceExit" | ||
}, | ||
"author": "dao.xyz", | ||
"license": "MIT", | ||
"gitHead": "180a8c4e6ab6f713134c949d2d7ce9fc5648a4ce" | ||
"name": "@peerbit/time", | ||
"version": "2.0.6-a4f88b6", | ||
"description": "Utility functions for time", | ||
"type": "module", | ||
"sideEffects": false, | ||
"types": "./dist/src/index.d.ts", | ||
"typesVersions": { | ||
"*": { | ||
"*": [ | ||
"*", | ||
"dist/*", | ||
"dist/src/*", | ||
"dist/src/*/index" | ||
], | ||
"src/*": [ | ||
"*", | ||
"dist/*", | ||
"dist/src/*", | ||
"dist/src/*/index" | ||
] | ||
} | ||
}, | ||
"files": [ | ||
"src", | ||
"dist", | ||
"!dist/test", | ||
"!**/*.tsbuildinfo" | ||
], | ||
"exports": { | ||
".": { | ||
"types": "./dist/src/index.d.ts", | ||
"import": "./dist/src/index.js" | ||
} | ||
}, | ||
"eslintConfig": { | ||
"extends": "ipfs", | ||
"parserOptions": { | ||
"project": true, | ||
"sourceType": "module" | ||
}, | ||
"ignorePatterns": [ | ||
"!.aegir.js", | ||
"test/ts-use", | ||
"*.d.ts" | ||
] | ||
}, | ||
"browser": { | ||
"./dist/src/hrtime.js": "./dist/src/hrtime.browser.js" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"clean": "aegir clean", | ||
"build": "aegir build --no-bundle", | ||
"test": "aegir test" | ||
}, | ||
"author": "dao.xyz", | ||
"license": "MIT" | ||
} |
@@ -1,78 +0,2 @@ | ||
/* | ||
MIT License | ||
Copyright (c) 2020 Vlad Tansky | ||
Copyright (c) 2022 dao.xyz | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
const _perfomancePolyfill = () => { | ||
// based on https://gist.github.com/paulirish/5438650 copyright Paul Irish 2015. | ||
if ("performance" in window === false) { | ||
((window as any).performance as any) = {}; | ||
} | ||
Date.now = | ||
Date.now || | ||
(() => { | ||
// thanks IE8 | ||
return new Date().getTime(); | ||
}); | ||
if ("now" in window.performance === false) { | ||
let nowOffset = Date.now(); | ||
if (performance.timeOrigin) { | ||
nowOffset = performance.timeOrigin; | ||
} | ||
(window.performance as any)["now"] = () => Date.now() - nowOffset; | ||
} | ||
}; | ||
const _hrtime = (previousTimestamp?: [number, number]): [number, number] => { | ||
_perfomancePolyfill(); | ||
const baseNow = Math.floor((Date.now() - performance.now()) * 1e-3); | ||
const clocktime = performance.now() * 1e-3; | ||
let seconds = Math.floor(clocktime) + baseNow; | ||
let nanoseconds = Math.floor((clocktime % 1) * 1e9); | ||
if (previousTimestamp) { | ||
seconds = seconds - previousTimestamp[0]; | ||
nanoseconds = nanoseconds - previousTimestamp[1]; | ||
if (nanoseconds < 0) { | ||
seconds--; | ||
nanoseconds += 1e9; | ||
} | ||
} | ||
return [seconds, nanoseconds]; | ||
}; | ||
const NS_PER_SEC = 1e9; | ||
_hrtime.bigint = (time?: [number, number]): bigint => { | ||
const diff = _hrtime(time); | ||
return BigInt(diff[0] * NS_PER_SEC + diff[1]); | ||
}; | ||
export default typeof process === "undefined" || | ||
typeof process.hrtime === "undefined" | ||
? _hrtime | ||
: process.hrtime; | ||
const hrtime = process.hrtime; | ||
export { hrtime } |
export * from "./wait.js"; | ||
export * from "./metrics.js"; | ||
import hrtime from "./hrtime.js"; | ||
import { hrtime } from "./hrtime.js"; | ||
export { hrtime }; |
@@ -1,2 +0,2 @@ | ||
import hrtime from "./hrtime.js"; | ||
import {hrtime} from "./hrtime.js"; | ||
@@ -3,0 +3,0 @@ export class MovingAverageTracker { |
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
20716
27
341
2
1