Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jul 11, 2023
1 parent 3257f16 commit b0e70ec
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ related to hardening of iterators, because they incur a much more
significant performance impact.

The various `XPrototypeConstructor` properties are not included,
because they're useless. (Can't be called with `new` because
because they're useless. (Can't be called with `new` because
they're bound functions, but _must_ be called with `new` because
they're constructors.)
77 changes: 48 additions & 29 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ const uncurryGetter = <O extends object, K extends keyof O, T = O>(
): UncurryGetter<O, K, T> => {
const desc = SafeReflect.getOwnPropertyDescriptor(obj, k)
if (desc?.get) {
return uncurryThis(desc.get);
return uncurryThis(desc.get)
}
throw new Error('invalid uncurryGetter call: ' + String(k))
}
Expand Down Expand Up @@ -1261,25 +1261,25 @@ const SafeReflect = Reflect
const ogProcess = (
typeof GLOBALTHIS.process === 'object' && !!GLOBALTHIS.process
? GLOBALTHIS.process
: {
argv: [],
argv0: '',
execArgv: [],
cwd: () => '.',
execPath: '',
env: {},
pid: 0,
ppid: 0,
title: '',
version: '',
versions: {},
platform: '',
release: {},
arch: '',
moduleLoadList: [],
features: {},
debugPort: 0,
}
: {
argv: [],
argv0: '',
execArgv: [],
cwd: () => '.',
execPath: '',
env: {},
pid: 0,
ppid: 0,
title: '',
version: '',
versions: {},
platform: '',
release: {},
arch: '',
moduleLoadList: [],
features: {},
debugPort: 0,
}
) as NodeJS.Process & {
moduleLoadList: string[]
initgroups?: (user: string | number, extraGroup: string | number) => void
Expand Down Expand Up @@ -2064,14 +2064,33 @@ const StringPrototypePadEnd = uncurryThis(String.prototype.padEnd)
const StringPrototypePadStart = uncurryThis(String.prototype.padStart)
const StringPrototypeRepeat = uncurryThis(String.prototype.repeat)
const StringPrototypeReplace = uncurryThis(String.prototype.replace) as {
(self: string, searchValue: string | RegExp, replaceValue: string): string;
(self: string, searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string;
(self: string, searchValue: {
[Symbol.replace](string: string, replaceValue: string): string;
}, replaceValue: string): string;
(self: string, searchValue: {
[Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string;
}, replacer: (substring: string, ...args: any[]) => string): string;
(
self: string,
searchValue: string | RegExp,
replaceValue: string
): string
(
self: string,
searchValue: string | RegExp,
replacer: (substring: string, ...args: any[]) => string
): string
(
self: string,
searchValue: {
[Symbol.replace](string: string, replaceValue: string): string
},
replaceValue: string
): string
(
self: string,
searchValue: {
[Symbol.replace](
string: string,
replacer: (substring: string, ...args: any[]) => string
): string
},
replacer: (substring: string, ...args: any[]) => string
): string
} // Fix overload
const StringPrototypeSearch = uncurryThis(String.prototype.search)
const StringPrototypeSlice = uncurryThis(String.prototype.slice)
Expand Down Expand Up @@ -2320,7 +2339,7 @@ const processArch = String(ogProcess.arch)
const processPlatform = String(ogProcess.platform)
const processRelease = Object.freeze(cloneSafe(ogProcess.release))
const processModuleLoadList = Object.freeze([
...(ogProcess.moduleLoadList).map(s => String(s)),
...ogProcess.moduleLoadList.map(s => String(s)),
])
const processFeatures = Object.freeze(cloneSafe(ogProcess.features))
const processNextTick = staticCall(ogProcess.nextTick)
Expand Down
2 changes: 1 addition & 1 deletion test/clobber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const PROC = process

//@ts-ignore
globalThis.process = null
import { primordials as p} from '../dist/cjs/index.js'
import { primordials as p } from '../dist/cjs/index.js'
globalThis.process = PROC

t.equal(p.processCwd(), '.')
Expand Down
6 changes: 3 additions & 3 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ t.test('maybeStaticCall', t => {
})

t.test('StringPrototypeReplace sanity', t => {
t.equal(primordials.StringPrototypeReplace('foo', 'o', 'a'), 'fao');
t.equal(StringPrototypeReplace('foo', 'o', 'a'), 'fao');
t.equal(primordials.StringPrototypeReplace('foo', 'o', 'a'), 'fao')
t.equal(StringPrototypeReplace('foo', 'o', 'a'), 'fao')
t.end()
});
})

0 comments on commit b0e70ec

Please sign in to comment.