1.0.2 • Published 11 months ago

pick-list v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

pick-list

Pick an item from a list in the terminal.

Features:

  • fuzzy matching algorithm
  • intelligent lazy choice loading

Install

npm install pick-list

Usage

supply choices as string array

import { pickList } from 'pick-list';

try {
  const answer = await pickList('favourite food', [
    'pizza',
    'sushi',
    'spaghetti',
    'lasagna',
    'babi pangang',
  ]);
  console.log(answer); // babi pangang
} catch(e) {
}

supply choices as complex array

import { pickList } from 'pick-list';

try {
  const answer = await pickList('favourite food', [
    { foodName:'pizza' },
    { foodName:'sushi' },
    { foodName:'spaghetti' },
    { foodName:'lasagna' },
    { foodName:'babi pangang' },
  ], 'foodName');
  console.log(answer); // { foodName: 'sushi' }
} catch(e) {
}

supply choices with async function

import { pickList } from 'pick-list';
import { quotes } from '../quotes.mjs';

try {
  const quote = await pickList('favourite quote', async(needle) => {
    await new Promise(ok => setTimeout(ok, 200));
    return quotes.filter(q => q.text.match(new RegExp(needle,'i')));
  },'text');
  console.log(quote); // { text: 'Action is eloquence.' }
} catch(e) {
}
1.0.2

11 months ago

1.0.1

11 months ago

0.4.0

12 months ago

0.3.1

12 months ago

0.3.0

12 months ago

0.2.0

12 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago

0.0.1

12 months ago

1.0.0

7 years ago