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

asynciterator

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asynciterator - npm Package Compare versions

Comparing version 3.0.0-beta.5 to 3.0.0-beta.6

taskscheduler.cjs

7

asynciterator.d.ts

@@ -7,2 +7,9 @@ /**

import { EventEmitter } from 'events';
import type { Task, TaskScheduler } from './taskscheduler';
/** Schedules the given ask for asynchronous execution. */
export declare function scheduleTask(task: Task): void;
/** Returns the asynchronous task scheduler. */
export declare function getTaskScheduler(): TaskScheduler;
/** Sets the asynchronous task scheduler. */
export declare function setTaskScheduler(scheduler: TaskScheduler): void;
/**

@@ -9,0 +16,0 @@ ID of the INIT state.

26

package.json
{
"name": "asynciterator",
"version": "3.0.0-beta.5",
"version": "3.0.0-beta.6",
"description": "An asynchronous iterator library for advanced object pipelines.",

@@ -16,13 +16,18 @@ "author": "Ruben Verborgh <ruben@verborgh.org>",

"files": [
"asynciterator.mjs",
"asynciterator.cjs",
"asynciterator.d.ts"
"*.mjs",
"*.cjs",
"*.d.ts"
],
"scripts": {
"build": "npm run build:module && npm run build:commonjs && npm run build:types",
"build:module": "tsc --module es2015 && mv asynciterator.js asynciterator.mjs",
"build:commonjs": "tsc --module commonjs && mv asynciterator.js asynciterator.cjs",
"build:types": "tsc -d && rm asynciterator.js",
"build": "npm run build:clean && npm run build:module && npm run build:commonjs && npm run build:types",
"build:clean": "rm -f *.js *.mjs *.cjs *.d.ts",
"build:module": " tsc --module es2015 && ./.change-extension mjs *.js && npm run build:fix:mjs",
"build:commonjs": "tsc --module commonjs && ./.change-extension cjs *.js && npm run build:fix:cjs",
"build:fix:mjs": "sed -i'.bak' -e 's/\\.\\/taskscheduler/.\\/taskscheduler.mjs/' asynciterator.mjs",
"build:fix:cjs": "sed -i'.bak' -e 's/\\.\\/taskscheduler/.\\/taskscheduler.cjs/' asynciterator.cjs",
"build:types": "tsc -d && rm *.js",
"prepare": "npm run build",
"test": "npm run build:module && npm run mocha",
"test": "npm run build:module && npm run test:microtask",
"test:microtask": "npm run mocha",
"test:immediate": "npm run mocha -- --require test/useSetImmediate.js",
"mocha": "c8 mocha",

@@ -35,5 +40,2 @@ "lint": "eslint asynciterator.ts test",

"repository": "RubenVerborgh/AsyncIterator",
"dependencies": {
"queue-microtask": "^1.1.2"
},
"devDependencies": {

@@ -40,0 +42,0 @@ "@babel/cli": "^7.10.1",

@@ -60,23 +60,23 @@ # Asynchronous iterators for JavaScript

```JavaScript
var AsyncIterator = require('asynciterator');
import https from 'https';
import { resolve } from 'url';
import { IntegerIterator } from 'asynciterator';
// Iterate over the natural numbers
var numbers = new AsyncIterator.IntegerIterator({ start: 0, end: Infinity });
const numbers = new IntegerIterator({ start: 0, end: Infinity });
// Transform these numbers into Wikipedia URLs
var urls = numbers.map(function (number) {
return 'https://en.wikipedia.org/wiki/' + number;
});
const urls = numbers.map(n => `https://en.wikipedia.org/wiki/${n}`);
// Fetch each corresponding Wikipedia page
var pages = urls.transform(function (url, done) {
require('https').get(url, function (response) {
var page = '';
response.on('data', function (data) { page += data; });
response.on('end', function () { pages._push(page); done(); });
const pages = urls.transform((url, done, push) => {
https.get(url, response => {
let page = '';
response.on('data', data => { page += data; });
response.on('end', () => { push(page); done(); });
});
});
// Extract the links from each page
var links = pages.transform(function (page, done) {
var search = /href="([^"]+)"/g, match, resolve = require('url').resolve;
const links = pages.transform((page, done, push) => {
let search = /href="([^"]+)"/g, match;
while (match = search.exec(page))
this._push(resolve('https://en.wikipedia.org/', match[1]));
push(resolve('https://en.wikipedia.org/', match[1]));
done();

@@ -88,5 +88,6 @@ });

```JavaScript
setInterval(function () {
var link = links.read();
if (link) console.log(link);
setInterval(() => {
const link = links.read();
if (link)
console.log(link);
}, 100);

@@ -119,3 +120,3 @@ ```

```JavaScript
var numbers = new AsyncIterator.IntegerIterator({ start: 1, end: 2 });
const numbers = new IntegerIterator({ start: 1, end: 2 });
console.log(numbers.read()); // 1

@@ -131,4 +132,4 @@ console.log(numbers.read()); // 2

```JavaScript
links.on('readable', function () {
var link;
links.on('readable', () => {
let link;
while (link = links.read())

@@ -146,5 +147,5 @@ console.log(link);

```JavaScript
var numbers = new AsyncIterator.IntegerIterator({ start: 1, end: 100 });
numbers.on('data', function (number) { console.log('number', number); });
numbers.on('end', function () { console.log('all done!'); });
const numbers = new IntegerIterator({ start: 1, end: 100 });
numbers.on('data', number => console.log('number', number));
numbers.on('end', () => console.log('all done!'));
```

@@ -160,7 +161,7 @@

```JavaScript
var numbers = new AsyncIterator.IntegerIterator();
const numbers = new IntegerIterator();
numbers.setProperty('rate', 1234);
console.log(numbers.getProperty('rate')); // 1234
var clone = numbers.clone();
const clone = numbers.clone();
console.log(clone.getProperty('rate')); // 1234

@@ -176,3 +177,3 @@

```JavaScript
var numbers = new AsyncIterator.IntegerIterator();
const numbers = new IntegerIterator();
numbers.getProperty('later', console.log);

@@ -179,0 +180,0 @@ numbers.setProperty('later', 'value');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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