本文整理汇总了TypeScript中humps.camelizeKeys函数的典型用法代码示例。如果您正苦于以下问题:TypeScript camelizeKeys函数的具体用法?TypeScript camelizeKeys怎么用?TypeScript camelizeKeys使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了camelizeKeys函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fetchOptionsWithDebug
export async function callApi<T = void>(
fetchOptions: KFetchOptions,
{ camelcase = true, prependBasePath = true } = {}
): Promise<T> {
const combinedFetchOptions = fetchOptionsWithDebug(fetchOptions);
const res = await kfetch(combinedFetchOptions, { prependBasePath });
return camelcase ? camelizeKeys(res) : res;
}
示例2: dispatch
.subscribe(responce => {
let body = responce.json();
body = humps.camelizeKeys(body);
if (body.status === `OK`) {
dispatch(this.SET_ENTITIES(body.results));
} else {
console.error('FETCH_ENTITIES', body.results);
}
}, error => console.error('FETCH_ENTITIES', error));
示例3: normalize
protected normalize(response, schema) {
let camelizedJson = camelizeKeys(response);
let normalizedResponse = normalize(camelizedJson, schema);
return {
result: fromJS(normalizedResponse.result),
entities: fromJS(normalizedResponse.entities)
};
}
示例4: function
split: /^[A-Z0-9_]+$/
};
let someOptions3: humps.HumpsOptions = {
separator: '-',
process: function (key: string, convert: humps.HumpsProcessorParameter, options: humps.HumpsOptions) {
return /^[A-Z0-9_]+$/.test(key) ? key : convert(key, options);
}
};
humps.camelize('hello_world')
humps.decamelize('fooBar')
humps.decamelize('fooBarBaz', someOptions)
humps.camelizeKeys(someObject);
humps.camelizeKeys(someArray);
humps.camelizeKeys(someObject, function (key, convert) {
return /^[A-Z0-9_]+$/.test(key) ? key : convert(key);
});
humps.decamelizeKeys(someObject, function (key, convert, options) {
return /^[A-Z0-9_]+$/.test(key) ? key : convert(key, options);
});
humps.camelize('hello_world-foo bar');
humps.pascalize('hello_world-foo bar');