Skip to content

Commit

Permalink
docs: update docs for convertMultiple
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay-Karia committed Aug 18, 2024
1 parent 875b86a commit 0d6fcef
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,31 @@
## 📜 Docs

```js
import convert from 'npm-to-yarn'
import { convert, convertMultiple } from 'npm-to-yarn'

// or
// var convert = require('npm-to-yarn')

convert('npm install squirrelly', 'yarn')

// yarn add squirrelly

// one to many conversions
convertMultiple("npm i next", ["pnpm", "bun"])
// ["pnpm add next", "bun add next"]

// many to one
convertMultiple(["npm i eslint", "pnpm add react"], "yarn")
// ["yarn add eslint", "yarn add react"]

// many to many
convertMultiple(["bun add rollup", "npm i express"], ["yarn", "pnpm"])
/*
[
["yarn add rollup", "yarn add express"],
["pnpm add rollup", "pnpm add express"]
]
*/
```

`npm-to-yarn` exposes a UMD build, so you can also install it with a CDN (it exposes global variable `n2y`)
Expand All @@ -43,7 +60,8 @@ convert('npm install squirrelly', 'yarn')
/**
* Converts between npm and yarn command
*/
export default function convert (str: string, to: 'npm' | 'yarn' | 'pnpm' | 'bun'): string
export function convert (str: string, to: Command): string
export function convertMultiple = (str: string | string[], to: Command | Command[]): string[]
```

## ✔️ Tests
Expand Down
4 changes: 2 additions & 2 deletions dist/npm-to-yarn.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ function convert(str, to) {
return str.replace(/npm(?: +([^&\n\r]*))?/gm, npmToYarn);
}
}
var convertMultiple = function (str, to) {
function convertMultiple(str, to) {
var commands = [];
// one to many
if (typeof str === 'string' && Array.isArray(to)) {
Expand All @@ -655,7 +655,7 @@ var convertMultiple = function (str, to) {
});
}
return commands;
};
}

export { convert, convertMultiple };
//# sourceMappingURL=npm-to-yarn.mjs.map
2 changes: 1 addition & 1 deletion dist/npm-to-yarn.mjs.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/npm-to-yarn.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/npm-to-yarn.umd.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ type Command = 'npm' | 'yarn' | 'pnpm' | 'bun';
* Converts between npm and yarn command
*/
export declare function convert(str: string, to: 'npm' | 'yarn' | 'pnpm' | 'bun'): string;
export declare const convertMultiple: (str: string | string[], to: Command | Command[]) => string[];
export declare function convertMultiple(str: string | string[], to: Command | Command[]): string[];
export type { Command };
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function convert (str: string, to: 'npm' | 'yarn' | 'pnpm' | 'bun'): stri
}


export const convertMultiple = (str: string | string[], to: Command | Command[]): string[] => {
export function convertMultiple (str: string | string[], to: Command | Command[]): string[] {
const commands : string[] = []

// one to many
Expand Down

0 comments on commit 0d6fcef

Please sign in to comment.