Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from feross:master #4

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 31 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
name: ci
'on':
- push
- pull_request
name: Tests

on:
push:
branches:
- main
pull_request:

jobs:
test:
name: Node ${{ matrix.node }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
unit:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
node:
- '14'
# see https://nodejs.org/en/about/releases/
node-version: [16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ runner.node }}
- run: npm install
- run: npm run build --if-present
- run: npm test
- uses: actions/checkout@main
- uses: actions/setup-node@main
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test

standard:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@main
- uses: actions/setup-node@main
with:
# don't use lts/* to prevent hitting rate-limit
node-version: 20.x
- run: npm install
- run: npm run standard
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@
- jkkang ([email protected])
- Deklan Webster ([email protected])
- Martin Heidegger ([email protected])
- junderw ([email protected])

#### Generated by bin/update-authors.sh.
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,27 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Parts of this software are based on node.js:

Copyright Node.js contributors. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

See https://github.com/nodejs/node/blob/main/LICENSE for more information.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ instance methods, and class methods that are supported.
- Super fast. Backed by Typed Arrays (`Uint8Array`/`ArrayBuffer`, not `Object`)
- Extremely small bundle size (**6.75KB minified + gzipped**, 51.9KB with comments)
- Excellent browser support (Chrome, Firefox, Edge, Safari 11+, iOS 11+, Android, etc.)
- Preserves Node API exactly, with one minor difference (see below)
- Preserves Node API exactly
- Square-bracket `buf[4]` notation works!
- Does not modify any browser prototypes or put anything on `window`
- Comprehensive test suite (including all buffer tests from node.js core)
Expand Down Expand Up @@ -147,8 +147,8 @@ Alternatively, use the [`to-arraybuffer`](https://www.npmjs.com/package/to-array

See perf tests in `/perf`.

`BrowserBuffer` is the browser `buffer` module (this repo). `Uint8Array` is included as a
sanity check (since `BrowserBuffer` uses `Uint8Array` under the hood, `Uint8Array` will
`BrowserBuffer` is the browser `buffer` module (this repo). `Uint8Array` is included as an
additional check (since `BrowserBuffer` uses `Uint8Array` under the hood, `Uint8Array` will
always be at least a bit faster). Finally, `NodeBuffer` is the node.js buffer module,
which is included to compare against.

Expand Down Expand Up @@ -376,8 +376,8 @@ Then, to run tests in Node.js, run:

To test locally in a browser, you can run:

npm run test-browser-es5-local # For ES5 browsers that don't support ES6
npm run test-browser-es6-local # For ES6 compliant browsers
npm run test-browser-old-local # For ES5 browsers that don't support ES6
npm run test-browser-new-local # For ES6 compliant browsers

This will print out a URL that you can then open in a browser to run the tests, using [airtap](https://www.npmjs.com/package/airtap).

Expand Down
71 changes: 36 additions & 35 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class Buffer extends Uint8Array {
compare(otherBuffer: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
slice(start?: number, end?: number): Buffer;
subarray(start?: number, end?: number): Buffer;
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
Expand All @@ -16,45 +17,45 @@ export class Buffer extends Uint8Array {
readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readUInt8(offset: number, noAssert?: boolean): number;
readUInt16LE(offset: number, noAssert?: boolean): number;
readUInt16BE(offset: number, noAssert?: boolean): number;
readUInt32LE(offset: number, noAssert?: boolean): number;
readUInt32BE(offset: number, noAssert?: boolean): number;
readBigUInt64LE(offset: number): BigInt;
readBigUInt64BE(offset: number): BigInt;
readInt8(offset: number, noAssert?: boolean): number;
readInt16LE(offset: number, noAssert?: boolean): number;
readInt16BE(offset: number, noAssert?: boolean): number;
readInt32LE(offset: number, noAssert?: boolean): number;
readInt32BE(offset: number, noAssert?: boolean): number;
readBigInt64LE(offset: number): BigInt;
readBigInt64BE(offset: number): BigInt;
readFloatLE(offset: number, noAssert?: boolean): number;
readFloatBE(offset: number, noAssert?: boolean): number;
readDoubleLE(offset: number, noAssert?: boolean): number;
readDoubleBE(offset: number, noAssert?: boolean): number;
readUInt16LE(offset?: number, noAssert?: boolean): number;
readUInt16BE(offset?: number, noAssert?: boolean): number;
readUInt32LE(offset?: number, noAssert?: boolean): number;
readUInt32BE(offset?: number, noAssert?: boolean): number;
readBigUInt64LE(offset?: number): BigInt;
readBigUInt64BE(offset?: number): BigInt;
readInt8(offset?: number, noAssert?: boolean): number;
readInt16LE(offset?: number, noAssert?: boolean): number;
readInt16BE(offset?: number, noAssert?: boolean): number;
readInt32LE(offset?: number, noAssert?: boolean): number;
readInt32BE(offset?: number, noAssert?: boolean): number;
readBigInt64LE(offset?: number): BigInt;
readBigInt64BE(offset?: number): BigInt;
readFloatLE(offset?: number, noAssert?: boolean): number;
readFloatBE(offset?: number, noAssert?: boolean): number;
readDoubleLE(offset?: number, noAssert?: boolean): number;
readDoubleBE(offset?: number, noAssert?: boolean): number;
reverse(): this;
swap16(): Buffer;
swap32(): Buffer;
swap64(): Buffer;
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeBigUInt64LE(value: number, offset: number): BigInt;
writeBigUInt64BE(value: number, offset: number): BigInt;
writeInt8(value: number, offset: number, noAssert?: boolean): number;
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeBigInt64LE(value: number, offset: number): BigInt;
writeBigInt64BE(value: number, offset: number): BigInt;
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
writeUInt8(value: number, offset?: number, noAssert?: boolean): number;
writeUInt16LE(value: number, offset?: number, noAssert?: boolean): number;
writeUInt16BE(value: number, offset?: number, noAssert?: boolean): number;
writeUInt32LE(value: number, offset?: number, noAssert?: boolean): number;
writeUInt32BE(value: number, offset?: number, noAssert?: boolean): number;
writeBigUInt64LE(value: BigInt, offset?: number): number;
writeBigUInt64BE(value: BigInt, offset?: number): number;
writeInt8(value: number, offset?: number, noAssert?: boolean): number;
writeInt16LE(value: number, offset?: number, noAssert?: boolean): number;
writeInt16BE(value: number, offset?: number, noAssert?: boolean): number;
writeInt32LE(value: number, offset?: number, noAssert?: boolean): number;
writeInt32BE(value: number, offset?: number, noAssert?: boolean): number;
writeBigInt64LE(value: BigInt, offset?: number): number;
writeBigInt64BE(value: BigInt, offset?: number): number;
writeFloatLE(value: number, offset?: number, noAssert?: boolean): number;
writeFloatBE(value: number, offset?: number, noAssert?: boolean): number;
writeDoubleLE(value: number, offset?: number, noAssert?: boolean): number;
writeDoubleBE(value: number, offset?: number, noAssert?: boolean): number;
fill(value: any, offset?: number, end?: number): this;
indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
Expand Down
Loading