Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chinsun9/time-based-sequence-character
get time based sequential string
https://github.com/chinsun9/time-based-sequence-character
sequence time-based
Last synced: about 1 month ago
JSON representation
get time based sequential string
- Host: GitHub
- URL: https://github.com/chinsun9/time-based-sequence-character
- Owner: chinsun9
- License: mit
- Created: 2021-09-24T06:26:41.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-08T02:12:43.000Z (over 2 years ago)
- Last Synced: 2024-04-25T04:02:38.816Z (8 months ago)
- Topics: sequence, time-based
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/time-based-sequence-character
- Size: 134 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# time-based-sequence-character
> 시간 베이스로 문자열 반환
- 매시간마다 애국가 한 음절을 반환합니다
- 기준 시간은 `2021. 9. 24. 오후 5:46:16`로부터 시작합니다## Install
```sh terminal
npm install time-based-sequence-character
```## Usage
```ts example.ts
// example
import { getTimeBasedCharacter } from 'time-based-sequence-character';// 한 시간마다 애국가 한 음절을 반환
const char = getTimeBasedCharacter(new Date().getTime());
console.log({ char });
``````ts custom example.ts
// 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' ] }
```