Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 12ded73

Browse files
committed
refactor: better duplication error message
1 parent 49b92b5 commit 12ded73

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎src/model/snippet.fn.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ export const createXSnippets = <T extends XSnippetDict>(input: T): T => input;
3333
export const mapToVscSnippetDicMeta = (metas: XSnippetDictMeta[], label: string): VscSnippetDictMeta[] =>
3434
metas.map(meta => {
3535
const entries = Object.entries(meta.dict);
36-
if (entries.length !== new Set(entries.map(([, { name }]) => name)).size)
36+
const names = new Set<string>();
37+
const dup = entries.filter(([, { name }]) => names.has(name) || !names.add(name));
38+
if (dup.length) {
39+
console.log(`Found duplicated name in ${meta.filename}: `, dup);
3740
throw Error(`Found duplicated name in ${meta.filename}`);
41+
}
3842

3943
return {
4044
...meta,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /