mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
feat(node): add process.binding (#1662)
This commit is contained in:
parent
04a55c008a
commit
e5e9b4eaa4
@ -143,6 +143,7 @@
|
||||
"test-next-tick-ordering2.js",
|
||||
"test-next-tick-when-exiting.js",
|
||||
"test-next-tick.js",
|
||||
"test-process-binding-internalbinding-allowlist.js",
|
||||
"test-querystring-escape.js",
|
||||
"test-querystring-maxKeys-non-finite.js",
|
||||
"test-querystring-multichar-separator.js",
|
||||
|
@ -0,0 +1,48 @@
|
||||
// deno-fmt-ignore-file
|
||||
// deno-lint-ignore-file
|
||||
|
||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||
// Taken from Node 16.13.0
|
||||
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
||||
|
||||
// Flags: --no-warnings
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
// Assert that allowed internalBinding modules are accessible via
|
||||
// process.binding().
|
||||
assert(process.binding('async_wrap'));
|
||||
assert(process.binding('buffer'));
|
||||
assert(process.binding('cares_wrap'));
|
||||
assert(process.binding('constants'));
|
||||
assert(process.binding('contextify'));
|
||||
if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
|
||||
assert(process.binding('crypto'));
|
||||
}
|
||||
assert(process.binding('fs'));
|
||||
assert(process.binding('fs_event_wrap'));
|
||||
assert(process.binding('http_parser'));
|
||||
if (common.hasIntl) {
|
||||
assert(process.binding('icu'));
|
||||
}
|
||||
assert(process.binding('inspector'));
|
||||
assert(process.binding('js_stream'));
|
||||
assert(process.binding('natives'));
|
||||
assert(process.binding('os'));
|
||||
assert(process.binding('pipe_wrap'));
|
||||
assert(process.binding('signal_wrap'));
|
||||
assert(process.binding('spawn_sync'));
|
||||
assert(process.binding('stream_wrap'));
|
||||
assert(process.binding('tcp_wrap'));
|
||||
if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
|
||||
assert(process.binding('tls_wrap'));
|
||||
}
|
||||
assert(process.binding('tty_wrap'));
|
||||
assert(process.binding('udp_wrap'));
|
||||
assert(process.binding('url'));
|
||||
assert(process.binding('util'));
|
||||
assert(process.binding('uv'));
|
||||
assert(process.binding('v8'));
|
||||
assert(process.binding('zlib'));
|
3
node/internal_binding/config.ts
Normal file
3
node/internal_binding/config.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/contextify.ts
Normal file
3
node/internal_binding/contextify.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/credentials.ts
Normal file
3
node/internal_binding/credentials.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/crypto.ts
Normal file
3
node/internal_binding/crypto.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/errors.ts
Normal file
3
node/internal_binding/errors.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/fs.ts
Normal file
3
node/internal_binding/fs.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/fs_dir.ts
Normal file
3
node/internal_binding/fs_dir.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/fs_event_wrap.ts
Normal file
3
node/internal_binding/fs_event_wrap.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/heap_utils.ts
Normal file
3
node/internal_binding/heap_utils.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/http_parser.ts
Normal file
3
node/internal_binding/http_parser.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/icu.ts
Normal file
3
node/internal_binding/icu.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/inspector.ts
Normal file
3
node/internal_binding/inspector.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/js_stream.ts
Normal file
3
node/internal_binding/js_stream.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/messaging.ts
Normal file
3
node/internal_binding/messaging.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
107
node/internal_binding/mod.ts
Normal file
107
node/internal_binding/mod.ts
Normal file
@ -0,0 +1,107 @@
|
||||
import * as asyncWrap from "./async_wrap.ts";
|
||||
import * as buffer from "./buffer.ts";
|
||||
import * as config from "./config.ts";
|
||||
import * as caresWrap from "./cares_wrap.ts";
|
||||
import * as constants from "./constants.ts";
|
||||
import * as contextify from "./contextify.ts";
|
||||
import * as crypto from "./crypto.ts";
|
||||
import * as credentials from "./credentials.ts";
|
||||
import * as errors from "./errors.ts";
|
||||
import * as fs from "./fs.ts";
|
||||
import * as fsDir from "./fs_dir.ts";
|
||||
import * as fsEventWrap from "./fs_event_wrap.ts";
|
||||
import * as heapUtils from "./heap_utils.ts";
|
||||
import * as httpParser from "./http_parser.ts";
|
||||
import * as icu from "./icu.ts";
|
||||
import * as inspector from "./inspector.ts";
|
||||
import * as jsStream from "./js_stream.ts";
|
||||
import * as messaging from "./messaging.ts";
|
||||
import * as moduleWrap from "./module_wrap.ts";
|
||||
import * as nativeModule from "./native_module.ts";
|
||||
import * as natives from "./natives.ts";
|
||||
import * as options from "./options.ts";
|
||||
import * as os from "./os.ts";
|
||||
import * as pipeWrap from "./pipe_wrap.ts";
|
||||
import * as performance from "./performance.ts";
|
||||
import * as processMethods from "./process_methods.ts";
|
||||
import * as report from "./report.ts";
|
||||
import * as serdes from "./serdes.ts";
|
||||
import * as signalWrap from "./signal_wrap.ts";
|
||||
import * as spawnSync from "./spawn_sync.ts";
|
||||
import * as streamWrap from "./stream_wrap.ts";
|
||||
import * as stringDecoder from "./string_decoder.ts";
|
||||
import * as symbols from "./symbols.ts";
|
||||
import * as taskQueue from "./task_queue.ts";
|
||||
import * as tcpWrap from "./tcp_wrap.ts";
|
||||
import * as timers from "./timers.ts";
|
||||
import * as tlsWrap from "./tls_wrap.ts";
|
||||
import * as traceEvents from "./trace_events.ts";
|
||||
import * as ttyWrap from "./tty_wrap.ts";
|
||||
import * as types from "./types.ts";
|
||||
import * as udpWrap from "./udp_wrap.ts";
|
||||
import * as url from "./url.ts";
|
||||
import * as util from "./util.ts";
|
||||
import * as uv from "./uv.ts";
|
||||
import * as v8 from "./v8.ts";
|
||||
import * as worker from "./worker.ts";
|
||||
import * as zlib from "./zlib.ts";
|
||||
|
||||
const modules = {
|
||||
"async_wrap": asyncWrap,
|
||||
buffer,
|
||||
"cares_wrap": caresWrap,
|
||||
config,
|
||||
constants,
|
||||
contextify,
|
||||
credentials,
|
||||
crypto,
|
||||
errors,
|
||||
fs,
|
||||
"fs_dir": fsDir,
|
||||
"fs_event_wrap": fsEventWrap,
|
||||
"heap_utils": heapUtils,
|
||||
"http_parser": httpParser,
|
||||
icu,
|
||||
inspector,
|
||||
"js_stream": jsStream,
|
||||
messaging,
|
||||
"module_wrap": moduleWrap,
|
||||
"native_module": nativeModule,
|
||||
natives,
|
||||
options,
|
||||
os,
|
||||
performance,
|
||||
"pipe_wrap": pipeWrap,
|
||||
"process_methods": processMethods,
|
||||
report,
|
||||
serdes,
|
||||
"signal_wrap": signalWrap,
|
||||
"spawn_sync": spawnSync,
|
||||
"stream_wrap": streamWrap,
|
||||
"string_decoder": stringDecoder,
|
||||
symbols,
|
||||
"task_queue": taskQueue,
|
||||
"tcp_wrap": tcpWrap,
|
||||
timers,
|
||||
"tls_wrap": tlsWrap,
|
||||
"trace_events": traceEvents,
|
||||
"tty_wrap": ttyWrap,
|
||||
types,
|
||||
"udp_wrap": udpWrap,
|
||||
url,
|
||||
util,
|
||||
uv,
|
||||
v8,
|
||||
worker,
|
||||
zlib,
|
||||
};
|
||||
|
||||
export type BindingName = keyof typeof modules;
|
||||
|
||||
export function getBinding(name: BindingName) {
|
||||
const mod = modules[name];
|
||||
if (!mod) {
|
||||
throw new Error(`No such module: ${name}`);
|
||||
}
|
||||
return mod;
|
||||
}
|
3
node/internal_binding/module_wrap.ts
Normal file
3
node/internal_binding/module_wrap.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/native_module.ts
Normal file
3
node/internal_binding/native_module.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/natives.ts
Normal file
3
node/internal_binding/natives.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/options.ts
Normal file
3
node/internal_binding/options.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/os.ts
Normal file
3
node/internal_binding/os.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/performance.ts
Normal file
3
node/internal_binding/performance.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/process_methods.ts
Normal file
3
node/internal_binding/process_methods.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/report.ts
Normal file
3
node/internal_binding/report.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/serdes.ts
Normal file
3
node/internal_binding/serdes.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/signal_wrap.ts
Normal file
3
node/internal_binding/signal_wrap.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/spawn_sync.ts
Normal file
3
node/internal_binding/spawn_sync.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/task_queue.ts
Normal file
3
node/internal_binding/task_queue.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/timers.ts
Normal file
3
node/internal_binding/timers.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/tls_wrap.ts
Normal file
3
node/internal_binding/tls_wrap.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/trace_events.ts
Normal file
3
node/internal_binding/trace_events.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/tty_wrap.ts
Normal file
3
node/internal_binding/tty_wrap.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
@ -1,4 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
//
|
||||
// Adapted from Node.js. Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
|
3
node/internal_binding/udp_wrap.ts
Normal file
3
node/internal_binding/udp_wrap.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/url.ts
Normal file
3
node/internal_binding/url.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/v8.ts
Normal file
3
node/internal_binding/v8.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/worker.ts
Normal file
3
node/internal_binding/worker.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
3
node/internal_binding/zlib.ts
Normal file
3
node/internal_binding/zlib.ts
Normal file
@ -0,0 +1,3 @@
|
||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export {};
|
@ -32,6 +32,8 @@ export {
|
||||
};
|
||||
import { stderr, stdin, stdout } from "./_process/streams.ts";
|
||||
export { stderr, stdin, stdout };
|
||||
import { getBinding } from "./internal_binding/mod.ts";
|
||||
import type { BindingName } from "./internal_binding/mod.ts";
|
||||
|
||||
const notImplementedEvents = [
|
||||
"beforeExit",
|
||||
@ -373,6 +375,10 @@ class Process extends EventEmitter {
|
||||
|
||||
/** https://nodejs.org/api/process.html#process_process_emitwarning_warning_options */
|
||||
emitWarning = emitWarning;
|
||||
|
||||
binding(name: BindingName) {
|
||||
return getBinding(name);
|
||||
}
|
||||
}
|
||||
|
||||
/** https://nodejs.org/api/process.html#process_process */
|
||||
|
Loading…
Reference in New Issue
Block a user