From f1f3ca4a8f7f383f54aeb43d9f350cd6edc95c96 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sat, 30 Dec 2017 17:08:11 +0000 Subject: [PATCH] Travis build: 672 [ci skip] --- README.md | 69 +++++++++++++++++++++---------------------------- docs/index.html | 14 +++++----- 2 files changed, 37 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index e036b03bd..329416bde 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ * [`scrollToTop`](#scrolltotop) * [`setStyle`](#setstyle) * [`show`](#show) +* [`speechSynthesis`](#speechsynthesis) * [`toggleClass`](#toggleclass) * [`UUIDGeneratorBrowser`](#uuidgeneratorbrowser) @@ -173,15 +174,6 @@ -### Media - -
-View contents - -* [`speechSynthesis`](#speechsynthesis) - -
- ### Node
@@ -1842,6 +1834,35 @@ show(document.querySelectorAll('img')); // Shows all elements on the page
[⬆ Back to top](#table-of-contents) +### speechSynthesis + +Performs speech synthesis (experimental). + +Use `SpeechSynthesisUtterance.voice` and `window.speechSynthesis.getVoices()` to convert a message to speech. +Use `window.speechSynthesis.speak()` to play the message. + +Learn more about the [SpeechSynthesisUtterance interface of the Web Speech API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance). + +```js +const speechSynthesis = message => { + const msg = new SpeechSynthesisUtterance(message); + msg.voice = window.speechSynthesis.getVoices()[0]; + window.speechSynthesis.speak(msg); +}; +``` + +
+Examples + +```js +speechSynthesis('Hello, World'); // // plays the message +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### toggleClass Toggle a class for an element. @@ -2880,36 +2901,6 @@ sum([1, 2, 3, 4]); // 10
[⬆ Back to top](#table-of-contents) -## Media - -### speechSynthesis - -Performs speech synthesis (experimental). - -Use `SpeechSynthesisUtterance.voice` and `window.speechSynthesis.getVoices()` to convert a message to speech. -Use `window.speechSynthesis.speak()` to play the message. - -Learn more about the [SpeechSynthesisUtterance interface of the Web Speech API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisUtterance). - -```js -const speechSynthesis = message => { - const msg = new SpeechSynthesisUtterance(message); - msg.voice = window.speechSynthesis.getVoices()[0]; - window.speechSynthesis.speak(msg); -}; -``` - -
-Examples - -```js -speechSynthesis('Hello, World'); // // plays the message -``` - -
- -
[⬆ Back to top](#table-of-contents) - ## Node ### JSONToFile diff --git a/docs/index.html b/docs/index.html index 356e7004a..1459847d1 100644 --- a/docs/index.html +++ b/docs/index.html @@ -59,7 +59,7 @@ wrapper.appendChild(box); box.appendChild(el); }); - }

 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
+    }

 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
 
Promise.resolve([1, 2, 3])
   .then(call('map', x => 2 * x))
   .then(console.log); //[ 2, 4, 6 ]
@@ -357,6 +357,12 @@ elementIsVisibleInViewport(el, true); // true // (partially visible)
 
setStyle(document.querySelector('p'), 'font-size', '20px'); // The first <p> element on the page will have a font-size of 20px
 

show

Shows all the elements specified.

Use the spread operator (...) and Array.forEach() to clear the display property for each element specified.

const show = (...el) => [...el].forEach(e => (e.style.display = ''));
 
show(document.querySelectorAll('img')); // Shows all <img> elements on the page
+

speechSynthesis

Performs speech synthesis (experimental).

Use SpeechSynthesisUtterance.voice and window.speechSynthesis.getVoices() to convert a message to speech. Use window.speechSynthesis.speak() to play the message.

Learn more about the SpeechSynthesisUtterance interface of the Web Speech API.

const speechSynthesis = message => {
+  const msg = new SpeechSynthesisUtterance(message);
+  msg.voice = window.speechSynthesis.getVoices()[0];
+  window.speechSynthesis.speak(msg);
+};
+
speechSynthesis('Hello, World'); // // plays the message
 

toggleClass

Toggle a class for an element.

Use element.classList.toggle() to toggle the specified class for the element.

const toggleClass = (el, className) => el.classList.toggle(className);
 
toggleClass(document.querySelector('p.special'), 'special'); // The paragraph will not have the 'special' class anymore
 

UUIDGeneratorBrowser

Generates a UUID in a browser.

Use crypto API to generate a UUID, compliant with RFC4122 version 4.

const UUIDGeneratorBrowser = () =>
@@ -549,12 +555,6 @@ median([0, 10, -2, 7]); // 3.5
 standardDeviation([10, 2, 38, 23, 38, 23, 21], true); // 12.29899614287479 (population)
 

sum

Returns the sum of an of two or more numbers/arrays.

Use Array.reduce() to add each value to an accumulator, initialized with a value of 0.

const sum = (...arr) => [].concat(...arr).reduce((acc, val) => acc + val, 0);
 
sum([1, 2, 3, 4]); // 10
-

Media

speechSynthesis

Performs speech synthesis (experimental).

Use SpeechSynthesisUtterance.voice and window.speechSynthesis.getVoices() to convert a message to speech. Use window.speechSynthesis.speak() to play the message.

Learn more about the SpeechSynthesisUtterance interface of the Web Speech API.

const speechSynthesis = message => {
-  const msg = new SpeechSynthesisUtterance(message);
-  msg.voice = window.speechSynthesis.getVoices()[0];
-  window.speechSynthesis.speak(msg);
-};
-
speechSynthesis('Hello, World'); // // plays the message
 

Node

JSONToFile

Writes a JSON object to a file.

Use fs.writeFile(), template literals and JSON.stringify() to write a json object to a .json file.

const fs = require('fs');
 const JSONToFile = (obj, filename) =>
   fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));