UNPKG

@smooai/utils

Version:

A collection of shared utilities and tools used across SmooAI projects. This package provides common functionality to standardize and simplify development across all SmooAI repositories.

1 lines 1.78 kB
{"version":3,"file":"CaseInsensitiveSet.mjs","names":[],"sources":["../../src/collections/CaseInsensitiveSet.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- ok */\n// https://stackoverflow.com/questions/50019920/javascript-map-key-value-pairs-case-insensitive-search\nexport class CaseInsensitiveSet<T> extends Set<T> {\n constructor(values?: Iterable<T>) {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- this is a valid use case\n values\n ? super(\n Array.from(values, (key) => {\n if (typeof key === 'string') {\n key = key.toLowerCase() as any as T;\n }\n\n return key;\n }),\n )\n : super();\n }\n\n add(key: T) {\n if (typeof key === 'string') {\n key = key.toLowerCase() as any as T;\n }\n\n return super.add(key);\n }\n\n has(key: T) {\n if (typeof key === 'string') {\n key = key.toLowerCase() as any as T;\n }\n\n return super.has(key);\n }\n\n delete(key: T) {\n if (typeof key === 'string') {\n key = key.toLowerCase() as any as T;\n }\n\n return super.delete(key);\n }\n}\n"],"mappings":";AAEA,IAAa,qBAAb,cAA2C,IAAO;CAC9C,YAAY,QAAsB;EAE9B,SACM,MACI,MAAM,KAAK,SAAS,QAAQ;GACxB,IAAI,OAAO,QAAQ,UACf,MAAM,IAAI,YAAY;GAG1B,OAAO;EACX,CAAC,CACL,IACA,MAAM;CAChB;CAEA,IAAI,KAAQ;EACR,IAAI,OAAO,QAAQ,UACf,MAAM,IAAI,YAAY;EAG1B,OAAO,MAAM,IAAI,GAAG;CACxB;CAEA,IAAI,KAAQ;EACR,IAAI,OAAO,QAAQ,UACf,MAAM,IAAI,YAAY;EAG1B,OAAO,MAAM,IAAI,GAAG;CACxB;CAEA,OAAO,KAAQ;EACX,IAAI,OAAO,QAAQ,UACf,MAAM,IAAI,YAAY;EAG1B,OAAO,MAAM,OAAO,GAAG;CAC3B;AACJ"}