Acme.BookStore.HttpApi.Host/node_modules/parse-filepath/index.js
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
'use strict';
var path = require('path');
var isAbsolute = require('is-absolute');
var pathRoot = require('path-root');
var MapCache = require('map-cache');
var cache = new MapCache();
module.exports = function(filepath) {
if (typeof filepath !== 'string') {
throw new TypeError('parse-filepath expects a string');
}
if (cache.has(filepath)) {
return cache.get(filepath);
}
var obj = {};
if (typeof path.parse === 'function') {
obj = path.parse(filepath);
obj.extname = obj.ext;
obj.basename = obj.base;
obj.dirname = obj.dir;
obj.stem = obj.name;
} else {
define(obj, 'root', function() {
return pathRoot(this.path);
});
define(obj, 'extname', function() {
return path.extname(filepath);
});
define(obj, 'ext', function() {
return this.extname;
});
define(obj, 'name', function() {
return path.basename(filepath, this.ext);
});
define(obj, 'stem', function() {
return this.name;
});
define(obj, 'base', function() {
return this.name + this.ext;
});
define(obj, 'basename', function() {
return this.base;
});
define(obj, 'dir', function() {
var dir = path.dirname(filepath);
if (dir === '.') {
return (filepath[0] === '.') ? dir : '';
} else {
return dir;
后面还有 35 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
