本文整理汇总了TypeScript中@orbit/utils.isArray函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isArray函数的具体用法?TypeScript isArray怎么用?TypeScript isArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isArray函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: deepGet
Object.keys(replacement.relationships).forEach(field => {
let data = deepGet(replacement, ['relationships', field, 'data']);
if (data !== undefined) {
let currentData = deepGet(current, [
'relationships',
field,
'data'
]);
let relationshipChanged;
if (isArray(data)) {
if (currentData) {
relationshipChanged = !equalRecordIdentitySets(
currentData,
data
);
} else {
relationshipChanged = true;
currentData = [];
}
} else {
if (currentData) {
relationshipChanged = !equalRecordIdentities(currentData, data);
} else {
relationshipChanged = true;
currentData = null;
}
}
if (relationshipChanged) {
changed = true;
deepSet(result, ['relationships', field, 'data'], currentData);
}
}
});
示例2: buildTransform
export function buildTransform(transformOrOperations: TransformOrOperations, transformOptions?: object, transformId?: string, transformBuilder?: TransformBuilder): Transform {
if (typeof transformOrOperations === 'function') {
return buildTransform(transformOrOperations(transformBuilder), transformOptions, transformId);
} else {
let transform = transformOrOperations as Transform;
let operations: Operation[];
let options: object;
if (isObject(transform) && transform.operations) {
if (transform.id && !transformOptions && !transformId) {
return transform;
}
operations = transform.operations;
options = transformOptions || transform.options;
} else {
if (isArray(transformOrOperations)) {
operations = transformOrOperations as Operation[];
} else {
operations = [transformOrOperations as Operation];
}
options = transformOptions;
}
let id: string = transformId || Orbit.uuid();
return { operations, options, id };
}
}
示例3: patch
/**
* Patches the cache with an operation or operations.
*/
patch(
operationOrOperations:
| RecordOperation
| RecordOperation[]
| TransformBuilderFunc
): PatchResult {
if (typeof operationOrOperations === 'function') {
operationOrOperations = operationOrOperations(this._transformBuilder) as
| RecordOperation
| RecordOperation[];
}
const result: PatchResult = {
inverse: [],
data: []
};
if (isArray(operationOrOperations)) {
this._applyPatchOperations(
operationOrOperations as RecordOperation[],
result,
true
);
} else {
this._applyPatchOperation(
operationOrOperations as RecordOperation,
result,
true
);
}
result.inverse.reverse();
return result;
}
示例4: recordArrayFromData
export function recordArrayFromData(data: any): RecordIdentity[] {
if (isArray(data)) {
return data;
} else if (data) {
return [data];
} else {
return [];
}
}
示例5: deepSet
['filter', 'include', 'page', 'sort'].forEach(param => {
let value = (options as any)[param];
if (value) {
if (param === 'include' && isArray(value)) {
value = value.join(',');
}
deepSet(settings, ['params', param], value);
}
});
示例6: RecordIdentityMap
Object.keys(record.relationships).forEach(name => {
let rel = record.relationships[name];
if (rel.data !== undefined) {
if (isArray(rel.data)) {
let relMap = rels[name] = new RecordIdentityMap();
(rel.data as RecordIdentity[]).forEach(r => relMap.add(r));
} else {
rels[name] = rel.data;
}
}
});
示例7:
Object.keys(relationships).forEach(relationship => {
const relationshipData = relationships[relationship] && relationships[relationship].data;
if (relationshipData) {
if (isArray(relationshipData)) {
const relatedRecords = relationshipData as Record[];
relatedRecords.forEach(relatedRecord => {
this.remove(relatedRecord, { record, relationship })
});
} else {
const relatedRecord = relationshipData as Record;
this.remove(relatedRecord, { record, relationship })
}
}
});
示例8: deepGet
Object.keys(replacement.relationships).forEach(field => {
let currentValue = deepGet(current, ['relationships', field]);
let value = replacement.relationships[field];
let data = value && value.data;
let relationshipMatch;
if (isArray(data)) {
relationshipMatch = cache.relationships.relatedRecordsMatch(op.record, field, data as RecordIdentity[]);
} else {
relationshipMatch = eq(value, currentValue);
}
if (!relationshipMatch) {
changed = true;
deepSet(result, ['relationships', field], currentValue === undefined ? null : currentValue);
}
});
示例9: function
proto.sync = function(
transformOrTransforms: Transform | Transform[]
): Promise<void> {
if (isArray(transformOrTransforms)) {
const transforms = transformOrTransforms as Transform[];
return transforms.reduce((chain, transform) => {
return chain.then(() => this.sync(transform));
}, Promise.resolve());
} else {
const transform = transformOrTransforms as Transform;
if (this.transformLog.contains(transform.id)) {
return Promise.resolve();
}
return this._enqueueSync('sync', transform);
}
};
示例10:
Object.keys(relationships).forEach(relationship => {
const relationshipData =
relationships[relationship] && relationships[relationship].data;
if (relationshipData) {
if (isArray(relationshipData)) {
const relatedRecords = relationshipData as Record[];
relatedRecords.forEach(relatedRecord => {
inverseRelationships.push({
record: recordIdentity,
relationship,
relatedRecord
});
});
} else {
const relatedRecord = relationshipData as Record;
inverseRelationships.push({
record: recordIdentity,
relationship,
relatedRecord
});
}
}
});