Socket
Socket
Sign inDemoInstall

@repeaterjs/timers

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.1 to 0.3.0

lib/timers.cjs.js

34

package.json
{
"name": "@repeaterjs/timers",
"version": "0.2.1",
"description": "Cancelable timers, implemented with channels",
"homepage": "https://channel.js.org",
"version": "0.3.0",
"description": "Async iterator timer functions",
"repository": {
"type": "git",
"url": "https://github.com/repeaterjs/repeater",
"directory": "packages/pubsub"
"directory": "packages/timers"
},

@@ -15,5 +14,5 @@ "license": "MIT",

],
"main": "lib/index.cjs.js",
"module": "lib/index.esm.js",
"types": "lib/index.d.ts",
"main": "lib/timers.cjs.js",
"module": "lib/timers.esm.js",
"types": "lib/timers.d.ts",
"scripts": {

@@ -23,5 +22,5 @@ "prebuild": "yarn run clean",

"clean": "shx rm -rf ./lib",
"test": "jest --config ../../jest.config.js --rootDir --color",
"lint": "eslint --ext ts src",
"prepublishOnly": "yarn run test && yarn run build"
"prepublishOnly": "yarn run test && yarn run build",
"test": "jest --config ../../jest.config.js --rootDir --color"
},

@@ -31,2 +30,19 @@ "dependencies": {

},
"devDependencies": {
"@types/jest": "^24.0.18",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"eslint": "^6.2.1",
"eslint-config-prettier": "^6.1.0",
"eslint-plugin-jest": "^22.15.2",
"eslint-plugin-prettier": "^3.1.0",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"rollup": "^1.20.0",
"rollup-plugin-typescript2": "^0.22.1",
"shx": "^0.3.2",
"ts-jest": "^24.0.0",
"typescript": "^3.5.3",
"weak": "^1.0.1"
},
"publishConfig": {

@@ -33,0 +49,0 @@ "access": "public"

@@ -1,25 +0,25 @@

# @channel/timers
# @repeaterjs/timers
This package is experimental!
Cancelable timers, implemented with channels
Cancelable timers, implemented with repeaters
For more information, visit [channel.js.org](https://channel.js.org).
For more information, visit [repeater.js.org](https://repeater.js.org).
```ts
function delay(wait: number): Channel<number>;
function delay(wait: number): Repeater<number>;
```
`delay` returns a channel which yields `Date.now()` `wait` milliseconds after `next` is called. Each call to `next` runs an independent timer. All outstanding timers can be canceled by calling `return`.
`delay` returns a repeater which yields `Date.now()` `wait` milliseconds after `next` is called. Each call to `next` runs an independent timer. All outstanding timers can be canceled by calling `return`.
```ts
function timeout(wait: number): Channel<undefined>;
function timeout(wait: number): Repeater<undefined>;
```
`timeout` returns a channel which rejects with a `TimeoutError` if the channel does not receive another call to `next` or `return` after the specified `wait`. This behavior is useful when you want to place a fixed upper bound on how long each iteration of an async iterator can take with `Channel.race`.
`timeout` returns a repeater which rejects with a `TimeoutError` if the repeater does not receive another call to `next` or `return` after the specified `wait`. This behavior is useful when you want to place a fixed upper bound on how long each iteration of an async iterator can take with `Repeater.race`.
```js
import { Channel } from "@channel/channel";
import { timeout } from "@channel/timers";
import { Repeater } from "@repeaterjs/repeater";
import { timeout } from "@repeaterjs/timers";
const chan = new Channel(async (push) => {
const chan = new Repeater(async (push) => {
await push(1);

@@ -33,3 +33,3 @@ await push(2);

(async () => {
for await (const num of Channel.race([chan, timeout(1000)])) {
for await (const num of Repeater.race([chan, timeout(1000)])) {
console.log(num); // 1, 2

@@ -44,5 +44,5 @@ }

```ts
function interval(wait: number, buffer?: ChannelBuffer<number>): Channel<number>;
function interval(wait: number, buffer?: RepeaterBuffer<number>): Repeater<number>;
```
`interval` returns a channel which resolves with the current timestamp every `wait` milliseconds. The timer does not start until you call `next` on the returned iterator, and can be canceled by calling `return`.
`interval` returns a repeater which resolves with the current timestamp every `wait` milliseconds. The timer does not start until you call `next` on the returned iterator, and can be canceled by calling `return`.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc