react-cosmos
Version:
CLI for running React Cosmos inside webpack-powered apps
22 lines (18 loc) • 541 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.removeLeadingDot = removeLeadingDot;
exports.removeLeadingSlash = removeLeadingSlash;
exports.replaceKeys = replaceKeys;
function replaceKeys(str, map) {
return Object.keys(map).reduce(function (res, key) {
return res.replace(key, map[key]);
}, str);
}
function removeLeadingSlash(fromPath) {
return fromPath.replace(/^\/+/, '');
}
function removeLeadingDot(fromPath) {
return fromPath.indexOf('.') === 0 ? fromPath.slice(1) : fromPath;
}