time-based-sequence-character
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

time-based-sequence-character

시간 베이스로 문자열 반환

  • 매시간마다 애국가 한 음절을 반환합니다
  • 기준 시간은 2021. 9. 24. 오후 5:46:16로부터 시작합니다

Install

npm install time-based-sequence-character

Usage

// example
import { getTimeBasedCharacter } from 'time-based-sequence-character';

// 한 시간마다 애국가 한 음절을 반환
const char = getTimeBasedCharacter(new Date().getTime());
console.log({ char });
// custom example
import { TimeBasedSequenceCharacter } from 'time-based-sequence-character';

// 현재 시간을 기준으로 10초마다 '0', '1', '0', '1', '0', '1',...
const curTime = new Date().getTime();
const tbsc = new TimeBasedSequenceCharacter({
  baseTime: curTime,
  gap: 10,
  arr: ['0', '1'],
});
const char = tbsc.getTimeBasedCharacter(curTime);
console.log({ char }); // { char: '0' }

const postChars = [1, 2, 3, 4, 5]
  .map((v) => v * 10 * 1000 + curTime)
  .map((time) => tbsc.getTimeBasedCharacter(time));
console.log({ postChars }); // { postChars: [ '1', '0', '1', '0', '1' ] }

Readme

Keywords

Package Sidebar

Install

npm i time-based-sequence-character

Weekly Downloads

1

Version

2.0.1

License

MIT

Unpacked Size

9.22 kB

Total Files

13

Last publish

Collaborators

  • chinsung