本文整理汇总了TypeScript中lodash.head函数的典型用法代码示例。如果您正苦于以下问题:TypeScript head函数的具体用法?TypeScript head怎么用?TypeScript head使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了head函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
.then(function(addresses) {
addresses.should.have.property('coin');
addresses.should.have.property('count');
addresses.should.have.property('addresses');
addresses.addresses.length.should.be.greaterThan(2);
walletAddress = (_.head(addresses.addresses) as any).address;
walletAddressId = (_.head(addresses.addresses) as any).id;
});
示例2: predict
const predictAddressNo = address => {
const pattern = ['เลขที่', 'N'];
if (predictNo.test(_.head(address))){
checkSum--;
return _.head(address);
} else {
return predict(address, pattern);
}
}
示例3: it
it('should fill __allRecipeIngredients on instantiation if there are _recipes', () => {
let recipe = RecipeMock.entity();
let meal = new Meal({
_recipes: [recipe]
});
expect(meal.__allRecipeIngredients.length).to.equal(recipe._ingredients.length);
expect(_.head(meal.__allRecipeIngredients).recipeIngredient).to.deep.equal(_.head(recipe._ingredients));
});
示例4: yamlStringToDocuments
export function yamlStringToDocuments(yamlString: string): any[] {
try {
const yamlDocuments = loadAll(yamlString, null);
if (Array.isArray(head(yamlDocuments))) {
// Multi-doc entered as list of maps
return head(yamlDocuments);
}
return yamlDocuments;
} catch (e) {
return null;
}
}
示例5: it
it('verifies spec models', ()=>{
const models = codegen.processModels(spec);
expect(models).to.not.be.empty;
_.forEach(models, (model: codegen.Model)=>{
expect(model.name).to.not.be.empty;
});
const modelQuestionType = models['Revinate.LustroFormServiceBundle.Form.QuestionType'];
const account = _.head(_.filter(modelQuestionType.properties, (prop: codegen.ModelProperty)=>(prop.name == 'account')));
expect(account.type).to.be.equal('string');
const name_translations = _.head(_.filter(modelQuestionType.properties, (prop: codegen.ModelProperty)=>(prop.name == 'name_translations')));
expect(name_translations.type).to.be.equal('Revinate_LustroFormServiceBundle_Form_TranslationType[]')
});
示例6: createLineReferenceFromSourceMap
export function createLineReferenceFromSourceMap(refractSourceMap, document: string, documentLines: string[]): any {
const firstSourceMap = lodash.first(refractSourceMap);
if (typeof (firstSourceMap) === 'undefined') {
return {
endIndex: documentLines[documentLines.length - 1].length,
endRow: documentLines.length - 1,
startIndex: 0,
startRow: 0,
};
}
const sourceMapArray = lodash.map(firstSourceMap.content, (sm) => {
return {
charCount: lodash.last(sm),
charIndex: lodash.head(sm),
};
});
// I didn't find any useful example of multiple sourcemap elements.
const sourceMap = lodash.head(sourceMapArray);
const sourceSubstring = document.substring(sourceMap.charIndex, sourceMap.charIndex + sourceMap.charCount);
const sourceLines = sourceSubstring.split(/\r?\n/g);
if (sourceSubstring === '\n' || sourceSubstring === '\r') {
// It's on a newline which I cannot show in the document.
return {
endIndex: lodash.last(documentLines).length,
endRow: documentLines.length,
startIndex: 0,
startRow: 0,
};
}
const startRow = document.substring(0, sourceMap.charIndex).split(/\r?\n/g).length - 1;
const endRow = startRow + sourceLines.length - 1;
const startIndex = documentLines[startRow].indexOf(lodash.head(sourceLines));
const endIndex = documentLines[endRow].length;
return {
startRow,
endRow,
startIndex,
endIndex,
};
}
示例7: getAppropriatePlugin
export function getAppropriatePlugin(queryParam, options: IBaseReaderOptions): IResourceSelectionOptimizer {
const plugins = [
new InClauseUnderConjunction(queryParam, options)
];
return head(plugins.filter(plugin => plugin.isMatched()));
}
示例8: cat
function cat(...rest: any[]) {
const head = _.head(rest)
if (existy(head)) {
return Array.prototype.concat.apply(head, _.tail(rest)) // remove apply eg: head.concat.apply(head, _.tail(rest))
}
return []
}
示例9:
_.map(regions, region_events => {
let region_obj = _.head(region_events);
if (region_events && region_events.length > 1) {
region_obj.timeEnd = region_events[1].time;
region_obj.isRegion = true;
return region_obj;
} else {
if (region_events && region_events.length) {
// Don't change proper region object
if (!region_obj.time || !region_obj.timeEnd) {
// This is cut region
if (isStartOfRegion(region_obj)) {
region_obj.timeEnd = range.to.valueOf() - 1;
} else {
// Start time = null
region_obj.timeEnd = region_obj.time;
region_obj.time = range.from.valueOf() + 1;
}
region_obj.isRegion = true;
}
return region_obj;
}
}
}),
示例10: createUser
async createUser(authID: string, username: string, email: string): Promise<number> {
let created: Date = new Date();
let input: UserRow = new UserRow(undefined, authID, username, email, created, created);
let result: Pick<UserRow, 'id'>[] = await this.db.table(USER_TABLES.USER.name).insert(input).returning([USER_TABLES.USER.schema.id]);
return _.head(result).id;
}