-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
72 lines (58 loc) · 1.55 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* node-name
* https://github.com/helpers/node-name
* Copyright (c) 2013 Jon Schlinkert
* Licensed under the MIT license.
*/
// Node.js
var path = require('path');
// node_modules
var chalk = require('chalk');
var _ = require('lodash');
// This module.
var name = require('./index');
var arr = [
'.foo.bar/baz.quux',
'.foo.bar/baz.quux.',
'.html',
'/foo.bar.baz.quux',
'/foo/bar/baz/asdf/quux',
'/foo/bar/baz/asdf/quux.html',
'/foo/bar/baz/quux',
'/quux',
'/quux/',
'foo.bar.baz.quux',
'foo.bar/baz.quux',
'foo/bar.baz.quux',
'foo/bar.baz.quux/',
'foo/bar.baz/quux',
'foo/bar/baz.quux',
'foo/bar/baz.quux.',
'foo/bar/baz/quux',
'foo/bar/baz/quux/',
'quux/',
];
function logger(fn, name) {
name = name || 'name';
console.log(name.bold + ':\n' + arr.map(function (item) {
return ('>> ' + name + ': ').yellow + item + ' =>\t'.green + fn(item);
}).join('\n') + '\n');
}
function loggerObj(fn, name) {
name = name || 'name';
console.log(name.bold + ':\n' + arr.map(function (item) {
return ('>> ' + name + ': ').yellow + item + ' =>\t\n'.green + JSON.stringify(fn(item), null, 2);
}).join('\n') + '\n');
}
logger(path.basename, 'basename');
logger(path.dirname, 'dirname');
logger(path.extname, 'extname');
logger(name.base, 'base');
logger(name.basename, 'basename');
logger(name.dir, 'dir');
logger(name.ext, 'ext');
logger(name.first, 'first');
logger(name.file, 'file');
logger(name.filename, 'filename');
logger(name.fullname, 'fullname');
loggerObj(name.splitPath, 'splitPath');