@jaredwray/fumanchu 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -16
- package/dist/index.d.ts +26 -0
- package/dist/index.js +2073 -0
- package/package.json +14 -20
- package/helpers.js +0 -61
- package/index.d.ts +0 -4
- package/index.js +0 -8
- package/index.mjs +0 -16
- package/lib/array.js +0 -822
- package/lib/code.js +0 -80
- package/lib/collection.js +0 -67
- package/lib/comparison.js +0 -604
- package/lib/date.js +0 -24
- package/lib/fs.js +0 -75
- package/lib/html.js +0 -218
- package/lib/i18n.js +0 -48
- package/lib/index.js +0 -24
- package/lib/inflection.js +0 -78
- package/lib/logging.js +0 -8
- package/lib/markdown.js +0 -99
- package/lib/match.js +0 -61
- package/lib/math.js +0 -285
- package/lib/md.js +0 -119
- package/lib/misc.js +0 -77
- package/lib/number.js +0 -204
- package/lib/object.js +0 -290
- package/lib/path.js +0 -181
- package/lib/regex.js +0 -50
- package/lib/string.js +0 -769
- package/lib/url.js +0 -132
- package/lib/utils/falsey.js +0 -46
- package/lib/utils/html.js +0 -82
- package/lib/utils/index.js +0 -91
- package/lib/utils/utils.js +0 -42
package/lib/url.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var url = require('url');
|
|
4
|
-
var util = require('handlebars-utils');
|
|
5
|
-
var querystring = require('querystring');
|
|
6
|
-
var helpers = module.exports;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Encodes a Uniform Resource Identifier (URI) component
|
|
10
|
-
* by replacing each instance of certain characters by
|
|
11
|
-
* one, two, three, or four escape sequences representing
|
|
12
|
-
* the UTF-8 encoding of the character.
|
|
13
|
-
*
|
|
14
|
-
* @param {String} `str` The un-encoded string
|
|
15
|
-
* @return {String} The endcoded string
|
|
16
|
-
* @api public
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
helpers.encodeURI = function(str) {
|
|
20
|
-
if (util.isString(str)) {
|
|
21
|
-
return encodeURIComponent(str);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Escape the given string by replacing characters with escape sequences.
|
|
27
|
-
* Useful for allowing the string to be used in a URL, etc.
|
|
28
|
-
*
|
|
29
|
-
* @param {String} `str`
|
|
30
|
-
* @return {String} Escaped string.
|
|
31
|
-
* @api public
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
helpers.escape = function(str) {
|
|
35
|
-
if (util.isString(str)) {
|
|
36
|
-
return querystring.escape(str);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Decode a Uniform Resource Identifier (URI) component.
|
|
42
|
-
*
|
|
43
|
-
* @param {String} `str`
|
|
44
|
-
* @return {String}
|
|
45
|
-
* @api public
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
helpers.decodeURI = function(str) {
|
|
49
|
-
if (util.isString(str)) {
|
|
50
|
-
return decodeURIComponent(str);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Alias for [encodeURI](#encodeuri).
|
|
56
|
-
* @api public
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
helpers.url_encode = function() {
|
|
60
|
-
return helpers.encodeURI.apply(this, arguments);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Alias for [decodeURI](#decodeuri).
|
|
65
|
-
* @api public
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
helpers.url_decode = function(val) {
|
|
69
|
-
return helpers.decodeURI.apply(this, arguments);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Take a base URL, and a href URL, and resolve them as a
|
|
74
|
-
* browser would for an anchor tag.
|
|
75
|
-
*
|
|
76
|
-
* @param {String} `base`
|
|
77
|
-
* @param {String} `href`
|
|
78
|
-
* @return {String}
|
|
79
|
-
* @api public
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
helpers.urlResolve = function(base, href) {
|
|
83
|
-
return url.resolve(base, href);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Parses a `url` string into an object.
|
|
88
|
-
*
|
|
89
|
-
* @param {String} `str` URL string
|
|
90
|
-
* @return {String} Returns stringified JSON
|
|
91
|
-
* @api public
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
helpers.urlParse = function(str) {
|
|
95
|
-
return url.parse(str);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Strip the query string from the given `url`.
|
|
100
|
-
*
|
|
101
|
-
* @param {String} `url`
|
|
102
|
-
* @return {String} the url without the queryString
|
|
103
|
-
* @api public
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
helpers.stripQuerystring = function(str) {
|
|
107
|
-
if (util.isString(str)) {
|
|
108
|
-
return str.split('?')[0];
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Strip protocol from a `url`. Useful for displaying media that
|
|
114
|
-
* may have an 'http' protocol on secure connections.
|
|
115
|
-
*
|
|
116
|
-
* ```handlebars
|
|
117
|
-
* <!-- url = 'http://foo.bar' -->
|
|
118
|
-
* {{stripProtocol url}}
|
|
119
|
-
* <!-- results in: '//foo.bar' -->
|
|
120
|
-
* ```
|
|
121
|
-
* @param {String} `str`
|
|
122
|
-
* @return {String} the url with http protocol stripped
|
|
123
|
-
* @api public
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
helpers.stripProtocol = function(str) {
|
|
127
|
-
if (util.isString(str)) {
|
|
128
|
-
var parsed = url.parse(str);
|
|
129
|
-
parsed.protocol = '';
|
|
130
|
-
return parsed.format();
|
|
131
|
-
}
|
|
132
|
-
};
|
package/lib/utils/falsey.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// utils.js
|
|
2
|
-
function falsey(val, keywords) {
|
|
3
|
-
if (!val) {
|
|
4
|
-
return true;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
let words = keywords || [
|
|
8
|
-
"0",
|
|
9
|
-
"false",
|
|
10
|
-
"nada",
|
|
11
|
-
"nil",
|
|
12
|
-
"nay",
|
|
13
|
-
"nah",
|
|
14
|
-
"negative",
|
|
15
|
-
"no",
|
|
16
|
-
"none",
|
|
17
|
-
"nope",
|
|
18
|
-
"nul",
|
|
19
|
-
"null",
|
|
20
|
-
"nix",
|
|
21
|
-
"nyet",
|
|
22
|
-
"uh-uh",
|
|
23
|
-
"veto",
|
|
24
|
-
"zero",
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
if (!Array.isArray(words)) {
|
|
28
|
-
words = [words];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const lower = typeof val === "string" ? val.toLowerCase() : null;
|
|
32
|
-
|
|
33
|
-
for (const word of words) {
|
|
34
|
-
if (word === val) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
if (word === lower) {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
module.exports = falsey;
|
|
46
|
-
|
package/lib/utils/html.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var util = require('handlebars-utils');
|
|
4
|
-
var striptags = require('striptags');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Expose `utils`
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var html = module.exports;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Remove extra newlines from HTML, respect indentation.
|
|
14
|
-
*
|
|
15
|
-
* @param {String} html
|
|
16
|
-
* @return {String}
|
|
17
|
-
* @api public
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
html.condense = function(str) {
|
|
21
|
-
return str.replace(/(\r\n|\r|\n|\u2028|\u2029) {2,}/g, '\n');
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Add a single newline above code comments in HTML
|
|
26
|
-
*
|
|
27
|
-
* @param {String} `html`
|
|
28
|
-
* @return {String}
|
|
29
|
-
* @api public
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
html.padcomments = function(str) {
|
|
33
|
-
return str.replace(/(\s*<!--)/g, '\n$1');
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Parse HTML tag attributes from the `options.hash`.
|
|
38
|
-
*
|
|
39
|
-
* @param {Object} `hash` Helper options hash, e.g. `{foo: 'bar'}`
|
|
40
|
-
* @return {String} Stringified attributes, e.g. `foo="bar"`
|
|
41
|
-
* @api public
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
html.parseAttributes = function parseAttributes(hash) {
|
|
45
|
-
return Object.keys(hash).map(function(key) {
|
|
46
|
-
var val = String(hash[key]).replace(/^['"]|["']$/g, '');
|
|
47
|
-
return key + '="' + val + '"';
|
|
48
|
-
}).join(' ');
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Strip HTML tags from a string, so that only the text nodes
|
|
53
|
-
* are preserved.
|
|
54
|
-
*
|
|
55
|
-
* ```handlebars
|
|
56
|
-
* {{sanitize "<span>foo</span>"}}
|
|
57
|
-
* //=> 'foo'
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* @param {String} `str` The string of HTML to sanitize.
|
|
61
|
-
* @return {String}
|
|
62
|
-
* @api public
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
html.sanitize = function(str) {
|
|
66
|
-
if (!util.isString(str)) return '';
|
|
67
|
-
return striptags(str).trim();
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
html.toAttributes = function toAttributes(hash) {
|
|
71
|
-
var res = '';
|
|
72
|
-
var keys = Object.keys(hash);
|
|
73
|
-
for (var i = 0; i < keys.length; i++) {
|
|
74
|
-
var val = hash[keys[i]];
|
|
75
|
-
if (val === true) {
|
|
76
|
-
res += ' ' + keys[i];
|
|
77
|
-
} else {
|
|
78
|
-
res += ' ' + keys[i] + '="' + String(val) + '"';
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return res;
|
|
82
|
-
};
|
package/lib/utils/index.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var util = require('handlebars-utils');
|
|
4
|
-
var utils = require('./utils');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Returns true if the given value contains the given
|
|
8
|
-
* `object`, optionally passing a starting index.
|
|
9
|
-
*
|
|
10
|
-
* @param {Array} val
|
|
11
|
-
* @param {Object} obj
|
|
12
|
-
* @param {Number} start
|
|
13
|
-
* @return {Boolean}
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
utils.contains = function(val, obj, start) {
|
|
17
|
-
if (val == null || obj == null || !utils.isNumber(val.length)) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
return val.indexOf(obj, start) !== -1;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Remove leading and trailing whitespace and non-word
|
|
25
|
-
* characters from the given string.
|
|
26
|
-
*
|
|
27
|
-
* @param {String} `str`
|
|
28
|
-
* @return {String}
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
utils.chop = function(str) {
|
|
32
|
-
if (!util.isString(str)) return '';
|
|
33
|
-
var re = /^[-_.\W\s]+|[-_.\W\s]+$/g;
|
|
34
|
-
if(str.length > 1000) {
|
|
35
|
-
throw new Error('utils.chop() regex is too long!');
|
|
36
|
-
}
|
|
37
|
-
return str.trim().replace(re, '');
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Change casing on the given `string`, optionally
|
|
42
|
-
* passing a delimiter to use between words in the
|
|
43
|
-
* returned string.
|
|
44
|
-
*
|
|
45
|
-
* ```handlebars
|
|
46
|
-
* utils.changecase('fooBarBaz');
|
|
47
|
-
* //=> 'foo bar baz'
|
|
48
|
-
*
|
|
49
|
-
* utils.changecase('fooBarBaz' '-');
|
|
50
|
-
* //=> 'foo-bar-baz'
|
|
51
|
-
* ```
|
|
52
|
-
* @param {String} `string` The string to change.
|
|
53
|
-
* @return {String}
|
|
54
|
-
* @api public
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
utils.changecase = function(str, fn) {
|
|
58
|
-
if (!util.isString(str)) return '';
|
|
59
|
-
if (str.length === 1) {
|
|
60
|
-
return str.toLowerCase();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
str = utils.chop(str).toLowerCase();
|
|
64
|
-
if (typeof fn !== 'function') {
|
|
65
|
-
fn = utils.identity;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
var re = /[-_.\W\s]+(\w|$)/g;
|
|
69
|
-
return str.replace(re, function(_, ch) {
|
|
70
|
-
return fn(ch);
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Generate a random number
|
|
76
|
-
*
|
|
77
|
-
* @param {Number} `min`
|
|
78
|
-
* @param {Number} `max`
|
|
79
|
-
* @return {Number}
|
|
80
|
-
* @api public
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
utils.random = function(min, max) {
|
|
84
|
-
return min + Math.floor(Math.random() * (max - min + 1));
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Expose `utils`
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
module.exports = utils;
|
package/lib/utils/utils.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var utils = require('lazy-cache')(require);
|
|
4
|
-
var falsey = require('./falsey');
|
|
5
|
-
var fn = require;
|
|
6
|
-
require = utils;
|
|
7
|
-
|
|
8
|
-
// Array utils
|
|
9
|
-
require('array-sort', 'sortBy');
|
|
10
|
-
require('arr-flatten', 'flatten');
|
|
11
|
-
|
|
12
|
-
// Html utils
|
|
13
|
-
require('to-gfm-code-block', 'block');
|
|
14
|
-
require('html-tag', 'tag');
|
|
15
|
-
|
|
16
|
-
// JavaScript language utils
|
|
17
|
-
require('kind-of', 'typeOf');
|
|
18
|
-
|
|
19
|
-
// matching utils
|
|
20
|
-
require('is-glob');
|
|
21
|
-
require('micromatch', 'mm');
|
|
22
|
-
utils.falsey = falsey;
|
|
23
|
-
|
|
24
|
-
// Number utils
|
|
25
|
-
require('is-even');
|
|
26
|
-
require('is-number');
|
|
27
|
-
|
|
28
|
-
// Object utils
|
|
29
|
-
require('create-frame');
|
|
30
|
-
require('get-object');
|
|
31
|
-
require('get-value', 'get');
|
|
32
|
-
require('for-own');
|
|
33
|
-
|
|
34
|
-
// Path utils
|
|
35
|
-
require('relative');
|
|
36
|
-
require = fn;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Expose `utils`
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
module.exports = utils;
|