diff --git a/regedit.d.ts b/regedit.d.ts index 98c7a2b97..f966d0024 100644 --- a/regedit.d.ts +++ b/regedit.d.ts @@ -59,17 +59,30 @@ export const OS_ARCH_32BIT = "32"; export const OS_ARCH_64BIT = "64"; type Architecture = (typeof OS_ARCH_AGNOSTIC | typeof OS_ARCH_SPECIFIC | typeof OS_ARCH_32BIT | typeof OS_ARCH_64BIT); -type ErrResCallback = (err: Error | undefined, res: RegistryItemCollection) => void; +type ErrResCallback = (err: Error | undefined, res: T) => void; -export function list(keys: readonly K[], callback: ErrResCallback): void; -export function list(keys: readonly K[], architecture: Architecture, callback?: ErrResCallback): void; +export function list(keys: readonly K[], callback: ErrResCallback>): void; +export function list(keys: readonly K[], architecture: Architecture, callback?: ErrResCallback>): void; + +interface Stream { + on(event: "data", callback: (entry: T) => void): Stream; + on(event: "finish", callback: () => void): Stream; +} + +interface RegistryEntry { + key: T; + data: RegistryItem; +} + +export function list(keys: readonly K[]): Stream>; +export function list(keys: readonly K[], architecture: Architecture): Stream>; export function setExternalVBSLocation(newLocation: string): string; interface ErrorWithCode extends Error { code: number; description: string; - } +} type ErrCallback = (err: ErrorWithCode | undefined) => void; @@ -82,10 +95,27 @@ export function deleteKey(keys: readonly string[], architecture: Architecture, c export function putValue(map: RegistryItemPutCollection, callback: ErrCallback): void; export function putValue(map: RegistryItemPutCollection, architecture: Architecture, callback?: ErrCallback): void; +interface UnexpandedValue { + path: T; + exists: boolean; + value: string; +} + +export function listUnexpandedValues(key: K, callback: ErrResCallback[]>): void; +export function listUnexpandedValues(key: K): Stream>; +export function listUnexpandedValues(keys: K[], callback: ErrResCallback[]>): void; +export function listUnexpandedValues(keys: K[]): Stream>; +export function listUnexpandedValues(key: K, architecture: Architecture, callback: ErrResCallback[]>): void; +export function listUnexpandedValues(key: K, architecture: Architecture): Stream>; +export function listUnexpandedValues(keys: K[], architecture: Architecture, callback: ErrResCallback[]>): void; +export function listUnexpandedValues(keys: K[], architecture: Architecture): Stream>; + export namespace arch { - export function list(keys: readonly K[], callback: ErrResCallback): void; - export function list32(keys: readonly K[], callback: ErrResCallback): void; - export function list64(keys: readonly K[], callback: ErrResCallback): void; + export function list(keys: readonly K[], callback: ErrResCallback>): void; + export function list32(keys: readonly K[], callback: ErrResCallback>): void; + export function list64(keys: readonly K[], callback: ErrResCallback>): void; + export function list32(keys: readonly K[]): Stream>; + export function list64(keys: readonly K[]): Stream>; export function createKey(keys: readonly string[], callback: ErrCallback): void; export function createKey32(keys: readonly string[], callback: ErrCallback): void; export function createKey64(keys: readonly string[], callback: ErrCallback): void; @@ -95,6 +125,15 @@ export namespace arch { export function putValue(map: RegistryItemPutCollection, callback: ErrCallback): void; export function putValue32(map: RegistryItemPutCollection, callback: ErrCallback): void; export function putValue64(map: RegistryItemPutCollection, callback: ErrCallback): void; + + export function listUnexpandedValues32(key: K, callback: ErrResCallback[]>): void; + export function listUnexpandedValues64(key: K, callback: ErrResCallback[]>): void; + export function listUnexpandedValues32(key: K): Stream>; + export function listUnexpandedValues64(key: K): Stream>; + export function listUnexpandedValues32(keys: K[], callback: ErrResCallback[]>): void; + export function listUnexpandedValues64(keys: K[], callback: ErrResCallback[]>): void; + export function listUnexpandedValues32(keys: K[]): Stream>; + export function listUnexpandedValues64(keys: K[]): Stream>; } export namespace promisified { @@ -107,6 +146,11 @@ export namespace promisified { export function putValue(map: RegistryItemPutCollection): Promise; export function putValue(map: RegistryItemPutCollection, architecture: Architecture): Promise; + export function listUnexpandedValues(key: K): Promise[]>; + export function listUnexpandedValues(keys: K[]): Promise[]>; + export function listUnexpandedValues(key: K, architecture: Architecture): Promise[]>; + export function listUnexpandedValues(keys: K[], architecture: Architecture): Promise[]>; + export namespace arch { export function list(keys: readonly K[]): Promise>; export function list32(keys: readonly K[]): Promise>; @@ -120,5 +164,10 @@ export namespace promisified { export function putValue(map: RegistryItemPutCollection): Promise; export function putValue32(map: RegistryItemPutCollection): Promise; export function putValue64(map: RegistryItemPutCollection): Promise; + + export function listUnexpandedValues32(key: K): Promise[]>; + export function listUnexpandedValues64(key: K): Promise[]>; + export function listUnexpandedValues32(keys: K[]): Promise[]>; + export function listUnexpandedValues64(keys: K[]): Promise[]>; } } diff --git a/test/regedit.test.js b/test/regedit.test.js index 47c328f07..228ecf5af 100644 --- a/test/regedit.test.js +++ b/test/regedit.test.js @@ -832,7 +832,8 @@ describe('regedit', function() { describe('listUnexpandedValues', function () { it('reads values without expanding environment variables embedded in them', function(done) { - index.listUnexpandedValues('HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData', function(err, result) { + const key = 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\AppData' + index.listUnexpandedValues(key, function(err, result) { if (err) { return done(err) }