1.0.2 • Published 2 years ago

pick-list v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years 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

2 years ago

1.0.1

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.1

2 years ago

1.0.0

8 years ago