rantjs 1.0.10 → 2.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/LICENSE +15 -0
- package/README.md +103 -117
- package/dist/cli.js +711 -0
- package/dist/index.cjs +762 -0
- package/dist/index.d.cts +72 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.js +754 -0
- package/dist/rant.js +679 -0
- package/dist/rant.min.js +6 -0
- package/package.json +56 -73
- package/.idea/compiler.xml +0 -22
- package/.idea/copyright/profiles_settings.xml +0 -3
- package/.idea/misc.xml +0 -14
- package/.idea/modules.xml +0 -8
- package/.idea/rantnpm.iml +0 -9
- package/.idea/workspace.xml +0 -441
- package/.npmignore +0 -1
- package/index.js +0 -83
- package/index.min.js +0 -949
- package/source/arrayMethods.js +0 -162
- package/source/core/braceParser.js +0 -60
- package/source/core/capitalize.js +0 -19
- package/source/core/en_US.js +0 -317
- package/source/core/getCase.js +0 -20
- package/source/core/lexer.js +0 -24
- package/source/core/randomString.js +0 -11
- package/source/core/replaceToken.js +0 -70
- package/source/core/sample_dic.js +0 -11
- package/source/dic/custom.js +0 -21
- package/source/dic/en_US.js +0 -326
- package/source/dic/tokens.js +0 -3
- package/source/extendFunction.js +0 -188
package/source/dic/tokens.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var dic={};
|
|
2
|
-
|
|
3
|
-
dic.tokens=["preposition","firstname","abstract", "activity", "adj", "adv", "color", "conj", "country", "emo", "em", "x", "face", "firstname", "greet", "surname", "noun", "sound", "title", "place", "prefix", "prepos", "pron", "quality", "rel", "sconj", "substance", "timeadv", "timenoun", "unit", "verbimg", "say", "verb", "vocal", "preposition", "yn", "insult"];
|
package/source/extendFunction.js
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* extendFunction.js - The easiest way to overwrite other functions with additional functionality
|
|
3
|
-
*
|
|
4
|
-
* github.com/devinrhode2/extendFunction.js
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2013 extendFunction.js contributors
|
|
7
|
-
* MIT Licensed
|
|
8
|
-
*/
|
|
9
|
-
(function(){
|
|
10
|
-
var window = this; // this === window in the browser, this === global in node.
|
|
11
|
-
var undefined;
|
|
12
|
-
|
|
13
|
-
function extendFunction(fnRef, addedFunctionality) {
|
|
14
|
-
// not doing 'use strict' because it changes what `this` means, and extendFunction
|
|
15
|
-
// should be as seamless as possible
|
|
16
|
-
// http://scriptogr.am/micmath/post/should-you-use-strict-in-your-production-javascript
|
|
17
|
-
// however, if a global 'use strict' is leaked, you can expect we just use the `this`
|
|
18
|
-
// keyword.. (I wish I could solve your bugs for you, but I can't here)
|
|
19
|
-
|
|
20
|
-
var originalFunction;
|
|
21
|
-
|
|
22
|
-
// type check like underscore/lodash.
|
|
23
|
-
// (..advanced: we could assume it's a function and correct ourselves if it's a string, but that's a little gnarly for a prime use case)
|
|
24
|
-
if (Object.prototype.toString.call(fnRef) == '[object String]') {
|
|
25
|
-
|
|
26
|
-
// Example: split 'jQuery.ajax' into ['jQuery', 'ajax']
|
|
27
|
-
var propertyArray = fnRef.split('.');
|
|
28
|
-
|
|
29
|
-
// start with the global object, and iteratively access each property,
|
|
30
|
-
// re-assigning to originalFunction each time
|
|
31
|
-
// For example, this dynamic code:
|
|
32
|
-
// originalFunction = window; originalFunction = originalFunction[prop]; originalFunction = originalFunction[nextProp]; ..
|
|
33
|
-
// Could ultimately boil down to this static code:
|
|
34
|
-
// originalFunction = window.$.fn.jQueryPluginFunction;
|
|
35
|
-
originalFunction = window;
|
|
36
|
-
|
|
37
|
-
// so while there are properties left to access..
|
|
38
|
-
while (propertyArray.length) {
|
|
39
|
-
try {
|
|
40
|
-
originalFunction = originalFunction[propertyArray.shift()];
|
|
41
|
-
|
|
42
|
-
// if originalFunction[propArray[0]] is undefined,
|
|
43
|
-
// then originalFunction[propArray[0]][propArray[1]] will throw because this is essentially doing window.undefined.undefined
|
|
44
|
-
} catch (cantReadPropOfUndefined) {
|
|
45
|
-
// And now we've caught that exception. originalFunction should still just === undefined (essentially like window.undefined aka originalFunction.notDefinedProperty)
|
|
46
|
-
if (originalFunction === undefined) {
|
|
47
|
-
// ...but don't we want to prevent having originalFunction.undefined in the first place?
|
|
48
|
-
// Nope, we just assume good input for efficiency, but catch the exception here when it happens.
|
|
49
|
-
return sendUncaughtExcepton(
|
|
50
|
-
new TypeError('window.' + fnRef + ' is undefined and therefore cannot be extended as a function.')
|
|
51
|
-
);
|
|
52
|
-
} else {
|
|
53
|
-
// ...who knows what happened!
|
|
54
|
-
return sendUncaughtExcepton(cantReadPropOfUndefined);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
// else fnRef is actually the originalFunction, or at least we'll assume so and catch the error if it isn't
|
|
60
|
-
originalFunction = fnRef;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
//originalFunction should now be a function. (If it isn't we'll catch that error specifically)
|
|
64
|
-
|
|
65
|
-
function extendedFunction() {
|
|
66
|
-
// TODO: write a test that verifies `this` refers to what it should refer too.
|
|
67
|
-
// For example, if you do extendFunction('$.ajax', function(){ this === window.$; });
|
|
68
|
-
var args = Array.prototype.slice.call(arguments);
|
|
69
|
-
|
|
70
|
-
// EXTEND originalFunction TO TRACK IF IT WAS CALLED
|
|
71
|
-
var wasOriginalCalled = false;
|
|
72
|
-
var untrackedOriginal = originalFunction;
|
|
73
|
-
originalFunction = function () {
|
|
74
|
-
wasOriginalCalled = true;
|
|
75
|
-
try {
|
|
76
|
-
// should we store this above and then use that variable? I don't know
|
|
77
|
-
return untrackedOriginal.apply(this, Array.prototype.slice.call(arguments));
|
|
78
|
-
// we use standard dynamic `arguments` instead of `args` because they are not necessarily always the same
|
|
79
|
-
// if a user modifies the arguments they call originalFunction with (extendFunction(function(args, originalFunction){ .. ) then we have to respect that
|
|
80
|
-
} catch (e) {
|
|
81
|
-
// above we assumed originalFunction was a function if it wasn't a string (for efficiency) - here, we catch and correct if it wasn't a function.
|
|
82
|
-
if (Object.prototype.toString.call(untrackedOriginal) != '[object Function]') {
|
|
83
|
-
// to throw or not to throw?
|
|
84
|
-
sendUncaughtExcepton(new TypeError([
|
|
85
|
-
fnRef + ' is not a function. ',
|
|
86
|
-
fnRef + '\'s toString is:' + untrackedOriginal,
|
|
87
|
-
'It\'s type is:' + typeof untrackedOriginal
|
|
88
|
-
].join('\n')));
|
|
89
|
-
}
|
|
90
|
-
return sendUncaughtExcepton(e); //always send browser provided error:
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// If the users additionalFunctionality function will call originalFunction asynchronously,
|
|
95
|
-
// they can tell us NOT to call it
|
|
96
|
-
function dontCallOriginal() {
|
|
97
|
-
wasOrignalCalled = true; // Original is going to be called, so we're just going to say it was already
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
var originalReturn;
|
|
101
|
-
var newReturn = addedFunctionality.call(this, args, originalFunction, dontCallOriginal);
|
|
102
|
-
if (!wasOriginalCalled) {
|
|
103
|
-
originalReturn = originalFunction.apply(this, args);
|
|
104
|
-
wasOriginalCalled = false; // reset in case a function dynamically calls the originalFunction (??)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return (newReturn === undefined ?
|
|
108
|
-
originalReturn
|
|
109
|
-
:
|
|
110
|
-
newReturn
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Copy properties over:
|
|
115
|
-
for (var prop in originalFunction) {
|
|
116
|
-
if (Object.prototype.hasOwnProperty.call(originalFunction, prop)) {
|
|
117
|
-
extendedFunction[prop] = originalFunction[prop];
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
//maintain/preserve prototype and constructor chains. Note: we're not actually creating a new class.
|
|
122
|
-
extendedFunction.prototype = originalFunction.prototype;
|
|
123
|
-
extendedFunction.constructor = originalFunction.constructor;
|
|
124
|
-
extendedFunction.name = originalFunction.name || 'httpBitLyDevinsFunctionNamingConvention';
|
|
125
|
-
// if check non-standard function properties:
|
|
126
|
-
if (typeof originalFunction.length !== 'undefined') { // if 0, then extendedFunction.length already === 0
|
|
127
|
-
extendedFunction.length = originalFunction.length; //extendedFunction doesn't list arguments!
|
|
128
|
-
}
|
|
129
|
-
if (originalFunction.__proto__) {
|
|
130
|
-
extendedFunction.__proto__ = originalFunction.__proto__;
|
|
131
|
-
}
|
|
132
|
-
if (propertyArray && propertyArray.length === 0) {
|
|
133
|
-
eval('(typeof window !== "undefined" ? window : global).' + fnRef + ' = ' + extendedFunction.toString());
|
|
134
|
-
} else {
|
|
135
|
-
return extendedFunction;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
// Export/define function just like lodash
|
|
141
|
-
|
|
142
|
-
/** Used to determine if values are of the language type Object */
|
|
143
|
-
var objectTypes = {
|
|
144
|
-
'function': true,
|
|
145
|
-
'object': true
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
/** Used as a reference to the global object */
|
|
149
|
-
var root = (objectTypes[typeof window] && window) || this;
|
|
150
|
-
|
|
151
|
-
/** Detect free variable `exports` */
|
|
152
|
-
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
|
|
153
|
-
|
|
154
|
-
/** Detect free variable `module` */
|
|
155
|
-
var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
|
|
156
|
-
|
|
157
|
-
/** Detect the popular CommonJS extension `module.exports` */
|
|
158
|
-
var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;
|
|
159
|
-
|
|
160
|
-
/** Detect free variable `global` from Node.js or Browserified code and use it as `root` */
|
|
161
|
-
var freeGlobal = objectTypes[typeof global] && global;
|
|
162
|
-
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
|
163
|
-
root = freeGlobal;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// some AMD build optimizers like r.js check for condition patterns like the following:
|
|
167
|
-
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
|
|
168
|
-
// define as a named module like jQuery and underscore.js
|
|
169
|
-
define("extendFunction", [], function () {
|
|
170
|
-
return extendFunction;
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
// check for `exports` after `define` in case a build optimizer adds an `exports` object
|
|
174
|
-
else if (freeExports && freeModule) {
|
|
175
|
-
// in Node.js or RingoJS
|
|
176
|
-
if (moduleExports) {
|
|
177
|
-
freeModule.exports = extendFunction;
|
|
178
|
-
}
|
|
179
|
-
// in Narwhal or Rhino -require
|
|
180
|
-
else {
|
|
181
|
-
freeExports.extendFunction = extendFunction;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
// in a browser or Rhino
|
|
186
|
-
root.extendFunction = extendFunction;
|
|
187
|
-
}
|
|
188
|
-
}).call(this);
|