fix conflicts
This commit is contained in:
45
.codeclimate.yml
Normal file
45
.codeclimate.yml
Normal file
@ -0,0 +1,45 @@
|
||||
version: "2" # required to adjust maintainability checks
|
||||
plugins:
|
||||
eslint:
|
||||
enabled: true
|
||||
markdownlint:
|
||||
enabled: true
|
||||
# initial: .mdlrc
|
||||
# config: .mdlrc.style.rb
|
||||
fixme:
|
||||
enabled: true
|
||||
checks:
|
||||
argument-count:
|
||||
config:
|
||||
threshold: 4
|
||||
complex-logic:
|
||||
config:
|
||||
threshold: 4
|
||||
file-lines:
|
||||
config:
|
||||
threshold: 250
|
||||
method-complexity:
|
||||
config:
|
||||
threshold: 5
|
||||
method-count:
|
||||
config:
|
||||
threshold: 20
|
||||
method-lines:
|
||||
config:
|
||||
threshold: 25
|
||||
nested-control-flow:
|
||||
config:
|
||||
threshold: 4
|
||||
return-statements:
|
||||
config:
|
||||
threshold: 4
|
||||
similar-code:
|
||||
config:
|
||||
threshold: # language-specific defaults. an override will affect all languages.
|
||||
identical-code:
|
||||
config:
|
||||
threshold: # language-specific defaults. an override will affect all languages
|
||||
exclude_patterns:
|
||||
- "locale/"
|
||||
- "**/test/"
|
||||
- "dist/"
|
||||
12
.mdlrc
Normal file
12
.mdlrc
Normal file
@ -0,0 +1,12 @@
|
||||
rules "MD003", // header style - atx
|
||||
"MD004", // ul list style - asterisk
|
||||
"MD009", // no trailing whitespaces
|
||||
"MD010", // no hard tabs
|
||||
"MD011", // no reversed links
|
||||
"MD018", // no space after hash on atx style header
|
||||
"MD023", // headers should start on the start of the line
|
||||
"MD025", // no multiple h1 headers
|
||||
"MD031", // blanks around fences
|
||||
"MD038", // no spaces inside code elements
|
||||
"MD040" // fenced code blocks need to have a language specified
|
||||
style ".mdlrc.style.rb"
|
||||
7
.mdlrc.style.rb
Normal file
7
.mdlrc.style.rb
Normal file
@ -0,0 +1,7 @@
|
||||
all
|
||||
rule 'header-style', :style => "atx"
|
||||
rule 'ul-style', :style => "asterisk"
|
||||
|
||||
exclude_rule 'first-header-h1'
|
||||
exclude_rule 'first-line-h1'
|
||||
exclude_rule 'no-inline-html'
|
||||
24
README.md
24
README.md
@ -3275,9 +3275,8 @@ Return a promise, listening for `onmessage` and `onerror` events and resolving t
|
||||
|
||||
```js
|
||||
const runAsync = fn => {
|
||||
const blob = `var fn = ${fn.toString()}; postMessage(fn());`;
|
||||
const worker = new Worker(
|
||||
URL.createObjectURL(new Blob([blob]), {
|
||||
URL.createObjectURL(new Blob([`postMessage((${fn})());`]), {
|
||||
type: 'application/javascript; charset=utf-8'
|
||||
})
|
||||
);
|
||||
@ -3823,20 +3822,17 @@ curry(Math.min, 3)(10)(50)(2); // 2
|
||||
|
||||
### debounce
|
||||
|
||||
Creates a debounced function that delays invoking the provided function until after `wait` milliseconds have elapsed since the last time the debounced function was invoked.
|
||||
Creates a debounced function that delays invoking the provided function until at least `ms` milliseconds have elapsed since the last time it was invoked.
|
||||
|
||||
Use `setTimeout()` and `clearTimeout()` to debounce the given method, `fn`.
|
||||
Use `Function.apply()` to apply the `this` context to the function and provide the necessary `arguments`.
|
||||
Omit the second argument, `wait`, to set the timeout at a default of 0 ms.
|
||||
Each time the debounced function is invoked, clear the current pending timeout with `clearTimeout()` and use `setTimeout()` to create a new timeout that delays invoking the function until at least `ms` milliseconds has elapsed. Use `Function.apply()` to apply the `this` context to the function and provide the necessary arguments.
|
||||
Omit the second argument, `ms`, to set the timeout at a default of 0 ms.
|
||||
|
||||
```js
|
||||
const debounce = (fn, wait = 0) => {
|
||||
let inDebounce;
|
||||
return function() {
|
||||
const context = this,
|
||||
args = arguments;
|
||||
clearTimeout(inDebounce);
|
||||
inDebounce = setTimeout(() => fn.apply(context, args), wait);
|
||||
const debounce = (fn, ms = 0) => {
|
||||
let timeoutId;
|
||||
return function(...args) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = setTimeout(() => fn.apply(this, args), ms);
|
||||
};
|
||||
};
|
||||
```
|
||||
@ -3847,7 +3843,7 @@ const debounce = (fn, wait = 0) => {
|
||||
```js
|
||||
window.addEventListener(
|
||||
'resize',
|
||||
debounce(function(evt) {
|
||||
debounce(() => {
|
||||
console.log(window.innerWidth);
|
||||
console.log(window.innerHeight);
|
||||
}, 250)
|
||||
|
||||
3
dist/_30s.es5.js
vendored
3
dist/_30s.es5.js
vendored
@ -1761,8 +1761,7 @@ var round = function round(n) {
|
||||
};
|
||||
|
||||
var runAsync = function runAsync(fn) {
|
||||
var blob = 'var fn = ' + fn.toString() + '; postMessage(fn());';
|
||||
var worker = new Worker(URL.createObjectURL(new Blob([blob]), {
|
||||
var worker = new Worker(URL.createObjectURL(new Blob(['postMessage((' + fn + ')());']), {
|
||||
type: 'application/javascript; charset=utf-8'
|
||||
}));
|
||||
return new Promise(function (res, rej) {
|
||||
|
||||
2
dist/_30s.es5.min.js
vendored
2
dist/_30s.es5.min.js
vendored
File diff suppressed because one or more lines are too long
3
dist/_30s.esm.js
vendored
3
dist/_30s.esm.js
vendored
@ -1013,9 +1013,8 @@ const reverseString = str => [...str].reverse().join('');
|
||||
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
|
||||
|
||||
const runAsync = fn => {
|
||||
const blob = `var fn = ${fn.toString()}; postMessage(fn());`;
|
||||
const worker = new Worker(
|
||||
URL.createObjectURL(new Blob([blob]), {
|
||||
URL.createObjectURL(new Blob([`postMessage((${fn})());`]), {
|
||||
type: 'application/javascript; charset=utf-8'
|
||||
})
|
||||
);
|
||||
|
||||
3
dist/_30s.js
vendored
3
dist/_30s.js
vendored
@ -1019,9 +1019,8 @@ const reverseString = str => [...str].reverse().join('');
|
||||
const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`);
|
||||
|
||||
const runAsync = fn => {
|
||||
const blob = `var fn = ${fn.toString()}; postMessage(fn());`;
|
||||
const worker = new Worker(
|
||||
URL.createObjectURL(new Blob([blob]), {
|
||||
URL.createObjectURL(new Blob([`postMessage((${fn})());`]), {
|
||||
type: 'application/javascript; charset=utf-8'
|
||||
})
|
||||
);
|
||||
|
||||
2
dist/_30s.min.js
vendored
2
dist/_30s.min.js
vendored
File diff suppressed because one or more lines are too long
@ -700,9 +700,8 @@ document<span class="token punctuation">.</span>body<span class="token punctuati
|
||||
asLink <span class="token operator">?</span> <span class="token punctuation">(</span>window<span class="token punctuation">.</span>location<span class="token punctuation">.</span>href <span class="token operator">=</span> url<span class="token punctuation">) :</span> window<span class="token punctuation">.</span>location<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span>url<span class="token punctuation">);</span>
|
||||
</pre><label class="collapse">Show examples</label><pre class="language-js"><span class="token function">redirect</span><span class="token punctuation">(</span><span class="token string">'https://google.com'</span><span class="token punctuation">);</span>
|
||||
</pre><button class="primary clipboard-copy">📋 Copy to clipboard</button></div></div><div class="card fluid"><h3 id="runasync" class="section double-padded">runAsync<mark class="tag">advanced</mark></h3><div class="section double-padded"><p>Runs a function in a separate thread by using a <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers">Web Worker</a>, allowing long running functions to not block the UI.</p><p>Create a new <code>Worker</code> using a <code>Blob</code> object URL, the contents of which should be the stringified version of the supplied function. Immediately post the return value of calling the function back. Return a promise, listening for <code>onmessage</code> and <code>onerror</code> events and resolving the data posted back from the worker, or throwing an error.</p><pre class="language-js"><span class="token keyword">const</span> <span class="token function-variable function">runAsync</span> <span class="token operator">=</span> fn <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||||
<span class="token keyword">const</span> blob <span class="token operator">=</span> <span class="token template-string"><span class="token string">`var fn = </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>fn<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">()</span><span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">; postMessage(fn());`</span></span><span class="token punctuation">;</span>
|
||||
<span class="token keyword">const</span> worker <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Worker</span><span class="token punctuation">(</span>
|
||||
URL<span class="token punctuation">.</span><span class="token function">createObjectURL</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Blob</span><span class="token punctuation">([</span>blob<span class="token punctuation">]), {</span>
|
||||
URL<span class="token punctuation">.</span><span class="token function">createObjectURL</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Blob</span><span class="token punctuation">([</span><span class="token template-string"><span class="token string">`postMessage((</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>fn<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">)());`</span></span><span class="token punctuation">]), {</span>
|
||||
type<span class="token punctuation">:</span> <span class="token string">'application/javascript; charset=utf-8'</span>
|
||||
<span class="token punctuation">})
|
||||
);</span>
|
||||
@ -858,18 +857,16 @@ console<span class="token punctuation">.</span><span class="token function">log<
|
||||
arity <span class="token operator"><=</span> args<span class="token punctuation">.</span>length <span class="token operator">?</span> <span class="token function">fn</span><span class="token punctuation">(</span><span class="token operator">...</span>args<span class="token punctuation">) :</span> curry<span class="token punctuation">.</span><span class="token function">bind</span><span class="token punctuation">(</span><span class="token keyword">null</span><span class="token punctuation">,</span> fn<span class="token punctuation">,</span> arity<span class="token punctuation">,</span> <span class="token operator">...</span>args<span class="token punctuation">);</span>
|
||||
</pre><label class="collapse">Show examples</label><pre class="language-js"><span class="token function">curry</span><span class="token punctuation">(</span>Math<span class="token punctuation">.</span>pow<span class="token punctuation">)(</span><span class="token number">2</span><span class="token punctuation">)(</span><span class="token number">10</span><span class="token punctuation">);</span> <span class="token comment">// 1024</span>
|
||||
<span class="token function">curry</span><span class="token punctuation">(</span>Math<span class="token punctuation">.</span>min<span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)(</span><span class="token number">10</span><span class="token punctuation">)(</span><span class="token number">50</span><span class="token punctuation">)(</span><span class="token number">2</span><span class="token punctuation">);</span> <span class="token comment">// 2</span>
|
||||
</pre><button class="primary clipboard-copy">📋 Copy to clipboard</button></div></div><div class="card fluid"><h3 id="debounce" class="section double-padded">debounce</h3><div class="section double-padded"><p>Creates a debounced function that delays invoking the provided function until after <code>wait</code> milliseconds have elapsed since the last time the debounced function was invoked.</p><p>Use <code>setTimeout()</code> and <code>clearTimeout()</code> to debounce the given method, <code>fn</code>. Use <code>Function.apply()</code> to apply the <code>this</code> context to the function and provide the necessary <code>arguments</code>. Omit the second argument, <code>wait</code>, to set the timeout at a default of 0 ms.</p><pre class="language-js"><span class="token keyword">const</span> <span class="token function-variable function">debounce</span> <span class="token operator">=</span> <span class="token punctuation">(</span>fn<span class="token punctuation">,</span> wait <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||||
<span class="token keyword">let</span> inDebounce<span class="token punctuation">;</span>
|
||||
<span class="token keyword">return function</span><span class="token punctuation">() {</span>
|
||||
<span class="token keyword">const</span> context <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">,</span>
|
||||
args <span class="token operator">=</span> arguments<span class="token punctuation">;</span>
|
||||
<span class="token function">clearTimeout</span><span class="token punctuation">(</span>inDebounce<span class="token punctuation">);</span>
|
||||
inDebounce <span class="token operator">=</span> <span class="token function">setTimeout</span><span class="token punctuation">(()</span> <span class="token operator">=></span> fn<span class="token punctuation">.</span><span class="token function">apply</span><span class="token punctuation">(</span>context<span class="token punctuation">,</span> args<span class="token punctuation">),</span> wait<span class="token punctuation">);
|
||||
</pre><button class="primary clipboard-copy">📋 Copy to clipboard</button></div></div><div class="card fluid"><h3 id="debounce" class="section double-padded">debounce</h3><div class="section double-padded"><p>Creates a debounced function that delays invoking the provided function until at least <code>ms</code> milliseconds have elapsed since the last time it was invoked.</p><p>Each time the debounced function is invoked, clear the current pending timeout with <code>clearTimeout()</code> and use <code>setTimeout()</code> to create a new timeout that delays invoking the function until at least <code>ms</code> milliseconds has elapsed. Use <code>Function.apply()</code> to apply the <code>this</code> context to the function and provide the necessary arguments. Omit the second argument, <code>ms</code>, to set the timeout at a default of 0 ms.</p><pre class="language-js"><span class="token keyword">const</span> <span class="token function-variable function">debounce</span> <span class="token operator">=</span> <span class="token punctuation">(</span>fn<span class="token punctuation">,</span> ms <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||||
<span class="token keyword">let</span> timeoutId<span class="token punctuation">;</span>
|
||||
<span class="token keyword">return function</span><span class="token punctuation">(</span><span class="token operator">...</span>args<span class="token punctuation">) {</span>
|
||||
<span class="token function">clearTimeout</span><span class="token punctuation">(</span>timeoutId<span class="token punctuation">);</span>
|
||||
timeoutId <span class="token operator">=</span> <span class="token function">setTimeout</span><span class="token punctuation">(()</span> <span class="token operator">=></span> fn<span class="token punctuation">.</span><span class="token function">apply</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> args<span class="token punctuation">),</span> ms<span class="token punctuation">);
|
||||
};
|
||||
};</span>
|
||||
</pre><label class="collapse">Show examples</label><pre class="language-js">window<span class="token punctuation">.</span><span class="token function">addEventListener</span><span class="token punctuation">(</span>
|
||||
<span class="token string">'resize'</span><span class="token punctuation">,</span>
|
||||
<span class="token function">debounce</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span>evt<span class="token punctuation">) {</span>
|
||||
<span class="token function">debounce</span><span class="token punctuation">(()</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||||
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>window<span class="token punctuation">.</span>innerWidth<span class="token punctuation">);</span>
|
||||
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>window<span class="token punctuation">.</span>innerHeight<span class="token punctuation">);
|
||||
},</span> <span class="token number">250</span><span class="token punctuation">)
|
||||
|
||||
@ -1,19 +1,16 @@
|
||||
### debounce
|
||||
|
||||
Creates a debounced function that delays invoking the provided function until after `wait` milliseconds have elapsed since the last time the debounced function was invoked.
|
||||
Creates a debounced function that delays invoking the provided function until at least `ms` milliseconds have elapsed since the last time it was invoked.
|
||||
|
||||
Use `setTimeout()` and `clearTimeout()` to debounce the given method, `fn`.
|
||||
Use `Function.apply()` to apply the `this` context to the function and provide the necessary `arguments`.
|
||||
Omit the second argument, `wait`, to set the timeout at a default of 0 ms.
|
||||
Each time the debounced function is invoked, clear the current pending timeout with `clearTimeout()` and use `setTimeout()` to create a new timeout that delays invoking the function until at least `ms` milliseconds has elapsed. Use `Function.apply()` to apply the `this` context to the function and provide the necessary arguments.
|
||||
Omit the second argument, `ms`, to set the timeout at a default of 0 ms.
|
||||
|
||||
```js
|
||||
const debounce = (fn, wait = 0) => {
|
||||
let inDebounce;
|
||||
return function() {
|
||||
const context = this,
|
||||
args = arguments;
|
||||
clearTimeout(inDebounce);
|
||||
inDebounce = setTimeout(() => fn.apply(context, args), wait);
|
||||
const debounce = (fn, ms = 0) => {
|
||||
let timeoutId;
|
||||
return function(...args) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = setTimeout(() => fn.apply(this, args), ms);
|
||||
};
|
||||
};
|
||||
```
|
||||
@ -21,7 +18,7 @@ const debounce = (fn, wait = 0) => {
|
||||
```js
|
||||
window.addEventListener(
|
||||
'resize',
|
||||
debounce(function(evt) {
|
||||
debounce(() => {
|
||||
console.log(window.innerWidth);
|
||||
console.log(window.innerHeight);
|
||||
}, 250)
|
||||
|
||||
@ -8,9 +8,8 @@ Return a promise, listening for `onmessage` and `onerror` events and resolving t
|
||||
|
||||
```js
|
||||
const runAsync = fn => {
|
||||
const blob = `var fn = ${fn.toString()}; postMessage(fn());`;
|
||||
const worker = new Worker(
|
||||
URL.createObjectURL(new Blob([blob]), {
|
||||
URL.createObjectURL(new Blob([`postMessage((${fn})());`]), {
|
||||
type: 'application/javascript; charset=utf-8'
|
||||
})
|
||||
);
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing JSONToFile', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof JSONToFile === 'function', 'JSONToFile is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(JSONToFile(args..), 'Expected');
|
||||
//t.equal(JSONToFile(args..), 'Expected');
|
||||
//t.false(JSONToFile(args..), 'Expected');
|
||||
//t.throws(JSONToFile(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing UUIDGeneratorBrowser', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof UUIDGeneratorBrowser === 'function', 'UUIDGeneratorBrowser is a Function');
|
||||
t.pass('Tested 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(UUIDGeneratorBrowser(args..), 'Expected');
|
||||
//t.equal(UUIDGeneratorBrowser(args..), 'Expected');
|
||||
//t.false(UUIDGeneratorBrowser(args..), 'Expected');
|
||||
//t.throws(UUIDGeneratorBrowser(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,12 @@ test('Testing UUIDGeneratorNode', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof UUIDGeneratorNode === 'function', 'UUIDGeneratorNode is a Function');
|
||||
const uuid = UUIDGeneratorNode();
|
||||
t.deepEqual([uuid[8], uuid[13], uuid[18], uuid[23]], ['-', '-', '-', '-'], 'Contains dashes in the proper places');
|
||||
t.true(/^[0-9A-Fa-f-]+$/.test(uuid), 'Only contains hexadecimal digits');
|
||||
//t.deepEqual(UUIDGeneratorNode(args..), 'Expected');
|
||||
//t.equal(UUIDGeneratorNode(args..), 'Expected');
|
||||
//t.false(UUIDGeneratorNode(args..), 'Expected');
|
||||
//t.throws(UUIDGeneratorNode(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing bottomVisible', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof bottomVisible === 'function', 'bottomVisible is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(bottomVisible(args..), 'Expected');
|
||||
//t.equal(bottomVisible(args..), 'Expected');
|
||||
//t.false(bottomVisible(args..), 'Expected');
|
||||
//t.throws(bottomVisible(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing colorize', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof colorize === 'function', 'colorize is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(colorize(args..), 'Expected');
|
||||
//t.equal(colorize(args..), 'Expected');
|
||||
//t.false(colorize(args..), 'Expected');
|
||||
//t.throws(colorize(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing copyToClipboard', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof copyToClipboard === 'function', 'copyToClipboard is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(copyToClipboard(args..), 'Expected');
|
||||
//t.equal(copyToClipboard(args..), 'Expected');
|
||||
//t.false(copyToClipboard(args..), 'Expected');
|
||||
//t.throws(copyToClipboard(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing detectDeviceType', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof detectDeviceType === 'function', 'detectDeviceType is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(detectDeviceType(args..), 'Expected');
|
||||
//t.equal(detectDeviceType(args..), 'Expected');
|
||||
//t.false(detectDeviceType(args..), 'Expected');
|
||||
//t.throws(detectDeviceType(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing elementIsVisibleInViewport', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof elementIsVisibleInViewport === 'function', 'elementIsVisibleInViewport is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(elementIsVisibleInViewport(args..), 'Expected');
|
||||
//t.equal(elementIsVisibleInViewport(args..), 'Expected');
|
||||
//t.false(elementIsVisibleInViewport(args..), 'Expected');
|
||||
//t.throws(elementIsVisibleInViewport(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing httpsRedirect', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof httpsRedirect === 'function', 'httpsRedirect is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(httpsRedirect(args..), 'Expected');
|
||||
//t.equal(httpsRedirect(args..), 'Expected');
|
||||
//t.false(httpsRedirect(args..), 'Expected');
|
||||
//t.throws(httpsRedirect(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,11 +5,12 @@ test('Testing mapObject', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof mapObject === 'function', 'mapObject is a Function');
|
||||
const squareIt = arr => mapObject(arr, a => a * a);
|
||||
t.deepEqual(squareIt([1, 2, 3]), { 1: 1, 2: 4, 3: 9 }, "Maps the values of an array to an object using a function");
|
||||
//t.deepEqual(mapObject(args..), 'Expected');
|
||||
t.deepEqual(mapObject([1, 2, 3], a => a * a), { 1: 1, 2: 4, 3: 9 }, "mapObject([1, 2, 3], a => a * a) returns { 1: 1, 2: 4, 3: 9 }");
|
||||
t.deepEqual(mapObject([1, 2, 3, 4], (a, b) => b - a), { 1: -1, 2: -1, 3: -1, 4: -1 }, 'mapObject([1, 2, 3, 4], (a, b) => b - a) returns { 1: -1, 2: -1, 3: -1, 4: -1 }');
|
||||
t.deepEqual(mapObject([1, 2, 3, 4], (a, b) => a - b), { 1: 1, 2: 1, 3: 1, 4: 1 }, 'mapObject([1, 2, 3, 4], (a, b) => a - b) returns { 1: 1, 2: 1, 3: 1, 4: 1 }');
|
||||
|
||||
//t.equal(mapObject(args..), 'Expected');
|
||||
//t.false(mapObject(args..), 'Expected');
|
||||
//t.throws(mapObject(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing observeMutations', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof observeMutations === 'function', 'observeMutations is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(observeMutations(args..), 'Expected');
|
||||
//t.equal(observeMutations(args..), 'Expected');
|
||||
//t.false(observeMutations(args..), 'Expected');
|
||||
//t.throws(observeMutations(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,13 @@ test('Testing promisify', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof promisify === 'function', 'promisify is a Function');
|
||||
const x = promisify(Math.max);
|
||||
t.true(x() instanceof Promise, 'Returns a promise');
|
||||
const delay = promisify((d, cb) => setTimeout(cb, d));
|
||||
delay(200).then(() => t.pass('Runs the function provided'));
|
||||
//t.deepEqual(promisify(args..), 'Expected');
|
||||
//t.equal(promisify(args..), 'Expected');
|
||||
//t.false(promisify(args..), 'Expected');
|
||||
//t.throws(promisify(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -7,13 +7,13 @@ test('Testing randomIntArrayInRange', (t) => {
|
||||
t.true(typeof randomIntArrayInRange === 'function', 'randomIntArrayInRange is a Function');
|
||||
const lowerLimit = Math.floor(Math.random() * 20);
|
||||
const upperLimit = Math.floor(lowerLimit + Math.random() * 10);
|
||||
const randLength = Math.floor(Math.random() * 10)
|
||||
t.true(randomIntArrayInRange(lowerLimit,upperLimit).length === 1,'The default value of returned array is 1');
|
||||
t.true(randomIntArrayInRange(lowerLimit,upperLimit,randLength).length === randLength,'The length of returned array is the same as the provided value.')
|
||||
t.true(randomIntArrayInRange(lowerLimit,upperLimit,randLength).filter(el => !((el>=lowerLimit) && (el <= upperLimit))).length === 0,'The returned values is in range.')
|
||||
const arr = randomIntArrayInRange(lowerLimit,upperLimit, 10);
|
||||
t.true(arr.every(x => typeof x === 'number'), 'The returned array contains only integers');
|
||||
t.equal(arr.length, 10, 'The returned array has the proper length');
|
||||
t.true(arr.every(x => (x >= lowerLimit) && (x <= upperLimit)),'The returned array\'s values lie between provided lowerLimit and upperLimit (both inclusive).');
|
||||
//t.deepEqual(randomIntArrayInRange(args..), 'Expected');
|
||||
//t.equal(randomIntArrayInRange(args..), 'Expected');
|
||||
//t.false(randomIntArrayInRange(args..), 'Expected');
|
||||
//t.throws(randomIntArrayInRange(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -7,9 +7,9 @@ test('Testing randomIntegerInRange', (t) => {
|
||||
t.true(typeof randomIntegerInRange === 'function', 'randomIntegerInRange is a Function');
|
||||
const lowerLimit = Math.floor(Math.random() * 20);
|
||||
const upperLimit = Math.floor(lowerLimit + Math.random() * 10);
|
||||
t.true(Number.isInteger(randomIntegerInRange(lowerLimit,upperLimit)),'The returned value is a Integer');
|
||||
t.true(Number.isInteger(randomIntegerInRange(lowerLimit,upperLimit)),'The returned value is an integer');
|
||||
const numberForTest = randomIntegerInRange(lowerLimit,upperLimit);
|
||||
t.true((numberForTest >= lowerLimit) && (numberForTest <= upperLimit),'The returned value lies between provied lowerLimit and upperLimit (both inclusive).');
|
||||
t.true((numberForTest >= lowerLimit) && (numberForTest <= upperLimit),'The returned value lies between provided lowerLimit and upperLimit (both inclusive).');
|
||||
//t.deepEqual(randomIntegerInRange(args..), 'Expected');
|
||||
//t.equal(randomIntegerInRange(args..), 'Expected');
|
||||
//t.false(randomIntegerInRange(args..), 'Expected');
|
||||
|
||||
@ -7,11 +7,12 @@ test('Testing randomNumberInRange', (t) => {
|
||||
t.true(typeof randomNumberInRange === 'function', 'randomNumberInRange is a Function');
|
||||
const lowerLimit = Math.floor(Math.random() * 20);
|
||||
const upperLimit = Math.floor(lowerLimit + Math.random() * 10);
|
||||
t.true(typeof randomNumberInRange(lowerLimit,upperLimit) === 'number','The returned value is a number');
|
||||
const numberForTest = randomNumberInRange(lowerLimit,upperLimit);
|
||||
t.true((numberForTest >= lowerLimit) && (numberForTest <= upperLimit),'The returned value lies between provied lowerLimit and upperLimit (both inclusive).');
|
||||
t.true((numberForTest >= lowerLimit) && (numberForTest <= upperLimit),'The returned value lies between provided lowerLimit and upperLimit (both inclusive).');
|
||||
//t.deepEqual(randomNumberInRange(args..), 'Expected');
|
||||
//t.equal(randomNumberInRange(args..), 'Expected');
|
||||
//t.false(randomNumberInRange(args..), 'Expected');
|
||||
//t.throws(randomNumberInRange(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing readFileLines', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof readFileLines === 'function', 'readFileLines is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(readFileLines(args..), 'Expected');
|
||||
//t.equal(readFileLines(args..), 'Expected');
|
||||
//t.false(readFileLines(args..), 'Expected');
|
||||
//t.throws(readFileLines(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing redirect', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof redirect === 'function', 'redirect is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(redirect(args..), 'Expected');
|
||||
//t.equal(redirect(args..), 'Expected');
|
||||
//t.false(redirect(args..), 'Expected');
|
||||
//t.throws(redirect(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
const runAsync = fn => {
|
||||
const blob = `var fn = ${fn.toString()}; postMessage(fn());`;
|
||||
const worker = new Worker(
|
||||
URL.createObjectURL(new Blob([blob]), {
|
||||
URL.createObjectURL(new Blob([`postMessage((${fn})());`]), {
|
||||
type: 'application/javascript; charset=utf-8'
|
||||
})
|
||||
);
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing runAsync', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof runAsync === 'function', 'runAsync is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(runAsync(args..), 'Expected');
|
||||
//t.equal(runAsync(args..), 'Expected');
|
||||
//t.false(runAsync(args..), 'Expected');
|
||||
//t.throws(runAsync(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,11 @@ test('Testing runPromisesInSeries', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof runPromisesInSeries === 'function', 'runPromisesInSeries is a Function');
|
||||
const delay = d => new Promise(r => setTimeout(r, d));
|
||||
runPromisesInSeries([() => delay(100), () => delay(200).then(() => t.pass('Runs promises in series'))]);
|
||||
//t.deepEqual(runPromisesInSeries(args..), 'Expected');
|
||||
//t.equal(runPromisesInSeries(args..), 'Expected');
|
||||
//t.false(runPromisesInSeries(args..), 'Expected');
|
||||
//t.throws(runPromisesInSeries(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,13 @@ test('Testing sample', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof sample === 'function', 'sample is a Function');
|
||||
const arr = [3,7,9,11];
|
||||
t.true(arr.includes(sample(arr)), 'Returns a random element from the array');
|
||||
t.equal(sample([1]), 1, 'Works for single-element arrays');
|
||||
t.equal(sample([]), undefined, 'Returns undefined for empty array');
|
||||
//t.deepEqual(sample(args..), 'Expected');
|
||||
//t.equal(sample(args..), 'Expected');
|
||||
//t.false(sample(args..), 'Expected');
|
||||
//t.throws(sample(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,15 @@ test('Testing sampleSize', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof sampleSize === 'function', 'sampleSize is a Function');
|
||||
const arr = [3,7,9,11];
|
||||
t.equal(sampleSize(arr).length, 1, 'Returns a single element without n specified');
|
||||
t.true(sampleSize(arr, 2).every(x => arr.includes(x)), 'Returns a random sample of specified size from an array');
|
||||
t.equal(sampleSize(arr, 5).length, 4, 'Returns all elements in an array if n >= length');
|
||||
t.deepEqual(sampleSize([], 2), [], 'Returns an empty array if original array is empty');
|
||||
t.deepEqual(sampleSize(arr, 0), [], 'Returns an empty array if n = 0');
|
||||
//t.deepEqual(sampleSize(args..), 'Expected');
|
||||
//t.equal(sampleSize(args..), 'Expected');
|
||||
//t.false(sampleSize(args..), 'Expected');
|
||||
//t.throws(sampleSize(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,10 @@ test('Testing scrollToTop', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof scrollToTop === 'function', 'scrollToTop is a Function');
|
||||
t.pass('Tested on 09/02/2018 by @chalarangelo');
|
||||
//t.deepEqual(scrollToTop(args..), 'Expected');
|
||||
//t.equal(scrollToTop(args..), 'Expected');
|
||||
//t.false(scrollToTop(args..), 'Expected');
|
||||
//t.throws(scrollToTop(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -6,7 +6,10 @@ test('Testing shuffle', (t) => {
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof shuffle === 'function', 'shuffle is a Function');
|
||||
const arr = [1,2,3,4,5,6];
|
||||
//t.notDeepEqual(shuffle(arr), arr, 'Shuffles the array'); Does not work always (got a test failing once)
|
||||
t.notEqual(shuffle(arr), arr, 'Shuffles the array');
|
||||
t.true(shuffle(arr).every(x => arr.includes(x)), 'New array contains all original elements');
|
||||
t.deepEqual(shuffle([]),[],'Works for empty arrays');
|
||||
t.deepEqual(shuffle([1]),[1],'Works for single-element arrays');
|
||||
//t.deepEqual(shuffle(args..), 'Expected');
|
||||
//t.equal(shuffle(args..), 'Expected');
|
||||
//t.false(shuffle(args..), 'Expected');
|
||||
|
||||
3475
test/testlog
3475
test/testlog
File diff suppressed because it is too large
Load Diff
@ -5,9 +5,14 @@ test('Testing tomorrow', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof tomorrow === 'function', 'tomorrow is a Function');
|
||||
const t1 = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1);
|
||||
const t2 = new Date(tomorrow());
|
||||
t.equal(t1.getFullYear(), t2.getFullYear(), 'Returns the correct year');
|
||||
t.equal(t1.getMonth(), t2.getMonth(), 'Returns the correct month');
|
||||
t.equal(t1.getDate(), t2.getDate(), 'Returns the correct date');
|
||||
//t.deepEqual(tomorrow(args..), 'Expected');
|
||||
//t.equal(tomorrow(args..), 'Expected');
|
||||
//t.false(tomorrow(args..), 'Expected');
|
||||
//t.throws(tomorrow(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -5,9 +5,12 @@ test('Testing untildify', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof untildify === 'function', 'untildify is a Function');
|
||||
t.true(untildify('~/test/dir/file.f').indexOf('~') === -1, 'Contains no tildes');
|
||||
t.equal(untildify('~/test/dir/file.f').slice(-16), '/test/dir/file.f', 'Does not alter the rest of the path');
|
||||
t.equal(untildify('test/dir/file.f'), 'test/dir/file.f', 'Does not alter paths without tildes');
|
||||
//t.deepEqual(untildify(args..), 'Expected');
|
||||
//t.equal(untildify(args..), 'Expected');
|
||||
//t.false(untildify(args..), 'Expected');
|
||||
//t.throws(untildify(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user