本文整理汇总了TypeScript中lodash.snakeCase函数的典型用法代码示例。如果您正苦于以下问题:TypeScript snakeCase函数的具体用法?TypeScript snakeCase怎么用?TypeScript snakeCase使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了snakeCase函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: joinTableName
joinTableName(firstTableName: string,
secondTableName: string,
firstPropertyName: string,
secondPropertyName: string,
firstColumnName: string,
secondColumnName: string): string {
return _.snakeCase(firstTableName + "_" + firstPropertyName + "_" + secondTableName + "_" + secondColumnName);
}
示例2:
Object.entries(settings).forEach(([key, value]) => {
// Avoid snake casing keys that are the result of being flattened, such as `security.principal` and `conf.*`
if (key.includes('.')) {
serializedSettings[key] = value;
} else {
serializedSettings[snakeCase(key)] = value;
}
});
示例3: getSpecialValue
export function getSpecialValue(key: string | number):
SPECIAL_VALUES {
const k = snakeCase(("" + key).toUpperCase()).toUpperCase();
const v = get(SPECIAL_VALUES, k, NaN);
if (isUndefined(v) || isNaN(v)) {
throw new Error("Not a SPECIAL_VALUE: " + k);
} else {
return v;
}
}
示例4: getModel
export function getModel(
sequelize: Sequelize.Sequelize,
kilnModel: IKilnModel,
kiln: IKiln,
): Sequelize.Model<Sequelize.Instance<object>, object> {
const sequelizeDatatypes: Sequelize.DefineAttributes = {}
addSequelizeDatatypes(sequelizeDatatypes, kilnModel.model)
constraints.addPrimaryKey(sequelizeDatatypes, kilnModel.model)
constraints.addAutomanaged(sequelizeDatatypes, kilnModel.model)
constraints.addForeignKeys(sequelizeDatatypes, kilnModel.model, kiln)
const tableName = kilnModel.meta.tableName || snakeCase(kilnModel.meta.plural!)
return sequelize.define(kilnModel.name, sequelizeDatatypes, {
indexes: getIndexes(kilnModel.model, tableName),
tableName,
})
}
示例5:
function fieldMap<F> (
model: Model<F> | IResourceObject,
base: _.Dictionary<any> = {}
): _.Dictionary<any> {
const fields: _.Dictionary<any> = _.merge(
base,
model instanceof Model
? model.fields
: model.attributes
)
const result: _.Dictionary<any> = {}
let key: string
for (key in fields) {
if (!_.has(fields, key)) {
continue
}
result[_.snakeCase(key)] = fields[key]
}
return result
}
示例6: GetAllBooks
import { Category } from './enums'; // filename no extension
import { Book, Logger, Author, Librarion , Magazine} from './interfaces';
import { UniversityLibrarian, ReferenceItem} from './classes';
import refBook from './Encyclopedia';
import { CalculateLateFee as CalcFee, MaxBooksAllowed, Purge } from './lib/utilityFunctions';
import Shelf from "./shelf";
import * as _ from 'lodash';
let snakeCaseTitle = _.snakeCase('For Whom the Bell Tolls');
console.log(snakeCaseTitle);
let reference = new refBook("Fact book", 2016, 1);
function GetAllBooks():Book[] {
let books = [
{id: 1, title: 'Ulysses', author: 'James Joyce', available: true, category: Category.Fiction},
{id: 2, title: 'A Farewell to Arms', author: 'Ernest Hemingway', available: false, category: Category.Poetry},
{
id: 3,
title: 'I Know Why the Caged Bird Sings',
author: 'Maya Angelou',
available: true,
category: Category.Poetry
},
{id: 4, title: 'Moby Dick', author: 'Herman Melville', available: true, category: Category.Fiction}
];
return books;
}
示例7: getDbName
function getDbName(name) {
return _.snakeCase(name);
}
示例8:
return _.mapKeys(object, (value, key) => {
return _.snakeCase(key);
});
示例9: tableName
tableName(className: string, customName: string): string {
return customName ? customName : _.snakeCase(className);
}
示例10: relationName
relationName(propertyName: string): string {
return _.snakeCase(propertyName);
}