From ce9b670707aa2b7f419d6a52486f9910cdababd2 Mon Sep 17 00:00:00 2001 From: tommy-mitchell Date: Tue, 2 Jan 2024 01:37:26 -0600 Subject: [PATCH] update `inclusive` example --- index.d.ts | 9 +++++++-- readme.md | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 136a131..0d7ab39 100644 --- a/index.d.ts +++ b/index.d.ts @@ -24,6 +24,11 @@ export type Range = { Whether or not to include the end value in the range. @default false + @example + ``` + console.log(...getRange({start: 3, end: 5, inclusive: true})); + //=> [3, 4, 5] + ``` */ readonly inclusive?: boolean; }; @@ -51,8 +56,8 @@ range.next().value; range.next().value; //=> 2 -console.log(...getRange({start: 0, end: -5, step: -1, inclusive: true})); -//=> [0, -1, -2, -3, -4, -5] +console.log(...getRange({start: 0, end: -5, step: -1})); +//=> [0, -1, -2, -3, -4] ``` */ export default function getRange(range: Range): IterableIterator; diff --git a/readme.md b/readme.md index 8b4d98b..83defb6 100644 --- a/readme.md +++ b/readme.md @@ -33,8 +33,8 @@ range.next().value; range.next().value; //=> 2 -console.log(...getRange({start: 0, end: -5, step: -1, inclusive: true})); -//=> [0, -1, -2, -3, -4, -5] +console.log(...getRange({start: 0, end: -5, step: -1})); +//=> [0, -1, -2, -3, -4] ``` It can replace normal for-loops in many cases: @@ -84,3 +84,8 @@ Type: `boolean`\ Default: `false` Whether or not to include the end value in the range. + +```js +console.log(...getRange({start: 3, end: 5, inclusive: true})); +//=> [3, 4, 5] +```