extract-base-iterator
Version:
Base iterator for extract iterators like tar-iterator and zip-iterator
1 lines • 1.06 kB
Source Map (JSON)
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/stripPath.mjs"],"sourcesContent":["import path from 'path';\nimport compact from 'lodash.compact';\n\nexport default function stripPath(relativePath, options) {\n const strip = options.strip || 0;\n if (!strip) return relativePath;\n const parts = compact(relativePath.split(path.sep));\n if (parts.length < strip) throw new Error(`You cannot strip more levels than there are directories. Strip: ${strip}. Path: ${relativePath}`);\n return parts.slice(strip).join(path.sep);\n}\n"],"names":["path","compact","stripPath","relativePath","options","strip","parts","split","sep","length","Error","slice","join"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,aAAa,iBAAiB;AAErC,eAAe,SAASC,UAAUC,YAAY,EAAEC,OAAO;IACrD,MAAMC,QAAQD,QAAQC,KAAK,IAAI;IAC/B,IAAI,CAACA,OAAO,OAAOF;IACnB,MAAMG,QAAQL,QAAQE,aAAaI,KAAK,CAACP,KAAKQ,GAAG;IACjD,IAAIF,MAAMG,MAAM,GAAGJ,OAAO,MAAM,IAAIK,MAAM,CAAC,gEAAgE,EAAEL,MAAM,QAAQ,EAAEF,cAAc;IAC3I,OAAOG,MAAMK,KAAK,CAACN,OAAOO,IAAI,CAACZ,KAAKQ,GAAG;AACzC"}