Merge remote-tracking branch 'origin/master'

This commit is contained in:
Angelos Chalaris
2018-02-09 13:06:50 +02:00
9 changed files with 1642 additions and 1549 deletions

45
.codeclimate.yml Normal file
View 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
View 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
View 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'

View File

@ -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'
})
);

View File

@ -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">&#128203;&nbsp;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>

View File

@ -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'
})
);

View File

@ -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();
});
});

View File

@ -5,9 +5,14 @@ test('Testing randomIntegerInRange', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
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');
const numberForTest = randomIntegerInRange(lowerLimit,upperLimit);
t.true((numberForTest >= lowerLimit) && (numberForTest <= upperLimit),'The returned value lies between provied lowerLimit and upperLimit (both inclusive).');
//t.deepEqual(randomIntegerInRange(args..), 'Expected');
//t.equal(randomIntegerInRange(args..), 'Expected');
//t.false(randomIntegerInRange(args..), 'Expected');
//t.throws(randomIntegerInRange(args..), 'Expected');
t.end();
});
});

File diff suppressed because it is too large Load Diff