GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: als variant of test-timers-clearImmediate · nodejs/node@1905b9e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-timers-clearImmediate-als.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-timers-clearImmediate-als.js‎

Copy file name to clipboard
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const { AsyncLocalStorage } = require('async_hooks');
5+
6+
// This is an asynclocalstorage variant of test-timers-clearImmediate.js
7+
const asyncLocalStorage = new AsyncLocalStorage();
8+
const N = 3;
9+
10+
function next() {
11+
const fn = common.mustCall(onImmediate);
12+
asyncLocalStorage.run(new Map(), common.mustCall(() => {
13+
const immediate = setImmediate(fn);
14+
const store = asyncLocalStorage.getStore();
15+
store.set('immediate', immediate);
16+
}));
17+
}
18+
19+
function onImmediate() {
20+
const store = asyncLocalStorage.getStore();
21+
const immediate = store.get('immediate');
22+
assert.strictEqual(immediate.constructor.name, 'Immediate');
23+
clearImmediate(immediate);
24+
}
25+
26+
for (let i = 0; i < N; i++) {
27+
next();
28+
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.