The core goal of 30 seconds of code is to provide a quality resource for beginner and advanced JavaScript developers alike. We want to help improve the JavaScript ecosystem, by lowering the barrier of entry for newcomers and help seasoned veterans pick up new tricks and remember old ones. In order to achieve this, we have collected hundreds of snippets that can be of use in a wide range of situations. We welcome new contributors and we like fresh ideas, as long as the code is short and easy to grasp in about 30 seconds. The only catch, if you may, is that a few of our snippets are not perfectly optimized for large, enterprise applications and they might not be deemed production-ready.
+
Related projects
+
The idea behind 30 seconds of code has inspired some people to create similar collections in other programming languages and environments. Here are the ones we like the most:
In order for 30 seconds of code to be as accessible and useful as
+ possible, all of the snippets in the collection are licensed under the CC0-1.0
+ License, meaning they are absolutely free to use in any project you like. If you like what we do, you can
+ always credit us, but that is not mandatory.
+
+
+
+
+
+
+
diff --git a/docs/adapter.html b/docs/adapter.html
index 14a90f377..3f765a68c 100644
--- a/docs/adapter.html
+++ b/docs/adapter.html
@@ -1,6 +1,6 @@
-Adapter - 30 seconds of codeAdapter - 30 seconds of code
let a ={ name:'John Smith'};let b ={};const mergeFrom =flip(Object.assign);let mergePerson = mergeFrom.bind(null, a);mergePerson(b);// == b
b ={};
Object.assign(b, a);// == b
-
over
Creates a function that invokes each provided function with the arguments it receives and returns the results.
Use Array.map() and Function.apply() to apply each function to the given arguments.
constsquare= n => n * n;constdouble= n => n *2;const fn =overArgs((x, y)=>[x, y], [square, double]);fn(9,3);// [81, 6]
-
pipeAsyncFunctions
Performs left-to-right function composition for asynchronous functions.
Use Array.reduce() with the spread operator (...) to perform left-to-right function composition using Promise.then(). The functions can return a combination of: simple values, Promise's, or they can be defined as async ones returning through await. All functions must be unary.
Performs left-to-right function composition for asynchronous functions.
Use Array.reduce() with the spread operator (...) to perform left-to-right function composition using Promise.then(). The functions can return a combination of: simple values, Promise's, or they can be defined as async ones returning through await. All functions must be unary.
const sum =pipeAsyncFunctions(
x => x +1,
x =>newPromise(resolve =>setTimeout(()=>resolve(x +2),1000)),
x => x +3,
@@ -122,28 +116,28 @@ Object.assig
(async()=>{
console.log(awaitsum(5));// 15 (after one second)})();
-
pipeFunctions
Performs left-to-right function composition.
Use Array.reduce() with the spread operator (...) to perform left-to-right function composition. The first (leftmost) function can accept one or more arguments; the remaining functions must be unary.
Use Array.reduce() with the spread operator (...) to perform left-to-right function composition. The first (leftmost) function can accept one or more arguments; the remaining functions must be unary.