extension 0.2.0 → 1.1.1
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 +18 -17
- package/README.md +80 -135
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +16 -0
- package/dist/module.d.ts +1 -0
- package/dist/module.js +28 -0
- package/package.json +40 -15
- package/.npmignore +0 -2
- package/lib/array.js +0 -77
- package/lib/extension.js +0 -122
- package/lib/object.js +0 -60
- package/lib/string.js +0 -102
- package/test/array.js +0 -118
- package/test/extension.js +0 -239
- package/test/object.js +0 -160
- package/test/string.js +0 -228
package/test/string.js
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
var expect = require('chai').expect;
|
|
2
|
-
var strext = require('../lib/string');
|
|
3
|
-
|
|
4
|
-
describe('string', function() {
|
|
5
|
-
describe('#contains', function() {
|
|
6
|
-
it('should return false if passed a null or undefined string argument', function(done) {
|
|
7
|
-
expect(strext.contains(null)).to.be.false;
|
|
8
|
-
expect(strext.contains(undefined)).to.be.false;
|
|
9
|
-
done();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('should return false if not passed a string', function(done) {
|
|
13
|
-
expect(strext.contains([1, 2, 3])).to.be.false;
|
|
14
|
-
done();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should detect a substring at the beginning of the source string', function(done) {
|
|
18
|
-
expect(strext.contains('hola', 'ho')).to.be.true;
|
|
19
|
-
expect(strext.contains('hola', 'Ho')).to.be.false;
|
|
20
|
-
done();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should detect a substring at the beginning of the source string while ignoring case', function(done) {
|
|
24
|
-
expect(strext.contains('hola', 'Ho', { ignoreCase: true })).to.be.true;
|
|
25
|
-
expect(strext.contains('hola', 'ho', { ignoreCase: true })).to.be.true;
|
|
26
|
-
done();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should detect a substring at the end of the source string', function(done) {
|
|
30
|
-
expect(strext.contains('hola', 'la')).to.be.true;
|
|
31
|
-
expect(strext.contains('hola', 'lA')).to.be.false;
|
|
32
|
-
done();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should detect a substring at the end of the source string while ignoring case', function(done) {
|
|
36
|
-
expect(strext.contains('hola', 'lA', { ignoreCase: true })).to.be.true;
|
|
37
|
-
expect(strext.contains('hola', 'la', { ignoreCase: true })).to.be.true;
|
|
38
|
-
done();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should detect a substring somewhere in the middle of the source string', function(done) {
|
|
42
|
-
expect(strext.contains('hola', 'ol')).to.be.true;
|
|
43
|
-
expect(strext.contains('hola', 'oL')).to.be.false;
|
|
44
|
-
done();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should detect a substring somewhere in the middle of the source string while ignoring case', function(done) {
|
|
48
|
-
expect(strext.contains('hola', 'oL', { ignoreCase: true })).to.be.true;
|
|
49
|
-
expect(strext.contains('hola', 'ol', { ignoreCase: true })).to.be.true;
|
|
50
|
-
done();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should be callable with or without a source string', function(done) {
|
|
54
|
-
var source = 'hola';
|
|
55
|
-
expect(strext.contains(source, 'ho')).to.be.true;
|
|
56
|
-
expect(strext.contains(source, 'Ho', { ignoreCase: true })).to.be.true;
|
|
57
|
-
expect(strext.contains.call(source, 'ho')).to.be.true;
|
|
58
|
-
expect(strext.contains.call(source, 'Ho', { ignoreCase: true })).to.be.true;
|
|
59
|
-
done();
|
|
60
|
-
});
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
describe('#startsWith', function() {
|
|
64
|
-
it('should return false if passed a null or undefined string argument', function(done) {
|
|
65
|
-
expect(strext.startsWith(null)).to.be.false;
|
|
66
|
-
expect(strext.startsWith(undefined)).to.be.false;
|
|
67
|
-
done();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should return false if not passed a string', function(done) {
|
|
71
|
-
expect(strext.startsWith([1, 2, 3])).to.be.false;
|
|
72
|
-
done();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should detect a substring at the beginning of the source string', function(done) {
|
|
76
|
-
expect(strext.startsWith('hola', 'ho')).to.be.true;
|
|
77
|
-
expect(strext.startsWith('hola', 'ol')).to.be.false;
|
|
78
|
-
expect(strext.startsWith('hola', 'Ho')).to.be.false;
|
|
79
|
-
done();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('should detect a substring at the beginning of the source string while ignoring case', function(done) {
|
|
83
|
-
expect(strext.startsWith('hola', 'ho', { ignoreCase: true })).to.be.true;
|
|
84
|
-
expect(strext.startsWith('hola', 'ol', { ignoreCase: true })).to.be.false;
|
|
85
|
-
expect(strext.startsWith('hola', 'Ho', { ignoreCase: true })).to.be.true;
|
|
86
|
-
done();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should be callable with or without a source string', function(done) {
|
|
90
|
-
var source = 'hola';
|
|
91
|
-
expect(strext.startsWith(source, 'ho')).to.be.true;
|
|
92
|
-
expect(strext.startsWith(source, 'Ho', { ignoreCase: true })).to.be.true;
|
|
93
|
-
expect(strext.startsWith(source, 'ol')).to.be.false;
|
|
94
|
-
expect(strext.startsWith.call(source, 'ho')).to.be.true;
|
|
95
|
-
expect(strext.startsWith.call(source, 'Ho', { ignoreCase: true })).to.be.true;
|
|
96
|
-
expect(strext.startsWith.call(source, 'ol')).to.be.false;
|
|
97
|
-
done();
|
|
98
|
-
});
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
describe('#endsWith', function() {
|
|
102
|
-
it('should return false if passed a null or undefined string argument', function(done) {
|
|
103
|
-
expect(strext.endsWith(null)).to.be.false;
|
|
104
|
-
expect(strext.endsWith(undefined)).to.be.false;
|
|
105
|
-
done();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('should return false if not passed a string', function(done) {
|
|
109
|
-
expect(strext.endsWith([1, 2, 3])).to.be.false;
|
|
110
|
-
done();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('should return true if passed a string with multiple matches', function(done) {
|
|
114
|
-
expect(strext.endsWith('test test', 'test')).to.be.true;
|
|
115
|
-
done();
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
it('should detect a substring at the end of the source string', function(done) {
|
|
119
|
-
expect(strext.endsWith('hola', 'la')).to.be.true;
|
|
120
|
-
expect(strext.endsWith('hola', 'ol')).to.be.false;
|
|
121
|
-
expect(strext.endsWith('hola', 'LA')).to.be.false;
|
|
122
|
-
done();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('should detect a substring at the end of the source string while ignoring case', function(done) {
|
|
126
|
-
expect(strext.endsWith('hola', 'la', { ignoreCase: true })).to.be.true;
|
|
127
|
-
expect(strext.endsWith('hola', 'ol', { ignoreCase: true })).to.be.false;
|
|
128
|
-
expect(strext.endsWith('hola', 'La', { ignoreCase: true })).to.be.true;
|
|
129
|
-
done();
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('should be callable with or without a source string', function(done) {
|
|
133
|
-
var source = 'hola';
|
|
134
|
-
expect(strext.endsWith(source, 'la')).to.be.true;
|
|
135
|
-
expect(strext.endsWith(source, 'lA', { ignoreCase: true })).to.be.true;
|
|
136
|
-
expect(strext.endsWith(source, 'lA')).to.be.false;
|
|
137
|
-
expect(strext.endsWith.call(source, 'la')).to.be.true;
|
|
138
|
-
expect(strext.endsWith.call(source, 'lA', { ignoreCase: true })).to.be.true;
|
|
139
|
-
expect(strext.endsWith.call(source, 'lA')).to.be.false;
|
|
140
|
-
done();
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
describe('#capitalize', function() {
|
|
145
|
-
it('should return null if passed a null', function(done) {
|
|
146
|
-
expect(strext.capitalize(null)).to.be.null;
|
|
147
|
-
done();
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('should do nothing to a zero length string', function(done) {
|
|
151
|
-
expect(strext.capitalize('')).to.equal('');
|
|
152
|
-
expect(strext.capitalize.call('')).to.equal('');
|
|
153
|
-
done();
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('should capitalize the only character in a string with length one', function(done) {
|
|
157
|
-
expect(strext.capitalize('a')).to.equal('A');
|
|
158
|
-
expect(strext.capitalize.call('a')).to.equal('A');
|
|
159
|
-
done();
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it('should only capitalize the first character of a multi-character string', function(done) {
|
|
163
|
-
expect(strext.capitalize('hello')).to.equal('Hello');
|
|
164
|
-
expect(strext.capitalize.call('hello')).to.equal('Hello');
|
|
165
|
-
expect(strext.capitalize('GOODBYE')).to.equal('GOODBYE');
|
|
166
|
-
expect(strext.capitalize.call('GOODBYE')).to.equal('GOODBYE');
|
|
167
|
-
done();
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
describe('#decapitalize', function() {
|
|
172
|
-
it('should return null if passed a null', function(done) {
|
|
173
|
-
expect(strext.decapitalize(null)).to.be.null;
|
|
174
|
-
done();
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('should do nothing to a zero length string', function(done) {
|
|
178
|
-
expect(strext.decapitalize('')).to.equal('');
|
|
179
|
-
expect(strext.decapitalize.call('')).to.equal('');
|
|
180
|
-
done();
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it('should capitalize the only character in a string with length one', function(done) {
|
|
184
|
-
expect(strext.decapitalize('A')).to.equal('a');
|
|
185
|
-
expect(strext.decapitalize.call('A')).to.equal('a');
|
|
186
|
-
done();
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('should only capitalize the first character of a multi-character string', function(done) {
|
|
190
|
-
expect(strext.decapitalize('Hello')).to.equal('hello');
|
|
191
|
-
expect(strext.decapitalize.call('Hello')).to.equal('hello');
|
|
192
|
-
expect(strext.decapitalize('GOODBYE')).to.equal('gOODBYE');
|
|
193
|
-
expect(strext.decapitalize.call('GOODBYE')).to.equal('gOODBYE');
|
|
194
|
-
done();
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
describe('#camelize', function() {
|
|
199
|
-
it('should return null if passed a null', function(done) {
|
|
200
|
-
expect(strext.camelize(null)).to.be.null;
|
|
201
|
-
done();
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it('should do nothing to a zero length string', function(done) {
|
|
205
|
-
expect(strext.camelize('')).to.equal('');
|
|
206
|
-
expect(strext.camelize.call('')).to.equal('');
|
|
207
|
-
done();
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it('should lowercase the only character in a string with length one', function(done) {
|
|
211
|
-
expect(strext.camelize('A')).to.equal('a');
|
|
212
|
-
expect(strext.camelize.call('a')).to.equal('a');
|
|
213
|
-
done();
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it('should camelize a string separated by dashes', function(done) {
|
|
217
|
-
expect(strext.camelize('prop-name')).to.equal('propName');
|
|
218
|
-
expect(strext.camelize.call('Prop-NAME')).to.equal('propNAME');
|
|
219
|
-
done();
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('should camelize a string separated by underscores', function(done) {
|
|
223
|
-
expect(strext.camelize('prop__name')).to.equal('propName');
|
|
224
|
-
expect(strext.camelize.call('Prop_NAME')).to.equal('propNAME');
|
|
225
|
-
done();
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
});
|