本文整理汇总了TypeScript中lodash.differenceWith函数的典型用法代码示例。如果您正苦于以下问题:TypeScript differenceWith函数的具体用法?TypeScript differenceWith怎么用?TypeScript differenceWith使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了differenceWith函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1:
return this.service.unreportedForms().do(result => {
// 删除已添加的申请
result.forms = _.differenceWith(
result.forms,
this.options.report.items,
(form: any, item: any) => form.formId === item.formId,
);
});
开发者ID:Gitjerryzhong,项目名称:bell-tm-static,代码行数:8,代码来源:form-select.dialog.ts
示例2: resolve
]).then(([userVirtualStudies, allCancerStudies])=>{
// return virtual studies from given cancer study ids
const missingFromCancerStudies = _.differenceWith(cancerStudyIds, allCancerStudies,(id:string, study:CancerStudy)=>id==study.studyId);
const virtualStudies = userVirtualStudies.filter(
(virtualStudy: VirtualStudy) => (missingFromCancerStudies.includes(virtualStudy.id))
);
resolve(virtualStudies);
}).catch(()=>{
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:8,代码来源:ResultsViewPageHelpers.ts
示例3: getOpponents
function getOpponents(creator, opponents) {
let members = opponents.concat(creator);
let user = getUser.call(this);
members = _.differenceWith(members, [{
username: user.username,
userId: user._id
}], _.isEqual);
return members;
}
开发者ID:Puzochacha,项目名称:rhy,代码行数:10,代码来源:game.ts
示例4: sweetHotFilter
@test('getAllProducts with flavor filter: sweet>2 spicy>2')
public async sweetHotFilter() {
await updateProduct(1, {
metadata: {
flavor: { sweet: 5, sour: 5, bitter: 5, salty: 5, spicy: 5 }
},
tags: []
});
let allResults = await getAllProducts();
let sweetHotResults = await getAllProducts({
filter: {
flavor: [
{ flavorName: 'spicy', type: 'greater-than', level: 2 },
{ flavorName: 'sweet', type: 'greater-than', level: 2 }
]
}
});
assert.isAbove(
sweetHotResults.length,
0,
'Nonzezro number of sweetHotResults'
);
assert.isBelow(
sweetHotResults.length,
allResults.length,
'Sweet-hot products are a subset of all products'
);
assert.ok(
sweetHotResults.every(
p =>
p.metadata &&
p.metadata.flavor &&
p.metadata.flavor.sweet > 2 &&
p.metadata.flavor.spicy > 2
),
'All results from sweet-hot filter have sweet > 2 and spicy > 2'
);
assert.ok(
differenceWith(
allResults,
sweetHotResults,
(a: any, b: any) => a.id === b.id
).every(
p =>
!p.metadata ||
p.metadata.flavor.sweet <= 2 ||
p.metadata.flavor.spicy <= 2
),
'All results excluded by sweet-hot filter have sweet <= 2 OR spicy <= 2'
);
}
开发者ID:qjac,项目名称:sql-fundamentals,代码行数:52,代码来源:ex14.product.metadata.test.ts
示例5: sweetSourFilter
@test('getAllProducts with flavor filter: sweet>2 sour>2')
public async sweetSourFilter() {
let allResults = await getAllProducts();
let sweetSourResults = await getAllProducts({
filter: {
flavor: [
{ flavorName: 'sour', type: 'greater-than', level: 2 },
{ flavorName: 'sweet', type: 'greater-than', level: 2 }
]
}
});
assert.isBelow(
sweetSourResults.length,
allResults.length,
'Sweet-sour products are a subset of all products'
);
assert.ok(
sweetSourResults.every(
p =>
p &&
p.metadata &&
p.metadata.flavor &&
p.metadata.flavor.sweet > 2 &&
p.metadata.flavor.sour > 2
),
'All results from sweet-sour filter have sweet > 2 and sour > 2'
);
assert.ok(
differenceWith(
allResults,
sweetSourResults,
(a: any, b: any) => a.id === b.id
).every(
p =>
!p ||
!p.metadata ||
!p.metadata.flavor ||
(p.metadata.flavor.sweet <= 2 || p.metadata.flavor.sour <= 2)
),
'All results excluded by sweet-sour filter have sweet <= 2 OR sour <= 2'
);
}
开发者ID:qjac,项目名称:sql-fundamentals,代码行数:42,代码来源:ex14.product.metadata.test.ts
示例6: capitalize
//.........这里部分代码省略.........
selfAmbiguousRelations.length > 0 && selfRemoteColumns && selfRemoteColumns.length > 0
return {
name: this.removeIdSuffix(relation.source_column),
type: capitalize(relation.target_table),
isReadOnly: false,
isRequired: false,
isId: false,
isUnique: false,
defaultValue: null,
isList: false,
relatedField: null, // TODO: Find and link related field, if possible.
relationName: isAmbigous ? camelCase(relationName) : null,
directives
} as IGQLField
})
const relationTables = joinTables.reduce((relations, joinTable) => {
if (joinTable.relations.some(relation => relation.target_table === tc.name)) {
return relations.concat(joinTable.relations.filter(relation => relation.target_table !== tc.name))
} else {
return relations
}
}, [] as TableRelation[])
const relations = tc.relations.filter(relation => {
return relation.target_table === tc.name &&
// Join tables are rendered seperately.
!joinTables.some(x => x.name === relation.target_table)
})
const relationFields = relations.map(relation => {
const ambiguousRelations = tc.relations.filter(innerRelation => innerRelation.source_table === relation.source_table && innerRelation.target_table === relation.target_table)
const fieldName = ambiguousRelations.length > 1
? plural(relation.source_table) + '_' + plural(
this.removeIdSuffix(relation.source_column)
)
: plural(relation.source_table)
const selfAmbiguousRelations = ambiguousRelations.filter(relation => relation.source_table === relation.target_table)
const isAmbigous = ambiguousRelations.length > 1 || selfAmbiguousRelations.length > 0
return {
name: fieldName,
type: capitalize(relation.source_table),
isRequired: true,
isReadOnly: false,
isId: false,
isList: true,
isUnique: false,
defaultValue: null,
relatedField: null, // TODO
relationName: isAmbigous ? camelCase(fieldName) : null
} as IGQLField
})
const relationTableFields = relationTables.map(relation => {
const directives: IDirectiveInfo[] = [{
name: "pgRelationTable",
arguments: {
table: `"${relation.source_table}`,
name: `"${relation.source_table}`
}
}]
// TODO Include directives
return {
name: plural(relation.target_table),
isList: true,
isRequired: true,
isId: false,
isUnique: false,
defaultValue: null,
relatedField: null, // Is this correct?
relationName: null,
isReadOnly: false,
type: capitalize(relation.target_table)
} as IGQLField
})
const allFields = [
...(_.differenceWith(fields, inlineRelationFields, (a, b) => {
return this.removeIdSuffix(a.name) === this.removeIdSuffix(b.name)
})),
...inlineRelationFields,
...relationFields,
...relationTableFields
]
// TODO: If has zero valid fields, don't render.
return {
name: name,
fields: allFields,
isEmbedded: false,
isEnum: false,
directives: directives
} as IGQLType
})
开发者ID:dhruvcodeword,项目名称:prisma,代码行数:101,代码来源:postgresIntrospectionResult.ts
示例7: availableTypes
get availableTypes() {
return _.differenceWith(this.types.filter(it => it.isTeaching === this.department.isTeaching),
this.auths.filter(it => it.departmentId === this.department.id),
(a: any, b: any) => a.id === b.typeId);
}
开发者ID:Gitjerryzhong,项目名称:bell-tm-static,代码行数:5,代码来源:booking-auth.component.ts
示例8: GQLField
//.........这里部分代码省略.........
const ambiguousRelations = tc.relations.filter(innerRelation => innerRelation.source_table === relation.source_table && innerRelation.target_table === relation.target_table)
const remoteColumns = _.intersectionWith(
tc.columns,
ambiguousRelations,
(a, b) => a.name === b.source_column
)
const selfAmbiguousRelations = ambiguousRelations.filter(relation => relation.source_table === relation.target_table)
const selfRemoteColumns = _.intersectionWith(
tc.columns,
selfAmbiguousRelations,
(a, b) => a.name === b.source_column
)
const relationName = pluralize(relation.source_table) + '_' + pluralize(this.removeIdSuffix(relation.source_column))
const directives = [
`@pgRelation(column: "${relation.source_column}")`,
...(ambiguousRelations.length > 1 && remoteColumns && remoteColumns.length > 0 ? [`@relation(name: "${upperCamelCase(relationName)}")`] : []),
...(selfAmbiguousRelations.length > 0 && selfRemoteColumns && selfRemoteColumns.length > 0 ? [`@relation(name: "${upperCamelCase(relationName)}")`] : [])
]
return new GQLField(
this.removeIdSuffix(relation.source_column),
`${this.capitalizeFirstLetter(relation.target_table)}`,
false,
directives,
false,
"", // TODO: Figure out comment thing for this
false
)
})
const relations = tc.relations.filter(relation => {
return relation.target_table === tc.name
})
const relationFields = relations.map(relation => {
const ambiguousRelations = tc.relations.filter(innerRelation => innerRelation.source_table === relation.source_table && innerRelation.target_table === relation.target_table)
const fieldName = ambiguousRelations.length > 1
? pluralize(relation.source_table) + '_' + pluralize(
this.removeIdSuffix(relation.source_column)
)
: pluralize(relation.source_table)
const selfAmbiguousRelations = ambiguousRelations.filter(relation => relation.source_table === relation.target_table)
const directives = [
...(ambiguousRelations.length > 1 ? [`@relation(name: "${upperCamelCase(fieldName)}")`] : []),
...(selfAmbiguousRelations.length > 0 ? [`@relation(name: "${upperCamelCase(fieldName)}")`] : [])
]
return new GQLField(
fieldName,
`[${this.capitalizeFirstLetter(relation.source_table)}!]`,
true,
directives,
false,
"", // TODO: Figure out comment thing for this
false
)
})
const relationTables = joinTables.reduce((relations, joinTable) => {
if (joinTable.relations.some(relation => relation.target_table === tc.name)) {
return relations.concat(joinTable.relations.filter(relation => relation.target_table !== tc.name))
} else {
return relations
}
}, [] as TableRelation[])
const relationTableFields = relationTables.map(relation => {
const directives = [
`@pgRelationTable(table: "${relation.source_table}" name: "${relation.source_table}")`
]
return new GQLField(
pluralize(relation.target_table),
`[${this.capitalizeFirstLetter(relation.target_table)}!]`,
true,
directives,
false,
"", // TODO: Figure out comment thing for this
false
)
})
const allFields = [
...(_.differenceWith(fields, inlineRelationFields, (a, b) => {
return this.removeIdSuffix(a.name) === this.removeIdSuffix(b.name)
})),
...inlineRelationFields,
...(_.differenceWith(relationFields, relationTableFields, (a, b) => {
// TODO: Manage this ugly hack if finding relation field in
// directive of relation table field
// there is also plural to singular hack in this
return b.directives.join('').indexOf(pluralize.singular(a.name)) > -1
})),
...relationTableFields
]
const someValidFields = fields.some(field => field.isValid())
return new GQLType(name, allFields, directives, !someValidFields)
})
开发者ID:nunsie,项目名称:prisma,代码行数:101,代码来源:SDLInferrer.ts
注:本文中的lodash.differenceWith函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论