From a9327f091f6dc65f1f12fffee72a6ef1c787ce7e Mon Sep 17 00:00:00 2001 From: Muthu Kumar Date: Thu, 17 May 2018 01:19:57 +0530 Subject: [PATCH] [docs] Updated to show new [] accessor! --- README.md | 7 +++++++ utils/index.js | 2 ++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 9a17896..d995517 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,9 @@ const infinity = new InfiniteList(, ); // Gets item at index infinity.get(); +// Equivalent to the above! (Modern browsers and node only) +infinity[]; + // Returns array of given number of InfiniteListItems from index 0 infinity.take(); @@ -46,6 +49,7 @@ You can pass in any starting value. `infinity` cheerfully ignores what you pass `InfiniteList` is iterable. ```JavaScript +// (Modern browsers and node only) for (let item of infinity) { // Remember to have an exit condition console.log(item); @@ -67,6 +71,9 @@ log(fibonacci.take(10).map(x => x.value)); // -> [ 0, 1, 1, 2, 3, 5, 8, 13, 21, // What's the 50th item? log(fibonacci.get(50).value); // -> 12586269025 +// This is equivalent of the above! (modern browsers only!) +log(fibonacci[50].value); // -> 12586269025 + // What's the next item? log(fibonacci.get(50).next().value); // -> 20365011074 diff --git a/utils/index.js b/utils/index.js index 1d7460f..330109b 100644 --- a/utils/index.js +++ b/utils/index.js @@ -1,3 +1,5 @@ +'use strict'; + const JSON = require('./cycle'); const always = x => _ => x;