Travis build: 1289
This commit is contained in:
66
README.md
66
README.md
@ -162,6 +162,7 @@ average(1, 2, 3);
|
|||||||
* [`getScrollPosition`](#getscrollposition)
|
* [`getScrollPosition`](#getscrollposition)
|
||||||
* [`getStyle`](#getstyle)
|
* [`getStyle`](#getstyle)
|
||||||
* [`hasClass`](#hasclass)
|
* [`hasClass`](#hasclass)
|
||||||
|
* [`hashBrowser`](#hashbrowser-)
|
||||||
* [`hide`](#hide)
|
* [`hide`](#hide)
|
||||||
* [`httpsRedirect`](#httpsredirect)
|
* [`httpsRedirect`](#httpsredirect)
|
||||||
* [`observeMutations`](#observemutations-)
|
* [`observeMutations`](#observemutations-)
|
||||||
@ -255,6 +256,7 @@ average(1, 2, 3);
|
|||||||
|
|
||||||
* [`colorize`](#colorize)
|
* [`colorize`](#colorize)
|
||||||
* [`hasFlags`](#hasflags)
|
* [`hasFlags`](#hasflags)
|
||||||
|
* [`hashNode`](#hashnode)
|
||||||
* [`isTravisCI`](#istravisci)
|
* [`isTravisCI`](#istravisci)
|
||||||
* [`JSONToFile`](#jsontofile)
|
* [`JSONToFile`](#jsontofile)
|
||||||
* [`readFileLines`](#readfilelines)
|
* [`readFileLines`](#readfilelines)
|
||||||
@ -2223,6 +2225,35 @@ hasClass(document.querySelector('p.special'), 'special'); // true
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### hashBrowser 
|
||||||
|
|
||||||
|
Creates a hash for a value using the [SHA-256](https://en.wikipedia.org/wiki/SHA-2) algorithm. Returns a promise.
|
||||||
|
|
||||||
|
Use the [SubtleCrypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) API to create a hash for the given value.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const hashBrowser = val =>
|
||||||
|
crypto.subtle.digest('SHA-256', new TextEncoder('utf-8').encode(val)).then(h => {
|
||||||
|
let hexes = [],
|
||||||
|
view = new DataView(h);
|
||||||
|
for (let i = 0; i < view.byteLength; i += 4)
|
||||||
|
hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8));
|
||||||
|
return hexes.join('');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
hashBrowser(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393'
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### hide
|
### hide
|
||||||
|
|
||||||
Hides all the elements specified.
|
Hides all the elements specified.
|
||||||
@ -3915,6 +3946,41 @@ hasFlags('special'); // false
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### hashNode
|
||||||
|
|
||||||
|
Creates a hash for a value using the [SHA-256](https://en.wikipedia.org/wiki/SHA-2) algorithm. Returns a promise.
|
||||||
|
|
||||||
|
Use `crypto` API to create a hash for the given value.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const hashNode = val =>
|
||||||
|
new Promise(resolve =>
|
||||||
|
setTimeout(
|
||||||
|
() =>
|
||||||
|
resolve(
|
||||||
|
crypto
|
||||||
|
.createHash('sha256')
|
||||||
|
.update(val)
|
||||||
|
.digest('hex')
|
||||||
|
),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
hashBrowser(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393'
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### isTravisCI
|
### isTravisCI
|
||||||
|
|
||||||
Checks if the current environment is [Travis CI](https://travis-ci.org/).
|
Checks if the current environment is [Travis CI](https://travis-ci.org/).
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -6,9 +6,7 @@ Use the [SubtleCrypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCr
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const hashBrowser = val =>
|
const hashBrowser = val =>
|
||||||
crypto.subtle
|
crypto.subtle.digest('SHA-256', new TextEncoder('utf-8').encode(val)).then(h => {
|
||||||
.digest('SHA-256', new TextEncoder('utf-8').encode(val))
|
|
||||||
.then(h => {
|
|
||||||
let hexes = [],
|
let hexes = [],
|
||||||
view = new DataView(h);
|
view = new DataView(h);
|
||||||
for (let i = 0; i < view.byteLength; i += 4)
|
for (let i = 0; i < view.byteLength; i += 4)
|
||||||
@ -18,5 +16,5 @@ const hashBrowser = val =>
|
|||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
hashBrowser(JSON.stringify({a :'a', b: [1,2,3,4], 'foo': {c: 'bar'}})).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393'
|
hashBrowser(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393'
|
||||||
```
|
```
|
||||||
|
|||||||
@ -7,9 +7,20 @@ Use `crypto` API to create a hash for the given value.
|
|||||||
```js
|
```js
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const hashNode = val =>
|
const hashNode = val =>
|
||||||
new Promise(resolve => setTimeout(() => resolve(crypto.createHash('sha256').update(val).digest('hex')),0));
|
new Promise(resolve =>
|
||||||
|
setTimeout(
|
||||||
|
() =>
|
||||||
|
resolve(
|
||||||
|
crypto
|
||||||
|
.createHash('sha256')
|
||||||
|
.update(val)
|
||||||
|
.digest('hex')
|
||||||
|
),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
hashBrowser(JSON.stringify({a :'a', b: [1,2,3,4], 'foo': {c: 'bar'}})).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393'
|
hashBrowser(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393'
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user