2.2.16 ā€¢ Published 7 months ago

@vangware/prompts v2.2.16

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Coverage License NPM Version Open Issues Size

ā‰ļø CLI interactive prompts. Can be used to wrap anything that matches the interface of node:readline/promises.

Usage

šŸ“¦ Node

Install @vangware/prompts as a dependency:

pnpm add @vangware/prompts
# or
npm install @vangware/prompts
# or
yarn add @vangware/prompts

Import it and use it:

import { question } from "@vangware/prompts";
import { createInterface } from "node:readline/promises";

const exampleQuestion = question(
	createInterface({
		input: process.stdin,
		output: process.stdout,
	}),
);

exampleQuestion({
	format: value => parseInt(value, 18),
	query: "How old are you?",
	validate: value => (value < 18 ? "You must be at least 18 years old." : ""),
})
	.then(console.log)
	.catch(console.error)
	.finally(() => readlineInterface.close());

šŸ¦• Deno

Import @vangware/prompts using the npm: prefix, and use it directly with the native prompt:

import { question } from "npm:@vangware/prompts";

const exampleQuestion = question({
	question: query => Promise.resolve(prompt(query)),
});

exampleQuestion({
	format: value => parseInt(value, 18),
	query: "How old are you?",
	validate: value => (value < 18 ? "You must be at least 18 years old." : ""),
})
	.then(console.log)
	.catch(console.error);

šŸŒŽ Browser

Import @vangware/prompts using esm.sh, and use it directly with the native prompt:

import { question } from "https://esm.sh/@vangware/prompts";

const exampleQuestion = question({
	question: query => Promise.resolve(prompt(query)),
});

exampleQuestion({
	format: value => parseInt(value, 18),
	query: "How old are you?",
	validate: value => (value < 18 ? "You must be at least 18 years old." : ""),
})
	.then(console.log)
	.catch(console.error);

Useful links

2.2.1

9 months ago

2.2.0

9 months ago

2.2.15

7 months ago

2.2.3

8 months ago

2.2.16

7 months ago

2.2.2

9 months ago

2.2.13

8 months ago

2.2.5

8 months ago

2.2.14

7 months ago

2.2.4

8 months ago

2.2.11

8 months ago

2.2.7

8 months ago

2.2.12

8 months ago

2.2.6

8 months ago

2.1.16

11 months ago

2.1.17

10 months ago

2.1.15

11 months ago

2.1.18

10 months ago

2.1.19

10 months ago

2.1.25

9 months ago

2.1.26

9 months ago

2.1.23

10 months ago

2.1.24

9 months ago

2.1.21

10 months ago

2.1.22

10 months ago

2.1.20

10 months ago

2.2.9

8 months ago

2.2.8

8 months ago

2.1.14

12 months ago

2.1.12

12 months ago

2.1.13

12 months ago

2.1.11

1 year ago

2.1.10

1 year ago

2.1.9

1 year ago

2.1.8

1 year ago

2.1.7

1 year ago

2.1.6

1 year ago

2.1.5

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.0

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago