本文整理汇总了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,
});
});
示例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],
],
},
}),
});
});
示例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],
],
},
}),
});
});
示例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,
});
});
示例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);
}
示例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],
],
},
}),
});
});
示例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
}
示例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,
}),
},
);
});
示例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']);
}
示例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;
}
}