Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 16, 2020
1 parent e83061f commit 3190e5f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: node_js
node_js:
- '14'
- '12'
- '10'
- '8'
Expand Down
10 changes: 7 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ declare class Cycled<T> extends Array<T> {
```
import Cycled = require('cycled');
const numberCycle = new Cycled([1,2,3,4,5]);
const numberCycle = new Cycled([1, 2, 3, 4, 5]);
console.log(...numberCycle);
//=> 1 2 3 4 5
Expand Down Expand Up @@ -72,12 +72,16 @@ declare class Cycled<T> extends Array<T> {
previous(): T;

/**
Returns the item by going the given amount of `steps` through the array. For example, calling `step(2)` is like calling `next()` twice. You go backward by specifying a negative number.
Returns the item by going the given amount of `steps` through the array. For example, calling `step(2)` is like calling `next()` twice.
You go backward by specifying a negative number.
*/
step(steps: number): T;

/**
Returns the item that is located in the given amount of `steps` through the array. For example, calling `peek(2)` would get the item 2 items after the current one. You go backward by specifying a negative number.
Returns the item that is located in the given amount of `steps` through the array. For example, calling `peek(2)` would get the item 2 items after the current one.
You go backward by specifying a negative number.
This method is similar to `.step()` but without changing the current item.
*/
Expand Down
2 changes: 1 addition & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"description": "Cycle through the items of an array",
"license": "MIT",
"repository": "sindresorhus/cycled",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "[email protected]",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=6"
Expand Down
10 changes: 3 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# cycled [![Build Status](https://travis-ci.org/sindresorhus/cycled.svg?branch=master)](https://travis-ci.org/sindresorhus/cycled)
# cycled [![Build Status](https://travis-ci.com/sindresorhus/cycled.svg?branch=master)](https://travis-ci.com/github/sindresorhus/cycled)

> Cycle through the items of an array
This package can be useful for cycling through tabs, images of a slideshows, etc.

This package can be useful for cycling through tabs, images of slideshows, etc.

## Install

```
$ npm install cycled
```


## Usage

```js
Expand All @@ -35,7 +33,6 @@ cycled.previous();
//=> 3
```


## API

### `cycled = new Cycled(array)`
Expand All @@ -53,7 +50,7 @@ The array to wrap.
The instance is an iterable that will cycle through the array. It will cycle through the number of elements equaling the length of the array from the current index.

```js
const numberCycle = new Cycled([1,2,3,4,5]);
const numberCycle = new Cycled([1, 2, 3, 4, 5]);

console.log(...numberCycle);
//=> 1 2 3 4 5
Expand Down Expand Up @@ -93,7 +90,6 @@ Returns an iterable that will cycle through the array indefinitely.

Returns an iterable that will cycle through the array backward indefinitely.


## Example

Here we create a simple tab component that can have the active view set or go forward/backward through the tabs.
Expand Down

0 comments on commit 3190e5f

Please sign in to comment.