Skip to content

Commit

Permalink
Merge branch 'master' into more-test-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens authored Feb 4, 2024
2 parents 58d0df6 + c7eee05 commit af62dc9
Show file tree
Hide file tree
Showing 32 changed files with 1,366 additions and 493 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: feross
tidelift: npm/buffer
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Tests

on:
push:
branches:
- main
pull_request:

jobs:
unit:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# see https://nodejs.org/en/about/releases/
node-version: [16.x, 18.x, 20.x]

steps:
- 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
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.airtap.yml
.github/
bin/
perf/
test/
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

26 changes: 26 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,31 @@
- adventure-yunfei ([email protected])
- Emil Bay ([email protected])
- Sam Sudar ([email protected])
- Volker Mische ([email protected])
- David Walton ([email protected])
- Сковорода Никита Андреевич ([email protected])
- greenkeeper[bot] (greenkeeper[bot]@users.noreply.github.com)
- ukstv ([email protected])
- Renée Kooi ([email protected])
- ranbochen ([email protected])
- Vladimir Borovik ([email protected])
- greenkeeper[bot] (23040076+greenkeeper[bot]@users.noreply.github.com)
- kumavis ([email protected])
- Sergey Ukustov ([email protected])
- Fei Liu ([email protected])
- Blaine Bublitz ([email protected])
- clement ([email protected])
- Koushik Dutta ([email protected])
- Jordan Harband ([email protected])
- Niklas Mischkulnig ([email protected])
- Nikolai Vavilov ([email protected])
- Fedor Nezhivoi ([email protected])
- shuse2 ([email protected])
- Peter Newman ([email protected])
- mathmakgakpak ([email protected])
- jkkang ([email protected])
- Deklan Webster ([email protected])
- Martin Heidegger ([email protected])
- junderw ([email protected])

#### Generated by bin/update-authors.sh.
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
# buffer [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]

[travis-image]: https://img.shields.io/travis/feross/buffer/master.svg
[travis-url]: https://travis-ci.org/feross/buffer
[ci-image]: https://img.shields.io/github/workflow/status/feross/buffer/ci/master
[ci-url]: https://github.com/feross/buffer/actions
[npm-image]: https://img.shields.io/npm/v/buffer.svg
[npm-url]: https://npmjs.org/package/buffer
[downloads-image]: https://img.shields.io/npm/dm/buffer.svg
[downloads-url]: https://npmjs.org/package/buffer
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com

#### The buffer module from [node.js](https://nodejs.org/), for the browser.
#### The buffer module from [node.js](https://nodejs.org), for the browser.

[![saucelabs][saucelabs-image]][saucelabs-url]

Expand All @@ -28,13 +28,12 @@ instance methods, and class methods that are supported.
- Manipulate binary data like a boss, in all browsers!
- 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 9+, IE 11, iOS 9+, Android, etc.)
- Preserves Node API exactly, with one minor difference (see below)
- Excellent browser support (Chrome, Firefox, Edge, Safari 11+, iOS 11+, Android, etc.)
- 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)


## install

To use this module directly (without browserify), install it:
Expand All @@ -46,8 +45,7 @@ npm install buffer
This module was previously called **native-buffer-browserify**, but please use **buffer**
from now on.

A standalone bundle is available [here](https://wzrd.in/standalone/buffer), for non-browserify users.

If you do not use a bundler, you can use the [standalone script](https://bundle.run/buffer).

## usage

Expand Down Expand Up @@ -149,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 @@ -378,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 All @@ -403,6 +401,9 @@ To test that the code conforms to the style, `npm install` and run:

This was originally forked from [buffer-browserify](https://github.com/toots/buffer-browserify).

## Security Policies and Procedures

The `buffer` team and community take all security bugs in `buffer` seriously. Please see our [security policies and procedures](https://github.com/feross/security) document to learn how to report issues.

## license

Expand Down
10 changes: 4 additions & 6 deletions bin/airtap-es6.yml → bin/airtap-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ browsers:
version: -1..latest
- name: firefox
version: -1..latest
- name: safari
version: 10..latest
# - name: safari
# version: 14..latest
- name: microsoftedge
version: -1..latest
- name: iphone
version:
- 10.3
- latest
# - name: iphone
# version: latest
6 changes: 2 additions & 4 deletions bin/airtap-es5.yml → bin/airtap-old.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
sauce_connect: true
loopback: airtap.local
browsers:
- name: ie
version: latest
- name: safari
version: 9
version: 11..13
- name: iphone
version: 9.3
version: 11.3
30 changes: 15 additions & 15 deletions bin/download-node-tests.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/usr/bin/env node

var concat = require('concat-stream')
var cp = require('child_process')
var fs = require('fs')
var hyperquest = require('hyperquest')
var path = require('path')
var split = require('split')
var through = require('through2')

var url = 'https://api.github.com/repos/nodejs/node/contents'
var dirs = [
const concat = require('concat-stream')
const cp = require('child_process')
const fs = require('fs')
const hyperquest = require('hyperquest')
const path = require('path')
const split = require('split')
const through = require('through2')

const url = 'https://api.github.com/repos/nodejs/node/contents'
const dirs = [
'/test/parallel',
'/test/pummel'
]

cp.execSync('rm -rf node/test-*.js', { cwd: path.join(__dirname, '../test') })

var httpOpts = {
const httpOpts = {
headers: {
'User-Agent': null
// auth if github rate-limits you...
Expand All @@ -25,7 +25,7 @@ var httpOpts = {
}

dirs.forEach(function (dir) {
var req = hyperquest(url + dir, httpOpts)
const req = hyperquest(url + dir, httpOpts)
req.pipe(concat(function (data) {
if (req.response.statusCode !== 200) {
throw new Error(url + dir + ': ' + data.toString())
Expand Down Expand Up @@ -57,7 +57,7 @@ function downloadBufferTests (dir, files) {

console.log(file.download_url)

var out = path.join(__dirname, '../test/node', file.name)
const out = path.join(__dirname, '../test/node', file.name)
hyperquest(file.download_url, httpOpts)
.pipe(split())
.pipe(testfixer(file.name))
Expand All @@ -69,14 +69,14 @@ function downloadBufferTests (dir, files) {
}

function testfixer (filename) {
var firstline = true
let firstline = true

return through(function (line, enc, cb) {
line = line.toString()

if (firstline) {
// require buffer explicitly
var preamble = 'var Buffer = require(\'../../\').Buffer;'
const preamble = 'var Buffer = require(\'../../\').Buffer;'
if (/use strict/.test(line)) line += '\n' + preamble
else line += preamble + '\n' + line
firstline = false
Expand Down
28 changes: 11 additions & 17 deletions bin/test.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
#!/usr/bin/env node

var cp = require('child_process')
var fs = require('fs')
var path = require('path')
const cp = require('child_process')
const fs = require('fs')
const path = require('path')

var shouldRunBrowserTests = !process.env.TRAVIS_PULL_REQUEST ||
process.env.TRAVIS_PULL_REQUEST === 'false'

var node = cp.spawn('npm', ['run', 'test-node'], { stdio: 'inherit' })
const node = cp.spawn('npm', ['run', 'test-node'], { stdio: 'inherit' })
node.on('close', function (code) {
if (code === 0 && shouldRunBrowserTests) {
runBrowserTests()
} else {
process.exit(code)
}
if (code !== 0) return process.exit(code)
runBrowserTests()
})

function runBrowserTests () {
var airtapYmlPath = path.join(__dirname, '..', '.airtap.yml')
const airtapYmlPath = path.join(__dirname, '..', '.airtap.yml')

writeES5AirtapYml()
cp.spawn('npm', ['run', 'test-browser-es5'], { stdio: 'inherit' })
cp.spawn('npm', ['run', 'test-browser-old'], { stdio: 'inherit' })
.on('close', function (code) {
if (code !== 0) process.exit(code)
writeES6AirtapYml()
cp.spawn('npm', ['run', 'test-browser-es6'], { stdio: 'inherit' })
cp.spawn('npm', ['run', 'test-browser-new'], { stdio: 'inherit' })
.on('close', function (code) {
process.exit(code)
})
})

function writeES5AirtapYml () {
fs.writeFileSync(airtapYmlPath, fs.readFileSync(path.join(__dirname, 'airtap-es5.yml')))
fs.writeFileSync(airtapYmlPath, fs.readFileSync(path.join(__dirname, 'airtap-old.yml')))
}

function writeES6AirtapYml () {
fs.writeFileSync(airtapYmlPath, fs.readFileSync(path.join(__dirname, 'airtap-es6.yml')))
fs.writeFileSync(airtapYmlPath, fs.readFileSync(path.join(__dirname, 'airtap-new.yml')))
}
}
Loading

0 comments on commit af62dc9

Please sign in to comment.