# simdle-universal

> Universal wrapper for libsimdle with a JavaScript fallback

Latest version **1.1.2** (published 2023-03-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install simdle-universal
pnpm add simdle-universal
yarn add simdle-universal
bun add simdle-universal
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2023-03-24 |
| First published | 2022-09-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 10 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Kasper Isager Dalsgarð |
| Maintainers | mafintosh, kasperisager |

## Links

- npm: https://www.npmjs.com/package/simdle-universal
- Repository: https://github.com/holepunchto/simdle-universal
- Homepage: https://github.com/holepunchto/simdle-universal#readme
- Issues: https://github.com/holepunchto/simdle-universal/issues
- npm.io page: https://npm.io/package/simdle-universal

## Dependencies (2)

- [b4a](https://npm.io/package/b4a.md) ^1.6.0
- [simdle-native](https://npm.io/package/simdle-native.md) ^1.1.1

## Recent versions

- 1.1.2 (latest) — 2023-03-24
- 1.1.1 — 2023-03-24
- 1.1.0 — 2022-10-10
- 1.0.4 — 2022-09-07
- 1.0.3 — 2022-09-07
- 1.0.2 — 2022-09-05
- 1.0.1 — 2022-09-05
- 1.0.0 — 2022-09-05

## README

# simdle-universal

Universal wrapper for https://github.com/holepunchto/libsimdle with a JavaScript fallback.

```sh
npm install simdle-universal
```

## Usage

```js
const { cnt } = require('simdle-universal')

cnt(Buffer.alloc(16, 0xff))
// <Buffer 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08>
```

## API

The lane width of all APIs is determined by the input buffer. That is, if providing a `Uint8Array` the lane width will be 8 bits, if providing a `Uint16Array` the lane width will be 16 bits and so on.

#### `const result = allo(buffer)`

Check if the buffer contains only ones.

#### `const result = allz(buffer)`

Check if the buffer contains only zeros.

#### `const result = and(a, b[, result])`

Compute the bitwise AND of `a` and `b`. If `result` is not provided, a fresh buffer is allocated. The `result` buffer is returned to the caller.

#### `const result = clear(a, b[, result])`

Clear the bits in `b` from `a`. If `result` is not provided, a fresh buffer is allocated. The `result` buffer is returned to the caller.

#### `const result = clo(buffer[, result])`

Count the number of leading ones in `buffer`, storing the result in `result`. If `result` is not provided, a fresh buffer is allocated. The `result` buffer is returned to the caller.

#### `const result = clz(buffer[, result])`

Count the number of leading zeroes in `buffer`, storing the result in `result`. If `result` is not provided, a fresh buffer is allocated. The `result` buffer is returned to the caller.

#### `const result = cnt(buffer[, result])`

Compute the population count in `buffer`, storing the result in `result`. If `result` is not provided, a fresh buffer is allocated. The `result` buffer is returned to the caller.

#### `const result = cto(buffer[, result])`

Count the number of trailing ones in `buffer`, storing the result in `result`. If `result` is not provided, a fresh buffer is allocated. The `result` buffer is returned to the caller.

#### `const result = ctz(buffer[, result])`

Count the number of trailing zeroes in `buffer`, storing the result in `result`. If `result` is not provided, a fresh buffer is allocated. The `result` buffer is returned to the caller.

#### `const result = not(buffer[, result])`

Compute the bitwise NOT in `buffer`, storing the result in `result`. If `result` is not provided, a fresh buffer is allocated. The `result` buffer is returned to the caller.

#### `const result = or(a, b[, result])`

Compute the bitwise OR of `a` and `b`. If `result` is not provided, a fresh buffer is allocated. The `result` buffer is returned to the caller.

#### `const result = sum(buffer)`

Compute the sum of `buffer` as a `bigint`.

#### `const result = xor(a, b[, result])`

Compute the bitwise XOR of `a` and `b`. If `result` is not provided, a fresh buffer is allocated. The `result` buffer is returned to the caller.

## License

ISC

---
_Source: https://npm.io/package/simdle-universal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
