action-debian-package/node_modules/camelcase-keys/index.d.ts

104 lines
2.1 KiB
TypeScript
Raw Normal View History

2020-03-26 14:37:35 +00:00
declare namespace camelcaseKeys {
interface Options {
/**
Recurse nested objects and objects in arrays.
@default false
*/
readonly deep?: boolean;
/**
Exclude keys from being camel-cased.
@default []
*/
readonly exclude?: ReadonlyArray<string | RegExp>;
/**
Exclude children at the given object paths in dot-notation from being camel-cased. For example, with an object like `{a: {b: '🦄'}}`, the object path to reach the unicorn is `'a.b'`.
@default []
@example
```
camelcaseKeys({
a_b: 1,
a_c: {
c_d: 1,
c_e: {
e_f: 1
}
}
}, {
deep: true,
stopPaths: [
'a_c.c_e'
]
}),
// {
// aB: 1,
// aC: {
// cD: 1,
// cE: {
// e_f: 1
// }
// }
// }
```
*/
readonly stopPaths?: ReadonlyArray<string>;
/**
Uppercase the first character as in `bye-bye` `ByeBye`.
@default false
*/
readonly pascalCase?: boolean;
}
}
/**
Convert object keys to camel case using [`camelcase`](https://github.com/sindresorhus/camelcase).
@param input - Object or array of objects to camel-case.
@example
```
import camelcaseKeys = require('camelcase-keys');
// Convert an object
camelcaseKeys({'foo-bar': true});
//=> {fooBar: true}
// Convert an array of objects
camelcaseKeys([{'foo-bar': true}, {'bar-foo': false}]);
//=> [{fooBar: true}, {barFoo: false}]
camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true});
//=> {fooBar: true, nested: {unicornRainbow: true}}
// Convert object keys to pascal case
camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true, pascalCase: true});
//=> {FooBar: true, Nested: {UnicornRainbow: true}}
import minimist = require('minimist');
const argv = minimist(process.argv.slice(2));
//=> {_: [], 'foo-bar': true}
camelcaseKeys(argv);
//=> {_: [], fooBar: true}
```
*/
declare function camelcaseKeys<T extends ReadonlyArray<{[key: string]: any}>>(
input: T,
options?: camelcaseKeys.Options,
): T;
declare function camelcaseKeys<T extends {[key: string]: any}>(
input: T,
options?: camelcaseKeys.Options,
): T;
export = camelcaseKeys;