本文整理汇总了TypeScript中lodash/get.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: switch
export const searchReducer: ActionReducer<Object> = (state: ISearchState = defaultState, action: Action) => {
const payload = action.payload;
switch (action.type) {
case types.REQUEST: {
const { searchTerm, itemType, reset = false } = payload;
const key = getKey(itemType, searchTerm);
return {
...state,
[key]: {
...(state[key] || defaultItem),
submitting: true,
loadedPage: reset ? 0 : _get(state, `[${key}].loadedPage`, 0)
}
}
}
case types.SUCCESS: {
const { itemType, query, searchTerm, totalPages, list = [], loadedPage = 0, reset = false } = payload;
const ids = list.map((item) => item.id);
const key = getKey(itemType, searchTerm);
return {
...state,
[key]: {
...(state[key] || defaultItem),
submitting: false,
error: false,
loadedPage,
totalPages,
perPage: query.per_page,
list: (reset || !state[key] ? defaultItem : state[key]).list.concat(ids)
}
};
}
case types.ERROR: {
const { itemType, searchTerm } = payload;
const key = getKey(itemType, searchTerm);
return {
...state,
[key]: {
...state[key],
submitting: false,
error: true,
}
}
}
case CLEAN_CACHE: {
return defaultState;
}
default:
return state;
}
}
示例2: reduce
export default function reduce(state: State = {} as State, action: any) {
return {
dirtyHandlerIds: dirtyHandlerIds(state.dirtyHandlerIds, {
type: action.type,
payload: {
...action.payload,
prevTargetIds: get(state, 'dragOperation.targetIds', []),
},
}),
dragOffset: dragOffset(state.dragOffset, action),
refCount: refCount(state.refCount, action),
dragOperation: dragOperation(state.dragOperation, action),
stateId: stateId(state.stateId),
}
}
示例3: getAggregations
getAggregations(path, defaultValue){
const results = this.getResults()
const getPath = ['aggregations',...path]
return get(results, getPath, defaultValue)
}
示例4: Error
mergeData.forEach((entity: any) => {
const key = get(entity, keyPath);
if (!key) {
throw new Error(`Invalid key property with path "${keyPath}" in entitiesUtils::mergeEntitiesBy()`);
}
result[key] = iteratee(source[key], entity);
});
示例5: resolveRef
function resolveRef(
id: string,
schema: object,
options: Options
): InstantiateResult {
const withoutRef = omit(schema, '$ref');
const { schemaId = id, path } = parseRef(schema['$ref']);
const validateFunction = options.ajv.getSchema(schemaId);
if (!validateFunction) {
return { hasResult: false, error: options.ajv.errors };
}
const resolved = get(
validateFunction.schema,
path.filter(p => p !== undefined),
{}
);
const result = merge({}, resolved, withoutRef);
return recursiveInstantiate(schemaId, result, options);
}
示例6: jsonParse
export const csvParse = (csvContent, options) => {
const { hasCategory } = options
const mergeRows = (acc, { question, answer, answer2, category, action }) => {
const [prevRow] = acc.slice(-1)
const isSameAnswer = prevRow && (prevRow.answer === answer && (!answer2 || answer2 === prevRow.answer2))
if (isSameAnswer) {
return [...acc.slice(0, acc.length - 1), { ...prevRow, questions: [...prevRow.questions, question] }]
}
const categoryWrapper = hasCategory ? { category } : {}
return [...acc, { answer, answer2, action, ...categoryWrapper, questions: [question] }]
}
const categoryWrapper = hasCategory ? ['category'] : []
const rows = parseCsvToJson(csvContent, {
columns: ['question', 'action', 'answer', 'answer2', ...categoryWrapper]
}).reduce(mergeRows, [])
// We trim the header if detected in the first row
if (get(rows, '0.action') === 'action') {
rows.splice(0, 1)
}
return jsonParse(rows, options)
}
示例7: get
getSuggestion(){
return get(this.searchkit.getSuggestions(), [0,"options", 0, "text"], false)
}
示例8: Error
constructor(fieldOptions){
super(fieldOptions)
if(!get(this.fieldOptions, "options.childType")){
throw new Error("fieldOptions type:children requires options.childType")
}
}
示例9:
(listState: any, item = {}, itemsToDisplay) =>
_take(_get(listState, 'list', []), itemsToDisplay).map(id => item[id])));