本文整理匯總了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
});
}
}
});