{"version":3,"sources":["../../src/collection/dict.ts"],"names":["Dict","obj","keyOrPath","defaultValue","getByPath","value","options","setByPath","hasKey"],"mappings":";;;;AAkBaA,IAAAA,CAAAA,CAAN,KAAgE,CAEnE,WAAA,CAAYC,EAAS,CACjB,IAAA,CAAK,OAAUA,CAAAA,CAAAA,EAAQ,GAC3B,CACA,GAAIC,CAAAA,CAAAA,CAAmBC,EAAyB,CAC5C,OAAOC,EAAU,IAAK,CAAA,OAAA,CAASF,CAAW,CAAA,CAAE,YAAcC,CAAAA,CAAa,CAAC,CAC5E,CACA,IAAID,CAAmBG,CAAAA,CAAAA,CAAYC,EAA4B,CAC3DC,GAAAA,CAAU,IAAK,CAAA,OAAA,CAASL,CAAWG,CAAAA,CAAAA,CAAOC,CAAO,EACrD,CACA,GAAIJ,CAAAA,CAAAA,CAA4B,CAC5B,OAAOM,IAAO,IAAK,CAAA,OAAA,CAASN,CAAS,CACzC,CACJ","file":"dict.mjs","sourcesContent":["import { getByPath } from '../object/getByPath'\nimport { setByPath, type SetByPathOptions } from '../object/setByPath'\nimport { hasKey } from '../object/hasKey'\n\n/**\n *\n * 一个字典对象，用于存储键值对并提供便捷的访问方法\n *\n *  let dict = new Dict({a:1,b:2})\n *  dict.get('a') // 1\n *  dict.set(\"a\",2)\n *  dict.set('a.b',3)\n *\n *\n */\n\nexport interface DictOptions {}\n\nexport class Dict<T extends Record<string, any> = Record<string, any>> {\n    private _values: T\n    constructor(obj?: T) {\n        this._values = obj || ({} as T)\n    }\n    get(keyOrPath: string, defaultValue?: any): any {\n        return getByPath(this._values, keyOrPath, { defaultValue: defaultValue })\n    }\n    set(keyOrPath: string, value: any, options?: SetByPathOptions) {\n        setByPath(this._values, keyOrPath, value, options)\n    }\n    has(keyOrPath: string): boolean {\n        return hasKey(this._values, keyOrPath)\n    }\n}\n"]}