本文整理汇总了TypeScript中Immutable.Set类的典型用法代码示例。如果您正苦于以下问题:TypeScript Set类的具体用法?TypeScript Set怎么用?TypeScript Set使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Set类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: doFilter
doFilter(keys: Set<string>): boolean {
if (this._filter.size > 0) {
if (!keys) {
return this._filter.contains(NONE_FILTER_KEY);
} else {
if (this._filter.size === 1 && this._filter.contains(NONE_FILTER_KEY)) {
// All we want to match is no components, and we have some components so return that we
// should be filtered out
return false;
}
for (const key of this._filterArray) {
if (key === NONE_FILTER_KEY) {
// We have values and we are looking for some values, for this case ignore the
// none filter
continue;
}
if (keys.contains(key)) {
return true;
}
}
return false;
}
}
return true;
}
示例2: it
it('can compose Immutable::Set initial states', () => {
const state = compose(Set.of(1, 2, 3), Set.of(4, 5, 6), Set.of());
expect(Set.isSet(state)).to.be.true;
const plain = state.toJS();
expect(plain).not.to.be.null;
expect(plain).to.deep.equal([1, 2, 3, 4, 5, 6]);
});
示例3: it
it('expresses value equality with set sequences', () => {
var s1 = Set.of('A', 'B', 'C');
expect(s1.equals(null)).toBe(false);
var s2 = Set.of('C', 'B', 'A');
expect(s1 === s2).toBe(false);
expect(is(s1, s2)).toBe(true);
expect(s1.equals(s2)).toBe(true);
// Map and Set are not the same (keyed vs unkeyed)
var v1 = Map({ A: 'A', C: 'C', B: 'B' });
expect(is(s1, v1)).toBe(false);
});
示例4: partialNameRefiner
function partialNameRefiner(previousParamValue: Set<string>, currentParamValue: Set<string>) {
var lowerCurrParam = currentParamValue.map((param) => param.toLowerCase()).toSet();
var lowerPrevParam = previousParamValue.map((param) => param.toLowerCase()).toSet();
function partialNameComponentRefiner(curr:string):boolean {
return lowerPrevParam.contains(curr)
|| lowerPrevParam.some((prevParam) => prevParam.includes(curr));
}
return lowerCurrParam
.every((currParam) => partialNameComponentRefiner(currParam));
}
示例5: buildParamValues
buildParamValues(fragments: Set<string>):Map<string, any> {
var paramValues = Map<string,any>();
var idFragment = fragments.find((fragment) => !!fragment.match(/\d+/));
if (idFragment) {
paramValues = paramValues.set('id', Number.parseInt(idFragment));
}
var nameFragments = fragments
.filter((fragment) => !!fragment.match(/\D+/))
.map((fragment) => fragment.toLowerCase())
.toSet();
paramValues = paramValues.set('name', nameFragments);
return paramValues;
}
示例6: Set
export const findEntries = (context: Context) => {
const { trace } = context
let entries = Set() as Set<string>
let modulesToExplore = Set.of(...trace.keys())
while (modulesToExplore.size > 0) {
// pick a node and add it to entries
const node = modulesToExplore.first()
modulesToExplore = modulesToExplore.remove(node)
entries = entries.add(node)
const removeDepsOf = (dep) => {
modulesToExplore = modulesToExplore.remove(dep)
if (trace.has(dep))
getDependencies(context, dep)
.forEach(depToRemove => {
if (entries.has(depToRemove)) entries = entries.remove(depToRemove)
else if (modulesToExplore.has(depToRemove)) removeDepsOf(depToRemove)
})
}
removeDepsOf(node)
}
return entries.toJS()
.filter(entry => !entry.includes('jspm_packages'))
}