aboutsummaryrefslogtreecommitdiff
path: root/node_modules/parse-filepath/index.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-03-27 21:01:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-03-27 21:01:33 +0100
commitcc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 (patch)
tree92c5d88706a6ffc654d1b133618d357890e7096b /node_modules/parse-filepath/index.js
parent3771b4d6b67b34c130f3a9a1a15f42deefdb2eda (diff)
remove node_modules
Diffstat (limited to 'node_modules/parse-filepath/index.js')
-rw-r--r--node_modules/parse-filepath/index.js95
1 files changed, 0 insertions, 95 deletions
diff --git a/node_modules/parse-filepath/index.js b/node_modules/parse-filepath/index.js
deleted file mode 100644
index 0df01700c..000000000
--- a/node_modules/parse-filepath/index.js
+++ /dev/null
@@ -1,95 +0,0 @@
-'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;
- }
- });
-
- define(obj, 'dirname', function() {
- return this.dir;
- });
- }
-
- obj.path = filepath;
-
- define(obj, 'absolute', function() {
- return path.resolve(this.path);
- });
-
- define(obj, 'isAbsolute', function() {
- return isAbsolute(this.path);
- });
-
- cache.set(filepath, obj);
- return obj;
-};
-
-function define(obj, prop, fn) {
- var cached;
- Object.defineProperty(obj, prop, {
- configurable: true,
- enumerable: true,
- set: function(val) {
- cached = val;
- },
- get: function() {
- return cached || (cached = fn.call(obj));
- }
- });
-}