{"version":3,"file":"index.umd.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":";;;;;;UAIgBA,aAAU;CAEzB,EAAA,OAAOC,cAAP,CAAA;CACA,CAAA;UAEeC,OAAOC,KAAkBC,QAAQH,gBAAgC;CAEhF,EAAA,OAAOE,GAAG,CAACE,KAAJ,CAAUD,KAAV,CAAP,CAAA;CACA,CAAA;UAEeE,MAAMC,OAAmBH,QAAQH,gBAAgC;CAEhF,EAAA,OAAOM,KAAK,CAACC,IAAN,CAAWJ,KAAX,CAAP,CAAA;CACA,CAAA;CAEe,SAAAK,WAAA,CAAYN,GAAZ,EAA8BC,KAA9B,EAAoD;GAEnE,OAAOM,UAAU,CAACR,MAAM,CAACC,GAAD,EAAMC,KAAN,CAAP,EAAqBA,KAArB,CAAjB,CAAA;CACA,CAAA;UAEeM,WAAWH,OAAmBH,QAAQH,gBAAgC;CAErF,EAAA,MAAMU,MAAM,GAAIC,MAAD,IACdF,UAAU,CAACH,KAAK,CAACM,MAAN,CAAa,GAAGD,MAAhB,CAAD,EAA0BR,KAA1B,CADX,CAAA;;CAGA,EAAA,MAAMU,OAAO,GAAIF,MAAD,IACfF,UAAU,CAACE,MAAM,CAACC,MAAP,CAAc,GAAGN,KAAjB,CAAD,EAA0BH,KAA1B,CADX,CAAA;;GAGA,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;;CAGA,EAAA,MAAMY,WAAW,GAAG,MACnBN,UAAU,CAACO,KAAK,CAACC,IAAN,CAAW,IAAIC,GAAJ,CAAQZ,KAAR,CAAX,CAAD,EAA6BH,KAA7B,CADX,CAAA;;GAGA,OAAO;CACNgB,IAAAA,GAAG,EAAE;OACJb,KAAK,EAAE,MAAMA,KADT;C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