Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "move-sort", | ||
"version": "1.0.0", | ||
"description": "Switch an array item's index and get a new sorted array.", | ||
"main": "dist/move-sort.cjs.js", | ||
"module": "dist/move-sort.es.js", | ||
"unpkg": "dist/move-sort.min.js", | ||
"version": "1.1.0", | ||
"repository": "https://github.com/syropian/move-sort", | ||
"author": "Collin Henderson <collin@syropia.net>", | ||
"license": "MIT", | ||
"files": [ | ||
"dist" | ||
], | ||
"repository": "https://github.com/syropian/move-sort", | ||
"author": "Collin Henderson <collin@syropia.net>", | ||
"license": "MIT", | ||
"main": "./dist/move-sort.cjs", | ||
"module": "./dist/move-sort.mjs", | ||
"exports": { | ||
".": { | ||
"require": "./dist/move-sort.cjs", | ||
"import": "./dist/move-sort.mjs" | ||
} | ||
}, | ||
"types": "./dist/index.d.ts", | ||
"scripts": { | ||
"build": "bili", | ||
"test": "jest", | ||
"watch-test": "jest --watchAll" | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"test": "vitest run", | ||
"test:watch": "vitest", | ||
"lint": "eslint --ext .ts --ignore-path .gitignore ./src ./test --fix", | ||
"format": "prettier ./src ./test -w -u" | ||
}, | ||
"bili": { | ||
"format": [ | ||
"cjs", | ||
"umd-min", | ||
"es" | ||
], | ||
"moduleName": "MoveSort" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.0.0-beta.44", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.44", | ||
"babel-core": "^7.0.0-0", | ||
"babel-jest": "^22.4.3", | ||
"babel-preset-env": "^1.6.1", | ||
"bili": "^3.0.15", | ||
"jest": "^22.4.3" | ||
"@types/node": "^18.7.23", | ||
"@typescript-eslint/eslint-plugin": "^5.38.1", | ||
"@typescript-eslint/parser": "^5.38.1", | ||
"eslint": "^8.24.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"prettier": "^2.7.1", | ||
"typescript": "^4.6.4", | ||
"vite": "^3.1.0", | ||
"vite-plugin-dts": "^1.6.4", | ||
"vitest": "^0.23.4" | ||
} | ||
} |
@@ -1,5 +0,3 @@ | ||
# move-sort | ||
# move-sort [![Tests](https://github.com/syropian/move-sort/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/syropian/move-sort/actions/workflows/test.yml) | ||
[![Build Status](https://travis-ci.org/syropian/move-sort.svg?branch=master)](https://travis-ci.org/syropian/move-sort) | ||
> Switch an array item's index and get a new sorted array. | ||
@@ -10,12 +8,6 @@ | ||
``` | ||
$ yarn add move-sort | ||
``` | ||
or | ||
``` | ||
$ npm install move-sort --save | ||
``` | ||
**or** include the UMD build, hosted by [unpkg](https://unpkg.com) in a `<script>` tag. | ||
**or** include it in a `<script>` tag, hosted by [unpkg](https://unpkg.com). | ||
@@ -28,6 +20,6 @@ ```js | ||
```js | ||
// ES6 (check out the tests for more examples) | ||
import moveSort from "move-sort" | ||
const items = ["a", "b", "c", "d", "e"] | ||
```ts | ||
import moveSort from 'move-sort' | ||
const items = ['a', 'b', 'c', 'd', 'e'] | ||
const sortedItems = moveSort(items, 4, 0) | ||
@@ -38,13 +30,4 @@ | ||
```js | ||
// Browser (include the UMD build in a <script> tag as shown above) | ||
const items = ["a", "b", "c", "d", "e"] | ||
const sortedItems = MoveSort(items, 1, 3) | ||
// or | ||
const sortedItems = window.MoveSort(items, 1, 3) | ||
console.log(sortedItems) // returns ["a", "c", "d", "b", "e"] | ||
``` | ||
**Note:** `move-sort` always returns a new array, and does not mutate the original array you pass into it. | ||
**Note:** `move-sort` always generates a new array, and will never mutate the original array you pass into it. | ||
## API | ||
@@ -56,6 +39,4 @@ | ||
Type: `Array` | ||
Type: `T extends any[]` | ||
Default: `[]` | ||
The original array you want to generate a sorted array for. | ||
@@ -65,6 +46,4 @@ | ||
Type: `integer` | ||
Type: `number` | ||
Default: `0` | ||
The index of the inital element in the array you want to move. | ||
@@ -74,6 +53,4 @@ | ||
Type: `integer` | ||
Type: `number` | ||
Default: `0` | ||
The target index of the inital element in the array you want to move it to. | ||
@@ -83,3 +60,3 @@ | ||
The start and end index arguments are run through `parseInt()` and clamped to the bounds of the `items` array. Indexes less than `0` will become `0` and indexes greater than `(items.length - 1)` will become `(items.length - 1)`. | ||
The start and end index arguments are clamped to the bounds of the `items` array. Indexes less than `0` will become `0` and indexes greater than `(items.length - 1)` will become `(items.length - 1)`. | ||
@@ -90,8 +67,8 @@ ## Development | ||
# To run the tests | ||
$ npm test | ||
$ pnpm test | ||
# or | ||
$ npm run watch-test | ||
$ pnpm run test:watch | ||
# To publish the dist files | ||
$ npm run build | ||
$ pnpm run build | ||
``` | ||
@@ -98,0 +75,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8
4595
11
22
71