extract-base-iterator
Version:
Base iterator for extract iterators like tar-iterator and zip-iterator
1 lines • 1.07 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":["stripPath","relativePath","options","strip","parts","compact","split","path","sep","length","Error","slice","join"],"mappings":";;;;+BAGA;;;eAAwBA;;;2DAHP;oEACG;;;;;;AAEL,SAASA,UAAUC,YAAY,EAAEC,OAAO;IACrD,IAAMC,QAAQD,QAAQC,KAAK,IAAI;IAC/B,IAAI,CAACA,OAAO,OAAOF;IACnB,IAAMG,QAAQC,IAAAA,sBAAO,EAACJ,aAAaK,KAAK,CAACC,aAAI,CAACC,GAAG;IACjD,IAAIJ,MAAMK,MAAM,GAAGN,OAAO,MAAM,IAAIO,MAAM,AAAC,mEAAkFT,OAAhBE,OAAM,YAAuB,OAAbF;IAC7H,OAAOG,MAAMO,KAAK,CAACR,OAAOS,IAAI,CAACL,aAAI,CAACC,GAAG;AACzC"}