This commit is contained in:
Dawid Dziurla 2020-03-26 15:37:35 +01:00
parent d9becc67b6
commit 9308795b8b
No known key found for this signature in database
GPG key ID: 7B6D8368172E9B0B
964 changed files with 104265 additions and 16 deletions

11
node_modules/atomic-sleep/.travis.yml generated vendored Normal file
View file

@ -0,0 +1,11 @@
language: node_js
sudo: false
node_js:
- 6
- 8
- 10
- 11
- 12
- 13
script:
- npm run ci

22
node_modules/atomic-sleep/LICENSE generated vendored Normal file
View file

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2020 David Mark Clements
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.

38
node_modules/atomic-sleep/index.js generated vendored Normal file
View file

@ -0,0 +1,38 @@
'use strict'
/* global SharedArrayBuffer, Atomics */
if (typeof SharedArrayBuffer !== 'undefined' && typeof Atomics !== 'undefined') {
const nil = new Int32Array(new SharedArrayBuffer(4))
function sleep (ms) {
// also filters out NaN, non-number types, including empty strings, but allows bigints
const valid = ms > 0 && ms < Infinity
if (valid === false) {
if (typeof ms !== 'number' && typeof ms !== 'bigint') {
throw TypeError('sleep: ms must be a number')
}
throw RangeError('sleep: ms must be a number that is greater than 0 but less than Infinity')
}
Atomics.wait(nil, 0, 0, Number(ms))
}
module.exports = sleep
} else {
function sleep (ms) {
// also filters out NaN, non-number types, including empty strings, but allows bigints
const valid = ms > 0 && ms < Infinity
if (valid === false) {
if (typeof ms !== 'number' && typeof ms !== 'bigint') {
throw TypeError('sleep: ms must be a number')
}
throw RangeError('sleep: ms must be a number that is greater than 0 but less than Infinity')
}
const target = Date.now() + Number(ms)
while (target > Date.now()){}
}
module.exports = sleep
}

65
node_modules/atomic-sleep/package.json generated vendored Normal file
View file

@ -0,0 +1,65 @@
{
"_from": "atomic-sleep@^1.0.0",
"_id": "atomic-sleep@1.0.0",
"_inBundle": false,
"_integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==",
"_location": "/atomic-sleep",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "atomic-sleep@^1.0.0",
"name": "atomic-sleep",
"escapedName": "atomic-sleep",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/sonic-boom"
],
"_resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz",
"_shasum": "eb85b77a601fc932cfe432c5acd364a9e2c9075b",
"_spec": "atomic-sleep@^1.0.0",
"_where": "/home/dawidd6/github/dawidd6/action-debian-package/node_modules/sonic-boom",
"author": {
"name": "David Mark Clements",
"url": "@davidmarkclem"
},
"bugs": {
"url": "https://github.com/davidmarkclements/atomic-sleep/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "Zero CPU overhead, zero dependency, true event-loop blocking sleep",
"devDependencies": {
"standard": "^14.3.1",
"tap": "^14.10.6",
"tape": "^4.13.2"
},
"engines": {
"node": ">=8.0.0"
},
"homepage": "https://github.com/davidmarkclements/atomic-sleep#readme",
"keywords": [
"sleep",
"pause",
"wait",
"performance",
"atomics"
],
"license": "MIT",
"main": "index.js",
"name": "atomic-sleep",
"repository": {
"type": "git",
"url": "git+https://github.com/davidmarkclements/atomic-sleep.git"
},
"scripts": {
"ci": "npm run lint && npm test",
"lint": "standard",
"test": "tap -R classic- -j1 test"
},
"version": "1.0.0"
}

58
node_modules/atomic-sleep/readme.md generated vendored Normal file
View file

@ -0,0 +1,58 @@
<h1 align="center">Welcome to atomic-sleep ⏱️</h1>
<p>
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" />
<a href="#" target="_blank">
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
</a>
<a href="https://twitter.com/davidmarkclem" target="_blank">
<img alt="Twitter: davidmarkclem" src="https://img.shields.io/twitter/follow/davidmarkclem.svg?style=social" />
</a>
</p>
> Zero CPU overhead, zero dependency, true event-loop blocking sleep
## Usage
```js
const sleep = require('atomic-sleep')
console.time('sleep')
setTimeout(() => { console.timeEnd('sleep') }, 100)
sleep(1000)
```
The `console.time` will report a time of just over 1000ms despite the `setTimeout`
being 100ms. This is because the event loop is paused for 1000ms and the setTimeout
fires immediately after the event loop is no longer blocked (as more than 100ms have passed).
## Install
```sh
npm install
```
## Run tests
```sh
npm test
```
## Support
Node and Browser versions that support both `SharedArrayBuffer` and `Atomics` will have (virtually) zero CPU overhead sleep.
For Node, Atomic Sleep can provide zero CPU overhead sleep from Node 8 and up.
For browser support see https://caniuse.com/#feat=sharedarraybuffer and https://caniuse.com/#feat=mdn-javascript_builtins_atomics.
For older Node versions and olders browsers we fall back to blocking the event loop in a way that will cause a CPU spike.
## Author
👤 **David Mark Clements (@davidmarkclem)**
* Twitter: [@davidmarkclem](https://twitter.com/davidmarkclem)
* Github: [@davidmarkclements](https://github.com/davidmarkclements)

47
node_modules/atomic-sleep/test.js generated vendored Normal file
View file

@ -0,0 +1,47 @@
'use strict'
const test = require('tape')
const sleep = require('.')
test('blocks event loop for given amount of milliseconds', ({ is, end }) => {
const now = Date.now()
setTimeout(() => {
const delta = Date.now() - now
const fuzzyDelta = Math.floor(delta / 10) * 10 // allow up to 10ms of execution lag
is(fuzzyDelta, 1000)
end()
}, 100)
sleep(1000)
})
if (typeof BigInt !== 'undefined') {
test('allows ms to be supplied as a BigInt number', ({ is, end }) => {
const now = Date.now()
setTimeout(() => {
const delta = Date.now() - now
const fuzzyDelta = Math.floor(delta / 10) * 10 // allow up to 10ms of execution lag
is(fuzzyDelta, 1000)
end()
}, 100)
sleep(BigInt(1000)) // avoiding n notation as this will error on legacy node/browsers
})
}
test('throws range error if ms less than 0', ({ throws, end }) => {
throws(() => sleep(-1), RangeError('sleep: ms must be a number that is greater than 0 but less than Infinity'))
end()
})
test('throws range error if ms is Infinity', ({ throws, end }) => {
throws(() => sleep(Infinity), RangeError('sleep: ms must be a number that is greater than 0 but less than Infinity'))
end()
})
test('throws range error if ms is not a number or bigint', ({ throws, end }) => {
throws(() => sleep('Infinity'), TypeError('sleep: ms must be a number'))
throws(() => sleep('foo'), TypeError('sleep: ms must be a number'))
throws(() => sleep({a: 1}), TypeError('sleep: ms must be a number'))
throws(() => sleep([1,2,3]), TypeError('sleep: ms must be a number'))
end()
})