本文整理汇总了TypeScript中lodash.omit函数的典型用法代码示例。如果您正苦于以下问题:TypeScript omit函数的具体用法?TypeScript omit怎么用?TypeScript omit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了omit函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('properly normalizes a nested object with arguments but without an ID', () => {
const fragment = gql`
fragment Item on ItemType {
id,
stringField,
numberField,
nullField,
nestedObj(arg: "val") {
stringField,
numberField,
nullField
}
}
`;
const result = {
id: 'abcd',
stringField: 'This is a string!',
numberField: 5,
nullField: null,
nestedObj: {
stringField: 'This is a string too!',
numberField: 6,
nullField: null,
},
};
assert.deepEqual(writeFragmentToStore({
fragment,
result: _.cloneDeep(result),
}), {
[result.id]: _.assign({}, _.assign({}, _.omit(result, 'nestedObj')), {
'nestedObj({"arg":"val"})': `${result.id}.nestedObj({"arg":"val"})`,
}),
[`${result.id}.nestedObj({"arg":"val"})`]: result.nestedObj,
});
});
开发者ID:JohnWelle,项目名称:apollo-client,代码行数:37,代码来源:writeToStore.ts
示例2: it
it('properly normalizes an array of non-objects with null', () => {
const query = gql`
{
id,
stringField,
numberField,
nullField,
simpleArray
}
`;
const result: any = {
id: 'abcd',
stringField: 'This is a string!',
numberField: 5,
nullField: null,
simpleArray: [null, 'two', 'three'],
};
const normalized = writeQueryToStore({
query,
result: _.cloneDeep(result),
});
assert.deepEqual(normalized, {
'ROOT_QUERY': _.assign({}, _.assign({}, _.omit(result, 'simpleArray')), {
simpleArray: {
type: 'json',
json: [
result.simpleArray[0],
result.simpleArray[1],
result.simpleArray[2],
],
},
}),
});
});
开发者ID:drager,项目名称:apollo-client,代码行数:37,代码来源:writeToStore.ts
示例3: it
it('properly normalizes an array of non-objects with null', () => {
const query = gql`
{
id
stringField
numberField
nullField
simpleArray
}
`;
const result: any = {
id: 'abcd',
stringField: 'This is a string!',
numberField: 5,
nullField: null,
simpleArray: [null, 'two', 'three'],
};
const normalized = writeQueryToStore({
query,
result: cloneDeep(result),
});
expect(normalized.toObject()).toEqual({
ROOT_QUERY: assign<{}>({}, assign({}, omit(result, 'simpleArray')), {
simpleArray: {
type: 'json',
json: [
result.simpleArray[0],
result.simpleArray[1],
result.simpleArray[2],
],
},
}),
});
});
开发者ID:dotansimha,项目名称:apollo-client,代码行数:37,代码来源:writeToStore.ts
示例4: it
it('properly normalizes a nested object without an ID', () => {
const fragment = `
fragment Item on ItemType {
id,
stringField,
numberField,
nullField,
nestedObj {
stringField,
numberField,
nullField
}
}
`;
const result = {
id: 'abcd',
stringField: 'This is a string!',
numberField: 5,
nullField: null,
nestedObj: {
stringField: 'This is a string too!',
numberField: 6,
nullField: null,
},
};
assertEqualSansDataId(writeFragmentToStore({
fragment,
result: _.cloneDeep(result),
}), {
[result.id]: _.assign({}, _.assign({}, _.omit(result, 'nestedObj')), {
nestedObj: `${result.id}.nestedObj`,
}),
[`${result.id}.nestedObj`]: result.nestedObj,
});
});
开发者ID:johnthepink,项目名称:apollo-client,代码行数:37,代码来源:writeToStore.ts
示例5: create
public async create(space: Space) {
if (this.useRbac()) {
this.debugLogger(`SpacesClient.create(), using RBAC. Checking if authorized globally`);
await this.ensureAuthorizedGlobally(
this.authorization.actions.space.manage,
'create',
'Unauthorized to create spaces'
);
this.debugLogger(`SpacesClient.create(), using RBAC. Global authorization check succeeded`);
}
const repository = this.useRbac()
? this.internalSavedObjectRepository
: this.callWithRequestSavedObjectRepository;
const { total } = await repository.find({
type: 'space',
page: 1,
perPage: 0,
});
if (total >= this.config.get('xpack.spaces.maxSpaces')) {
throw Boom.badRequest(
'Unable to create Space, this exceeds the maximum number of spaces set by the xpack.spaces.maxSpaces setting'
);
}
this.debugLogger(`SpacesClient.create(), using RBAC. Attempting to create space`);
const attributes = omit(space, ['id', '_reserved']);
const id = space.id;
const createdSavedObject = await repository.create('space', attributes, { id });
this.debugLogger(`SpacesClient.create(), created space object`);
return this.transformSavedObjectToSpace(createdSavedObject);
}
开发者ID:,项目名称:,代码行数:37,代码来源:
示例6: it
it('properly normalizes an array of non-objects with null', () => {
const fragment = gql`
fragment Item on ItemType {
id,
stringField,
numberField,
nullField,
simpleArray
}
`;
const result = {
id: 'abcd',
stringField: 'This is a string!',
numberField: 5,
nullField: null,
simpleArray: [null, 'two', 'three'],
};
const normalized = writeFragmentToStore({
fragment,
result: _.cloneDeep(result),
});
assert.deepEqual(normalized, {
[result.id]: _.assign({}, _.assign({}, _.omit(result, 'simpleArray')), {
simpleArray: {
type: 'json',
json: [
result.simpleArray[0],
result.simpleArray[1],
result.simpleArray[2],
],
},
}),
});
});
开发者ID:gitter-badger,项目名称:apollo-client,代码行数:37,代码来源:writeToStore.ts
示例7: createSettingsTransactionWithoutMemos
function createSettingsTransactionWithoutMemos(
account: string, settings: Settings
): any {
if (settings.regularKey !== undefined) {
const removeRegularKey = {
TransactionType: 'SetRegularKey',
Account: account
}
if (settings.regularKey === null) {
return removeRegularKey
}
return _.assign({}, removeRegularKey, {RegularKey: settings.regularKey})
}
if (settings.signers !== undefined) {
return {
TransactionType: 'SignerListSet',
Account: account,
SignerQuorum: settings.signers.threshold,
SignerEntries: _.map(settings.signers.weights, formatSignerEntry)
}
}
const txJSON: any = {
TransactionType: 'AccountSet',
Account: account
}
setTransactionFlags(txJSON, _.omit(settings, 'memos'))
setTransactionFields(txJSON, settings)
if (txJSON.TransferRate !== undefined) {
txJSON.TransferRate = convertTransferRate(txJSON.TransferRate)
}
return txJSON
}
开发者ID:ledgerd,项目名称:ledgerd-lib,代码行数:36,代码来源:settings.ts
示例8: it
it('properly normalizes a nested object that returns null', () => {
const query = gql`
{
id
stringField
numberField
nullField
nestedObj {
id
stringField
numberField
nullField
}
}
`;
const result: any = {
id: 'abcd',
stringField: 'This is a string!',
numberField: 5,
nullField: null,
nestedObj: null,
};
assert.deepEqual<NormalizedCache>(
writeQueryToStore({
query,
result: cloneDeep(result),
}),
{
ROOT_QUERY: assign({}, assign({}, omit(result, 'nestedObj')), {
nestedObj: null,
}),
},
);
});
开发者ID:hammadj,项目名称:apollo-client,代码行数:36,代码来源:writeToStore.ts
示例9: getBeatWithToken
public async getBeatWithToken(
user: FrameworkUser,
enrollmentToken: string
): Promise<CMBeat | null> {
const params = {
ignore: [404],
index: INDEX_NAMES.BEATS,
type: '_doc',
body: {
query: {
match: { 'beat.enrollment_token': enrollmentToken },
},
},
};
const response = await this.database.search(user, params);
const beats = _get<CMBeat[]>(response, 'hits.hits', []);
if (beats.length === 0) {
return null;
}
return omit<CMBeat, {}>(_get<CMBeat>(beats[0], '_source.beat'), ['access_token']);
}
开发者ID:liuyepiaoxiang,项目名称:kibana,代码行数:24,代码来源:elasticsearch_beats_adapter.ts
示例10: semColors
function semColors(state: ColorMapping = defaultSemColorMap, action: FSA): ColorMapping {
const moduleCode = get(action, 'payload.moduleCode');
if (!moduleCode) return state;
switch (action.type) {
case ADD_MODULE:
return {
...state,
[moduleCode]: getNewColor(values(state)),
};
case REMOVE_MODULE:
return omit(state, moduleCode);
case SELECT_MODULE_COLOR:
return {
...state,
[moduleCode]: action.payload.colorIndex,
};
default:
return state;
}
}
开发者ID:nusmodifications,项目名称:nusmods,代码行数:24,代码来源:timetables.ts
注:本文中的lodash.omit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论