open-index/open-npm huggingface dataset:
npm package: @hazae41/pendule
Description: Mnemonic derivation (BIP-39, Monero) for TypeScript
Author: hazae41
Latest version: 1.0.0

# Pendule

Time-based one-time passcodes (TOTP) for the web

```bash
npm install @hazae41/pendule
```

[**📦 NPM**](https://www.npmjs.com/package/@hazae41/pendule)

## Features

### Current features
- 100% TypeScript and ESM
- Minimal dependencies
- SHA-1 TOTP

## Usage

### SHA-1 TOTP

Parse generator secret

```tsx
const totp = Sha1Totp.parseOrThrow("JBSWY3DPEHPK3PXP")
```

Parse generator url

```tsx
const totp = Sha1Totp.parseOrThrow("otpauth://totp/?secret=AAAABBBB22223333YYYYZZZZ66667777")
```

### Codes

Generate the current code

```tsx
const code = await totp.generate()
```

Automatically update code (with a margin of error of 1 second)

```tsx
setInterval(() => {
  code = await totp.generate()
}, 1000)
```

Log codes every time there is a new one

```tsx
const period = totp.period * 1000

const elapsed = Date.now() % period

const remaining = period - elapsed

setTimeout(() => {
  console.log(await totp.generate())

  setInterval(() => {
    console.log(await totp.generate())
  }, period)

  // New codes will now be displayed
}, remaining)
```
npm package: @hazae41/phobos
Description: Modern and minimalist testing library
Author: hazae41
Latest version: 2.0.16

<div align="center">
<img width="500" src="https://user-images.githubusercontent.com/4405263/208164108-5be58f53-a29b-46b3-be90-3886f4afc32d.png" />
</div>
<h3 align="center">
Modern and minimalist testing library
</h3>

```bash
npm install @hazae41/phobos
```

```bash
deno install jsr:@hazae41/phobos
```

[**📦 NPM**](https://www.npmjs.com/package/@hazae41/phobos) • [**📦 JSR**](https://jsr.io/@hazae41/phobos)

## Philosophy 🧠

Phobos aims to be minimalist and to always work no matter the:
- runtime (Node, Deno, browser)
- module resolution (ESM, CommonJS)
- language (TypeScript, JavaScript)
- bundler (Rollup, Vite)

It's just a library you can import everywhere! That's it, no CLI, no configuration file, just JavaScript.

## Features 🔥

### Current features

- 100% TypeScript and ESM
- No external dependency
- Unit tested (by itself)
- Runnable in the browser
- Minimalist assertion helpers
- Asynchronous fork-join parallelism
- Function calls spying

## Usage 🚀

```typescript
import { assert, test } from "@hazae41/phobos"

test("it should work", () => {
  assert(false, "oh no")
})
```

### Concurrent tests

Test blocks are always executed concurrently, unless you `await` them

```typescript
import { assert, test } from "@hazae41/phobos"

test("it should work", async ({ test }) => {
  
  // run in sequence
  await test("first test", async () => {
    assert(true, "should be true")
  })
  
  // or in parallel
  test("second test", async () => {
    assert(true, "should be true")
  })
})
```

You can also use `await Promise.all(...)` to forcefully join

```typescript
import { assert, test } from "@hazae41/phobos"

test("it should work", async ({ test }) => {
  const tests = []
  
  tests.push(test("first test", async () => {
    assert(true, "should be true")
  }))
  
  tests.push(test("second test", async () => {
    assert(true, "should be true")
  }))

  // wait first and second tests
  await Promise.all(tests)

  tests.push(test("third test", async () => {
    assert(true, "should be true")
  }))

  // wait last test
  await Promise.all(tests)
})
```

### Spying function calls

You can spy on function calls using `spy(function)`

You can then `.call()` it and get a list of all its `.calls`

```typescript
import { assert, test, spy } from "@hazae41/phobos"

test("it should work", async () => {
  const f = spy((param: boolean) => !param)

  const result = f.call(true)
  assert(result === false, `result should be false`)

  assert(f.calls.length === 1, `should have been called 1 time`)
  assert(f.calls[0].params[0] === true, `should have been called with true`)
  assert(f.calls[0].result === false, `should have resulted in false`)
})
```

## Running 🏎️

#### Node

```bash
node --test --test-concurrency=1 ./out/**/*.test.js
```

#### Deno

```bash
deno test ./src/**/*.test.ts
```

#### Other

```typescript
await import("./mymodule.test.ts")
```