Skip to content

Commit

Permalink
spec: test in bun
Browse files Browse the repository at this point in the history
  • Loading branch information
zbjornson committed Sep 18, 2023
1 parent e8223f5 commit d22412b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ trim_trailing_whitespace = false
[*.gyp]
indent_style = space
indent_size = 2

[*.yaml]
indent_style = space
indent_size = 2
24 changes: 22 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Test
on: [push, pull_request]

jobs:
Test:
name: Test
Test_Nodejs:
name: Test Node.js
runs-on: ${{ matrix.platform }}
strategy:
matrix:
Expand All @@ -18,3 +18,23 @@ jobs:
run: npm install
- name: Test
run: npm test

Test_Bun:
name: Test Bun
runs-on: ${{ matrix.platform }}
strategy:
matrix:
bun: [latest]
platform: [ubuntu-latest, macos-latest]
steps:
- uses: oven-sh/setup-bun@v1
with:
bun-version: ${{ matrix.bun }}
- uses: actions/checkout@v3
- name: Install
run: |
bun install -g node-gyp
bun install
node-gyp rebuild
- name: Test
run: bun run test
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ x86: ![x86 Build Status](https://github.com/zbjornson/node-bswap/actions/workflo
ARM: [![ARM Build Status](https://cloud.drone.io/api/badges/zbjornson/node-bswap/status.svg)](https://cloud.drone.io/zbjornson/node-bswap)

The fastest function to swap bytes (a.k.a. reverse the byte ordering, change
endianness) of TypedArrays in-place for Node.js and browsers. Uses SIMD when
available. Works with all of the TypedArray types, including BigUint64Array and
BigInt64Array. Also works on Buffers if you construct a TypedArray view on the
underlying ArrayBuffer (see below).
endianness) of TypedArrays in-place for Node.js, Bun and browsers. Uses SIMD
when available. Works with all of the TypedArray types, including BigUint64Array
and BigInt64Array. Also works on Buffers if you construct a TypedArray view on
the underlying ArrayBuffer (see below).

Install:
```
$ npm install bswap
$ bun install bswap # but see https://bun.sh/guides/install/trusted
```

Use:
Expand All @@ -28,9 +29,9 @@ const ui32 = new Uint32Array(b.buffer, b.byteOffset, b.byteLength / Uint32Array.
bswap(ui32);
```

In Node.js when native code and a recent x86 or ARM processor is available, this
library uses the fastest available SIMD instructions ([PSHUFB (SSSE3) or VPSHUFB
(AVX2)](http://www.felixcloutier.com/x86/PSHUFB.html), [REVn
In Node.js/Bun when native code and a recent x86 or ARM processor is available,
this library uses the fastest available SIMD instructions ([PSHUFB (SSSE3) or
VPSHUFB (AVX2)](http://www.felixcloutier.com/x86/PSHUFB.html), [REVn
(NEON)](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489h/Cihjgdid.html)),
which process multiple array elements simultaneously.

Expand Down

0 comments on commit d22412b

Please sign in to comment.