Skip to content

Commit

Permalink
feat: add node: prefix for Deno support (#212)
Browse files Browse the repository at this point in the history
* feat: add node prefix import for Deno support

* remove eslint.config.mjs

* Apply suggestions from code review

* import setImmediate

---------

Co-authored-by: Luke Edwards <[email protected]>
  • Loading branch information
benmccann and lukeed authored Sep 18, 2024
1 parent 9656b12 commit e34ad69
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bench/native.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const http = require('http');
const http = require('node:http');

http.createServer((req, res) => {
if (req.url === '/favicon.ico') return;
Expand Down
6 changes: 3 additions & 3 deletions packages/cluster/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cpus } from 'os';
import cluster from 'cluster';
import { createServer } from 'http';
import { cpus } from 'node:os';
import cluster from 'node:cluster';
import { createServer } from 'node:http';

export default function (app, num) {
if (cluster.isMaster) {
Expand Down
2 changes: 1 addition & 1 deletion packages/compression/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// NOTE: supports Node 6.x

import zlib from 'zlib';
import zlib from 'node:zlib';

const NOOP = () => {};
const MIMES = /text|javascript|\/json|xml/i;
Expand Down
6 changes: 3 additions & 3 deletions packages/compression/test/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { suite } from 'uvu';
import * as assert from 'uvu/assert';

import fs from 'fs';
import * as zlib from 'zlib';
import { join } from 'path';
import fs from 'node:fs';
import * as zlib from 'node:zlib';
import { join } from 'node:path';

import { prepare, toAscii } from './util/index';
import compression from '../index';
Expand Down
2 changes: 1 addition & 1 deletion packages/compression/test/util/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IncomingMessage, ServerResponse } from 'http';
import { IncomingMessage, ServerResponse } from 'node:http';

// IncomingMessage
class Request {
Expand Down
2 changes: 1 addition & 1 deletion packages/parse/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { decode } from 'querystring';
import { decode } from 'node:querystring';

const noop = x => x;

Expand Down
3 changes: 2 additions & 1 deletion packages/polka/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import http from 'http';
import http from 'node:http';
import { setImmediate } from 'node:timers';
import { Trouter } from 'trouter';
import { parse } from '@polka/url';

Expand Down
2 changes: 1 addition & 1 deletion packages/polka/test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-console */
import http from 'http';
import http from 'node:http';
import { test } from 'uvu';
import * as assert from 'uvu/assert';
import { get, send, post } from 'httpie';
Expand Down
2 changes: 1 addition & 1 deletion packages/redirect/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from 'url';
import { resolve } from 'node:url';

export default function (res, code=302, location='') {
if (!location && typeof code === 'string') {
Expand Down
4 changes: 2 additions & 2 deletions packages/send/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { STATUS_CODES } from 'http';
import { createHash } from 'crypto';
import { STATUS_CODES } from 'node:http';
import { createHash } from 'node:crypto';

const TYPE = 'Content-Type';
const LENGTH = 'Content-Length';
Expand Down
4 changes: 2 additions & 2 deletions packages/send/test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import fs from 'node:fs';
import { join } from 'node:path';
import { suite } from 'uvu';
import { join } from 'path';
import * as assert from 'uvu/assert';
import { Response, toStatusText } from './util';
import send from '../index';
Expand Down
2 changes: 1 addition & 1 deletion packages/send/test/util/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STATUS_CODES } from 'http';
import { STATUS_CODES } from 'node:http';

export const toStatusText = code => STATUS_CODES[code];

Expand Down
2 changes: 1 addition & 1 deletion packages/url/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as qs from 'querystring';
import * as qs from 'node:querystring';

/**
* @typedef ParsedURL
Expand Down

0 comments on commit e34ad69

Please sign in to comment.