本文整理汇总了TypeScript中ramda.keys函数的典型用法代码示例。如果您正苦于以下问题:TypeScript keys函数的具体用法?TypeScript keys怎么用?TypeScript keys使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了keys函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: requestKeys
/**
* Given a path somewhere within the tree, list the keys found if it is an object.
*
* @param command The command received from the reactotron app.
*/
function requestKeys(command: any) {
const trackedNode = trackedNodes[command.mstNodeName || "default"]
const atPath: string = (command && command.payload && command.payload.path) || []
if (trackedNode && trackedNode.node && atPath) {
const state = getSnapshot(trackedNode.node)
if (isNilOrEmpty(atPath)) {
reactotron.stateKeysResponse(null, keys(state))
} else {
const keyList = keys(dotPath(atPath, state))
reactotron.stateKeysResponse(atPath, keyList)
}
}
}
示例2: keys
const extractSchemaMetaData = (typeDefs: string) => {
if (!cache.schemaMetaData) {
const scalars = keys(scalarResolversMap)
const scalarsPresentInSchema = map(hasScalar(typeDefs), scalars)
cache.schemaMetaData = zipObj(scalars, scalarsPresentInSchema)
}
return cache.schemaMetaData
}
示例3: getImmutableModel
/**
* Return a immutable model
* @param model An object with key value pair
*/
static getImmutableModel(model) {
let newModel: any = { };
const getFields = R.keys();
const assignFields = field => newModel[field] = model[field];
const prepareModel = R.pipe(getFields, R.forEach(assignFields));
prepareModel(model);
return newModel;
}
示例4: init
export const initAll = (element: any): any => {
if (Array.isArray(element)) {
return init(element);
// Check for length of Object.keys, because Dates and null are objects too
} else if (typeof element === 'object' && keys(element).length > 0) {
return map(initAll, element);
}
return element;
};
示例5: constructor
constructor(operator$: Stream<string>) {
const xs = Stream;
operator$.addListener(dummyListener);
this.operator$ =
operator$
.map(operator => xs.of(operators[operator]))
.flatten();
this.operators$ =
xs.of(keys(operators)).remember();
}
示例6: getPidByPidCode
export function getPidByPidCode (pidstring: string) : PID|null {
let names:Array<string> = keys(PIDS);
let pidname:string = find((name:string) => {
let curpid:PID = PIDS[name];
return curpid.getPid() === pidstring;
})(names);
if (pidname) {
return PIDS[pidname];
} else {
return null;
}
};
示例7:
fields.forEach(field => {
if (!toFilter) {
if (R.is(Object, field)) {
const key = R.head(R.keys(field));
const value = R.values(field);
if (key === 'eq') {
toFilter = (obj[value] === query);
}
} else {
if (!R.isNil(obj[field])) {
toFilter = obj[field].toString()
.toLowerCase().indexOf(query) > -1
}
}
}
});
示例8: recordTimings
function recordTimings(start: [number, number], name: string, timings: Record<string, [number, number]>, middlewareMetrics: Record<string, [number, number]>) {
// Capture the total amount of time spent in this middleware
const end = process.hrtime(start)
timings[name] = end
const label = `middleware-${name}`
metrics.batch(label, end)
// This middleware has added it's own metrics
// Just add them to `timings` scoped by the middleware's name and batch them
const middlewareMetricsKeys: string[] = keys(middlewareMetrics) as string[]
if (middlewareMetricsKeys.length > 0) {
forEach((k: string) => {
const metricEnd = middlewareMetrics[k]
const metricName = `${label}-${k}`
timings[metricName] = metricEnd
metrics.batch(metricName, metricEnd)
}, middlewareMetricsKeys)
}
}
示例9: reduce
export const nativeTypeDefs = (metaData: SchemaMetaData) => reduce(
(acc, scalar) => !metaData[scalar] ? `${acc}\nscalar ${scalar}\n` : acc,
'',
keys(scalarResolversMap)
)
示例10:
export const process = (user: User): User => {
return Object.assign({ }, user, {
$tenants: R.keys(user.tenants),
});
}