{"version":3,"file":"index.cjs.development.cjs","sources":["../src/path-env.ts","../src/types.ts","../src/index.ts"],"sourcesContent":["import { delimiter as _pathDelimiter } from 'path'\n\nimport { IEnvFactory, IEnv, IPathArray, IPathDelimiter, IPathFactory, IPathString } from './types'\n\nexport function _delimiter()\n{\n\treturn _pathDelimiter as IPathDelimiter;\n}\n\nexport function _split(str: IPathString, delim = _pathDelimiter as IPathDelimiter): IPathArray\n{\n\treturn str.split(delim);\n}\n\nexport function _join(array: IPathArray, delim = _pathDelimiter as IPathDelimiter): IPathString\n{\n\treturn array.join(delim);\n}\n\nexport function _pathString(str: IPathString, delim?: IPathDelimiter)\n{\n\treturn _pathArray(_split(str, delim), delim)\n}\n\nexport function _pathArray(array: IPathArray, delim = _pathDelimiter as IPathDelimiter): IPathFactory\n{\n\tconst append = (addend: IPathArray) =>\n\t\t_pathArray(array.concat(...addend), delim)\n\n\tconst prepend = (addend: IPathArray) =>\n\t\t_pathArray(addend.concat(...array), delim)\n\n\tconst surround = (addend: IPathArray) =>\n\t\t_pathArray(addend.concat(...array).concat(...addend), delim)\n\n\tconst deduplicate = () =>\n\t\t_pathArray(Array.from(new Set(array)), delim)\n\n\treturn {\n\t\tget: {\n\t\t\tarray: () => array,\n\t\t\tstring: () => _join(array, delim),\n\t\t\tdelim: () => delim,\n\t\t},\n\t\tset: {\n\t\t\tarray: (x: IPathArray) => _pathArray(x, delim),\n\t\t\tstring: (x: IPathString) => _pathString(x, delim),\n\t\t\tdelim: (x: IPathDelimiter) => _pathArray(array, x),\n\t\t},\n\t\tappend,\n\t\tprepend,\n\t\tsurround,\n\t\tdeduplicate,\n\t}\n}\n\nexport function _pathEnv(env: IEnv, name = 'PATH', delim = _pathDelimiter as IPathDelimiter): IEnvFactory\n{\n\tconst { [name]: str = '', ...restEnv } = env\n\tconst factory = _pathString(str, delim)\n\n\tfunction main(\n\t\tfactory: IPathFactory,\n\t\tname: string,\n\t\tdelim: IPathDelimiter,\n\t): IEnvFactory\n\t{\n\t\tconst replaceFactory = (x: IPathFactory) => main(x, name, x.get.delim())\n\n\t\treturn {\n\t\t\tget: {\n\t\t\t\tpath: {\n\t\t\t\t\tname: () => name,\n\t\t\t\t\tfactory: () => factory,\n\t\t\t\t},\n\t\t\t\tenv: () => ({\n\t\t\t\t\t[name]: factory.get.string(),\n\t\t\t\t\t...restEnv,\n\t\t\t\t}),\n\t\t\t\trest: () => restEnv,\n\t\t\t},\n\t\t\tset: {\n\t\t\t\tfactory: replaceFactory,\n\t\t\t\tname: (x: string) => main(factory, x, delim),\n\t\t\t\tdelim: (x: IPathDelimiter) => main(factory, name, x),\n\t\t\t},\n\t\t\tpath: {\n\t\t\t\tget: {\n\t\t\t\t\t...factory.get,\n\t\t\t\t\tfactory: () => factory,\n\t\t\t\t\tname: () => name,\n\t\t\t\t},\n\t\t\t\tset: {\n\t\t\t\t\tfactory: replaceFactory,\n\t\t\t\t\tstring: (x: IPathString) => main(factory.set.string(x), name, delim),\n\t\t\t\t\tarray: (x: IPathArray) => main(factory.set.array(x), name, delim),\n\t\t\t\t\tdelim: (x: IPathDelimiter) => main(factory.set.delim(x), name, x),\n\t\t\t\t\tname: (x: string) => main(factory, x, delim),\n\t\t\t\t},\n\t\t\t\tappend: (addend: IPathArray) =>\n\t\t\t\t\treplaceFactory(factory.append(addend)),\n\t\t\t\tprepend: (addend: IPathArray) =>\n\t\t\t\t\treplaceFactory(factory.prepend(addend)),\n\t\t\t\tsurround: (addend: IPathArray) =>\n\t\t\t\t\treplaceFactory(factory.surround(addend)),\n\t\t\t\tdeduplicate: () =>\n\t\t\t\t\treplaceFactory(factory.deduplicate()),\n\t\t\t},\n\t\t}\n\t}\n\n\treturn main(factory, name, delim)\n}\n","import { ITSTypeAndStringLiteral } from 'ts-type/lib/helper/string';\n\nexport const enum EnumPathDelimiter\n{\n  poxix = ':',\n  win32 = ';',\n}\n\nexport type IPathDelimiter = ITSTypeAndStringLiteral<EnumPathDelimiter>\nexport type IPathElement = string\nexport type IPathArray = ReadonlyArray<IPathElement>\nexport type IPathString = IPathElement\n\nexport interface IEnv\n{\n  readonly [name: string]: string | undefined\n}\n\nexport interface IPathFactory\n{\n  get: {\n    array(): IPathArray,\n    string(): IPathString,\n    delim(): IPathDelimiter\n  },\n  set: {\n    array(x: IPathArray): IPathFactory,\n    string(x: IPathString): IPathFactory,\n    delim(x: IPathDelimiter): IPathFactory\n  },\n\n  append(x: IPathArray): IPathFactory,\n\n  prepend(x: IPathArray): IPathFactory,\n\n  surround(x: IPathArray): IPathFactory,\n\n  deduplicate(): IPathFactory\n}\n\nexport interface IEnvFactory\n{\n  get: {\n    path: {\n      name(): string,\n      factory(): IPathFactory\n    },\n    env(): IEnv,\n    rest(): IEnv\n  },\n  set: {\n    factory(x: IPathFactory): IEnvFactory,\n    name(x: string): IEnvFactory,\n    delim(x: IPathDelimiter): IEnvFactory\n  },\n  path: {\n    get: {\n      factory(): IPathFactory,\n      string(): IPathString,\n      array(): IPathArray,\n      delim(): IPathDelimiter,\n      name(): string\n    },\n    set: {\n      factory(x: IPathFactory): IEnvFactory,\n      string(x: IPathString): IEnvFactory,\n      array(x: IPathArray): IEnvFactory,\n      delim(x: IPathDelimiter): IEnvFactory,\n      name(x: string): IEnvFactory\n    },\n    append(addend: IPathArray): IEnvFactory,\n    prepend(addend: IPathArray): IEnvFactory,\n    surround(addend: IPathArray): IEnvFactory,\n    deduplicate(): IEnvFactory\n  }\n}\n","import { env } from 'process'\nexport * from './path-env'\nexport * from './types'\nimport { IEnv, IPathDelimiter } from './types';\nimport { _pathEnv, _pathString } from './path-env';\n\nexport function pathString(str = env['PATH'] || '', delim?: IPathDelimiter) {\n\treturn _pathString(str, delim);\n}\n\nexport function pathEnv(envObject: IEnv = env,\n\tname?: string,\n\tdelim?: IPathDelimiter,\n)\n{\n\treturn _pathEnv(envObject, name, delim);\n}\n\nexport default pathEnv\n"],"names":["_delimiter","_pathDelimiter","_split","str","delim","split","_join","array","join","_pathString","_pathArray","append","addend","concat","prepend","surround","deduplicate","Array","from","Set","get","string","set","x","_pathEnv","env","name","restEnv","factory","main","replaceFactory","path","rest","EnumPathDelimiter","pathString","pathEnv","envObject"],"mappings":";;;;;;;SAIgBA,aAAU;AAEzB,EAAA,OAAOC,cAAP,CAAA;AACA,CAAA;SAEeC,OAAOC,KAAkBC,QAAQH,gBAAgC;AAEhF,EAAA,OAAOE,GAAG,CAACE,KAAJ,CAAUD,KAAV,CAAP,CAAA;AACA,CAAA;SAEeE,MAAMC,OAAmBH,QAAQH,gBAAgC;AAEhF,EAAA,OAAOM,KAAK,CAACC,IAAN,CAAWJ,KAAX,CAAP,CAAA;AACA,CAAA;AAEe,SAAAK,WAAA,CAAYN,GAAZ,EAA8BC,KAA9B,EAAoD;EAEnE,OAAOM,UAAU,CAACR,MAAM,CAACC,GAAD,EAAMC,KAAN,CAAP,EAAqBA,KAArB,CAAjB,CAAA;AACA,CAAA;SAEeM,WAAWH,OAAmBH,QAAQH,gBAAgC;AAErF,EAAA,MAAMU,MAAM,GAAIC,MAAD,IACdF,UAAU,CAACH,KAAK,CAACM,MAAN,CAAa,GAAGD,MAAhB,CAAD,EAA0BR,KAA1B,CADX,CAAA;;AAGA,EAAA,MAAMU,OAAO,GAAIF,MAAD,IACfF,UAAU,CAACE,MAAM,CAACC,MAAP,CAAc,GAAGN,KAAjB,CAAD,EAA0BH,KAA1B,CADX,CAAA;;EAGA,MAAMW,QAAQ,GAAIH,MAAD,IAChBF,UAAU,CAACE,MAAM,CAACC,MAAP,CAAc,GAAGN,KAAjB,CAAA,CAAwBM,MAAxB,CAA+B,GAAGD,MAAlC,CAAD,EAA4CR,KAA5C,CADX,CAAA;;AAGA,EAAA,MAAMY,WAAW,GAAG,MACnBN,UAAU,CAACO,KAAK,CAACC,IAAN,CAAW,IAAIC,GAAJ,CAAQZ,KAAR,CAAX,CAAD,EAA6BH,KAA7B,CADX,CAAA;;EAGA,OAAO;AACNgB,IAAAA,GAAG,EAAE;MACJb,KAAK,EAAE,MAAMA,KADT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