Skip to content

Commit f227633

Browse files
committed
Initial implementation, tests, readme
1 parent 5fa9933 commit f227633

16 files changed

+472
-38
lines changed

Diff for: .eslintrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"root": true,
3+
4+
"extends": "@ljharb",
5+
6+
"rules": {
7+
},
8+
}

Diff for: .github/FUNDING.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: [ljharb]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: npm/typed-array-length
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

Diff for: .github/workflows/node-aught.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: 'Tests: node.js < 10'
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
tests:
7+
uses: ljharb/actions/.github/workflows/node.yml@main
8+
with:
9+
range: '< 10'
10+
type: minors
11+
command: npm run tests-only
12+
13+
node:
14+
name: 'node < 10'
15+
needs: [tests]
16+
runs-on: ubuntu-latest
17+
steps:
18+
- run: 'echo tests completed'

Diff for: .github/workflows/node-pretest.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: 'Tests: pretest/posttest'
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
tests:
7+
uses: ljharb/actions/.github/workflows/pretest.yml@main

Diff for: .github/workflows/node-tens.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: 'Tests: node.js >= 10'
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
tests:
7+
uses: ljharb/actions/.github/workflows/node.yml@main
8+
with:
9+
range: '>= 10'
10+
type: minors
11+
command: npm run tests-only
12+
13+
node:
14+
name: 'node >= 10'
15+
needs: [tests]
16+
runs-on: ubuntu-latest
17+
steps:
18+
- run: 'echo tests completed'

Diff for: .github/workflows/rebase.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Automatic Rebase
2+
3+
on: [pull_request_target]
4+
5+
jobs:
6+
_:
7+
uses: ljharb/actions/.github/workflows/rebase.yml@main
8+
secrets:
9+
token: ${{ secrets.GITHUB_TOKEN }}

Diff for: .github/workflows/require-allow-edits.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Require “Allow Edits”
2+
3+
on: [pull_request_target]
4+
5+
jobs:
6+
_:
7+
name: "Require “Allow Edits”"
8+
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: ljharb/require-allow-edits@main

Diff for: .gitignore

+7-31
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ npm-debug.log*
55
yarn-debug.log*
66
yarn-error.log*
77
lerna-debug.log*
8-
.pnpm-debug.log*
98

109
# Diagnostic reports (https://nodejs.org/api/report.html)
1110
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@@ -42,8 +41,8 @@ build/Release
4241
node_modules/
4342
jspm_packages/
4443

45-
# Snowpack dependency directory (https://snowpack.dev/)
46-
web_modules/
44+
# TypeScript v1 declaration files
45+
typings/
4746

4847
# TypeScript cache
4948
*.tsbuildinfo
@@ -54,9 +53,6 @@ web_modules/
5453
# Optional eslint cache
5554
.eslintcache
5655

57-
# Optional stylelint cache
58-
.stylelintcache
59-
6056
# Microbundle cache
6157
.rpt2_cache/
6258
.rts2_cache_cjs/
@@ -72,41 +68,29 @@ web_modules/
7268
# Yarn Integrity file
7369
.yarn-integrity
7470

75-
# dotenv environment variable files
71+
# dotenv environment variables file
7672
.env
77-
.env.development.local
78-
.env.test.local
79-
.env.production.local
80-
.env.local
73+
.env.test
8174

8275
# parcel-bundler cache (https://parceljs.org/)
8376
.cache
84-
.parcel-cache
8577

8678
# Next.js build output
8779
.next
88-
out
8980

9081
# Nuxt.js build / generate output
9182
.nuxt
9283
dist
9384

9485
# Gatsby files
9586
.cache/
96-
# Comment in the public line in if your project uses Gatsby and not Next.js
87+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
9788
# https://nextjs.org/blog/next-9-1#public-directory-support
9889
# public
9990

10091
# vuepress build output
10192
.vuepress/dist
10293

103-
# vuepress v2.x temp and cache directory
104-
.temp
105-
.cache
106-
107-
# Docusaurus cache and generated files
108-
.docusaurus
109-
11094
# Serverless directories
11195
.serverless/
11296

@@ -119,17 +103,9 @@ dist
119103
# TernJS port file
120104
.tern-port
121105

122-
# Stores VSCode versions used for testing VSCode extensions
123-
.vscode-test
124-
125-
# yarn v2
126-
.yarn/cache
127-
.yarn/unplugged
128-
.yarn/build-state.yml
129-
.yarn/install-state.gz
130-
.pnp.*
131-
132106
# Only apps should have lockfiles
133107
npm-shrinkwrap.json
134108
package-lock.json
135109
yarn.lock
110+
111+
.npmignore

Diff for: .npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
package-lock=false
2+
allow-same-version=true
3+
message=v%s

Diff for: .nycrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"all": true,
3+
"check-coverage": false,
4+
"reporter": ["text-summary", "text", "html", "json"],
5+
"lines": 86,
6+
"statements": 85.93,
7+
"functions": 82.43,
8+
"branches": 76.06,
9+
"exclude": [
10+
"coverage",
11+
"test"
12+
]
13+
}

Diff for: CHANGELOG.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [v1.0.4](https://github.com/inspect-js/typed-array-length/compare/v1.0.3...v1.0.4) - 2022-05-23
9+
10+
### Commits
11+
12+
- [actions] reuse common workflows [`dfd4a37`](https://github.com/inspect-js/typed-array-length/commit/dfd4a37d851a28e3d74d892a69874e02f2e58c37)
13+
- [meta] use `npmignore` to autogenerate an npmignore file [`a837e80`](https://github.com/inspect-js/typed-array-length/commit/a837e80d4029f26785ab9f3aa571ca782ac8e851)
14+
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `is-callable`, `object-inspect`, `tape` [`7b05a87`](https://github.com/inspect-js/typed-array-length/commit/7b05a8772af399e52bb448618a246cd34d3e3273)
15+
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `object-inspect`, `tape` [`c495f6e`](https://github.com/inspect-js/typed-array-length/commit/c495f6e050a4a7463a82c9195f31f44cf2760945)
16+
- [meta] simplify "exports" [`e42a6b6`](https://github.com/inspect-js/typed-array-length/commit/e42a6b6b0dc243fce32df20a75a7962782ef2a83)
17+
- [Fix] ensure `for-each` dependency is properly listed [`8ec761c`](https://github.com/inspect-js/typed-array-length/commit/8ec761ca56c13927281d626958a2f55211e14f45)
18+
- [Deps] update `call-bind`, `is-typed-array` [`2cc173a`](https://github.com/inspect-js/typed-array-length/commit/2cc173a4216e167db896bea7b8e03edf8b2d3833)
19+
- [meta] add `safe-publish-latest` [`e8e3afa`](https://github.com/inspect-js/typed-array-length/commit/e8e3afa431ce98bbdbb68c9f8e3c029cc5128c6c)
20+
- [Deps] update `is-typed-array` [`cd8084d`](https://github.com/inspect-js/typed-array-length/commit/cd8084db59b734ac4519b6d47f96233b6f73b1a6)
21+
22+
## [v1.0.3](https://github.com/inspect-js/typed-array-length/compare/v1.0.2...v1.0.3) - 2020-12-05
23+
24+
### Commits
25+
26+
- [Tests] migrate tests to Github Actions [`a578b83`](https://github.com/inspect-js/typed-array-length/commit/a578b83e68055c1e7c7120bc4583e1d6926fc268)
27+
- [meta] avoid publishing github workflows [`f064a4b`](https://github.com/inspect-js/typed-array-length/commit/f064a4bf9090202154249d969be0799c34804ad4)
28+
- [Tests] run `nyc` on all tests [`69b841e`](https://github.com/inspect-js/typed-array-length/commit/69b841e43042358c71c3290342514b6d107f08d1)
29+
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `object-inspect`, `tape` [`4594e83`](https://github.com/inspect-js/typed-array-length/commit/4594e83250579cdbff870aa951e7af56ca169489)
30+
- [actions] add "Allow Edits" workflow [`81e953b`](https://github.com/inspect-js/typed-array-length/commit/81e953ba6b3f59c5657e0d17fa1e7619b94891f5)
31+
- [Deps] update `is-typed-array`; use `call-bind` instead of `es-abstract` [`e7da56b`](https://github.com/inspect-js/typed-array-length/commit/e7da56b3c03b7f0db9bb110444ec1ccf19d7e9f9)
32+
- [readme] remove travis badge [`6d610d8`](https://github.com/inspect-js/typed-array-length/commit/6d610d83cb78ac5286c5ca273f4b3c7289f7686e)
33+
- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`2d0ad64`](https://github.com/inspect-js/typed-array-length/commit/2d0ad644a11f754e61b49d327fdf891605abbe58)
34+
35+
## [v1.0.2](https://github.com/inspect-js/typed-array-length/compare/v1.0.1...v1.0.2) - 2020-04-22
36+
37+
### Commits
38+
39+
- [Dev Deps] update `make-arrow-function`, `make-generator-function` [`4facf69`](https://github.com/inspect-js/typed-array-length/commit/4facf697cafb36b9c1057dc4ca1a21d8550c564e)
40+
- [Deps] update `is-typed-array`, `es-abstract` [`aaf3585`](https://github.com/inspect-js/typed-array-length/commit/aaf3585429896b9520dedd886c07aa4a96b50615)
41+
- [Dev Deps] update `aud`, `auto-changelog` [`f10e298`](https://github.com/inspect-js/typed-array-length/commit/f10e298c7733b8de59231c1581c9b000c205edbd)
42+
- [meta] allow `package.json` to be required/imported [`104f4c6`](https://github.com/inspect-js/typed-array-length/commit/104f4c6a6363e600d54aeb7abd90e37d99693aaf)
43+
- [Tests] only audit prod deps [`c748ab5`](https://github.com/inspect-js/typed-array-length/commit/c748ab596de505483df14ca7eeda7f27aeb20383)
44+
- [Deps] update `es-abstract` [`6cd213e`](https://github.com/inspect-js/typed-array-length/commit/6cd213ec654da3325abc8190f8c07c860474d944)
45+
- [Dev Deps] update `tape` [`2b0b2ea`](https://github.com/inspect-js/typed-array-length/commit/2b0b2ea9be106e8a068597c3f499ef703cce1edb)
46+
- [Dev Deps] update `@ljharb/eslint-config` [`cf462f3`](https://github.com/inspect-js/typed-array-length/commit/cf462f3352cf2fd592e624746371e3de800a265d)
47+
- [Deps] update `is-typed-array` [`ff46995`](https://github.com/inspect-js/typed-array-length/commit/ff469955b5d92942ba066c77eac7467e0c4de1ec)
48+
49+
## [v1.0.1](https://github.com/inspect-js/typed-array-length/compare/v1.0.0...v1.0.1) - 2020-01-19
50+
51+
### Commits
52+
53+
- readme [`d3643fd`](https://github.com/inspect-js/typed-array-length/commit/d3643fd11919844b1f42041ef980a1f33215b515)
54+
- [meta] fix "exports" field [`006e28b`](https://github.com/inspect-js/typed-array-length/commit/006e28b30b11f8948e607d13ef0e96c3d7d7f61f)
55+
56+
## v1.0.0 - 2020-01-18
57+
58+
### Commits
59+
60+
- Initial commit [`5f9e2ec`](https://github.com/inspect-js/typed-array-length/commit/5f9e2ec6650f80dc894e354e9e98181b09006346)
61+
- Tests [`6b9cadb`](https://github.com/inspect-js/typed-array-length/commit/6b9cadb0c274933bc7ee5e3fc6a5a380163cbe76)
62+
- Implementation [`6a3cb50`](https://github.com/inspect-js/typed-array-length/commit/6a3cb50429f40fc4ac9020bbf9539560c1b70213)
63+
- npm init [`41d42cd`](https://github.com/inspect-js/typed-array-length/commit/41d42cddfd3d47df6c9d480cf77787eae1109432)
64+
- [meta] add `auto-changelog` [`4fd159b`](https://github.com/inspect-js/typed-array-length/commit/4fd159bc6535e86c370a2186d60a68656f0d8917)
65+
- [meta] add `funding` field; create FUNDING.yml [`6a9fca7`](https://github.com/inspect-js/typed-array-length/commit/6a9fca7e0fdf3ff3fd4b0f18596471ca3d050a39)
66+
- [actions] add automatic rebasing / merge commit blocking [`8303296`](https://github.com/inspect-js/typed-array-length/commit/83032967b14afd37c382d4bf2c1fc5c95e3764bd)
67+
- [Tests] add `npm run lint` [`47a9c21`](https://github.com/inspect-js/typed-array-length/commit/47a9c211f474dbe8528f6b28f50080eacd5bf7eb)
68+
- [Tests] use shared travis-ci configs [`d0c8915`](https://github.com/inspect-js/typed-array-length/commit/d0c89153e1c50f1eadd0b42521bcdcf3366b8af5)
69+
- Only apps should have lockfiles [`3eaef9c`](https://github.com/inspect-js/typed-array-length/commit/3eaef9cd192b1a25d1930739e7c0044e39ad3c0d)

Diff for: LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Inspect JS
3+
Copyright (c) 2020 Inspect JS
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Diff for: README.md

+70-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,70 @@
1-
# typed-array-byte-offset
2-
Robustly get the byte offset of a Typed Array.
1+
# typed-array-byte-offset <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
2+
3+
[![github actions][actions-image]][actions-url]
4+
[![coverage][codecov-image]][codecov-url]
5+
[![License][license-image]][license-url]
6+
[![Downloads][downloads-image]][downloads-url]
7+
8+
[![npm badge][npm-badge-png]][package-url]
9+
10+
Robustly get the byte offset of a Typed Array, or `false` if it is not a Typed Array. Works cross-realm, in every engine, even if the `byteOffset` property is overridden.
11+
12+
## Example
13+
14+
```js
15+
var typedArrayByteOffset = require('typed-array-byte-offset');
16+
var assert = require('assert');
17+
18+
assert.equal(false, typedArrayByteOffset(undefined));
19+
assert.equal(false, typedArrayByteOffset(null));
20+
assert.equal(false, typedArrayByteOffset(false));
21+
assert.equal(false, typedArrayByteOffset(true));
22+
assert.equal(false, typedArrayByteOffset([]));
23+
assert.equal(false, typedArrayByteOffset({}));
24+
assert.equal(false, typedArrayByteOffset(/a/g));
25+
assert.equal(false, typedArrayByteOffset(new RegExp('a', 'g')));
26+
assert.equal(false, typedArrayByteOffset(new Date()));
27+
assert.equal(false, typedArrayByteOffset(42));
28+
assert.equal(false, typedArrayByteOffset(NaN));
29+
assert.equal(false, typedArrayByteOffset(Infinity));
30+
assert.equal(false, typedArrayByteOffset(new Number(42)));
31+
assert.equal(false, typedArrayByteOffset('foo'));
32+
assert.equal(false, typedArrayByteOffset(Object('foo')));
33+
assert.equal(false, typedArrayByteOffset(function () {}));
34+
assert.equal(false, typedArrayByteOffset(function* () {}));
35+
assert.equal(false, typedArrayByteOffset(x => x * x));
36+
assert.equal(false, typedArrayByteOffset([]));
37+
38+
const buffer = new ArrayBuffer(32);
39+
40+
assert.equal(8, typedArrayByteOffset(new Int8Array(buffer, 8)));
41+
assert.equal(8, typedArrayByteOffset(new Uint8Array(buffer, 8)));
42+
assert.equal(8, typedArrayByteOffset(new Uint8ClampedArray(buffer, 8)));
43+
assert.equal(4, typedArrayByteOffset(new Int16Array(buffer, 4)));
44+
assert.equal(4, typedArrayByteOffset(new Uint16Array(buffer, 4)));
45+
assert.equal(8, typedArrayByteOffset(new Int32Array(buffer, 8)));
46+
assert.equal(8, typedArrayByteOffset(new Uint32Array(buffer, 8)));
47+
assert.equal(16, typedArrayByteOffset(new Float32Array(buffer, 16)));
48+
assert.equal(16, typedArrayByteOffset(new Float64Array(buffer, 16)));
49+
assert.equal(16, typedArrayByteOffset(new BigInt64Array(buffer, 16)));
50+
assert.equal(16, typedArrayByteOffset(new BigUint64Array(buffer, 16)));
51+
```
52+
53+
## Tests
54+
Simply clone the repo, `npm install`, and run `npm test`
55+
56+
[package-url]: https://npmjs.org/package/typed-array-byte-offset
57+
[npm-version-svg]: https://versionbadg.es/inspect-js/typed-array-byte-offset.svg
58+
[deps-svg]: https://david-dm.org/inspect-js/typed-array-byte-offset.svg
59+
[deps-url]: https://david-dm.org/inspect-js/typed-array-byte-offset
60+
[dev-deps-svg]: https://david-dm.org/inspect-js/typed-array-byte-offset/dev-status.svg
61+
[dev-deps-url]: https://david-dm.org/inspect-js/typed-array-byte-offset#info=devDependencies
62+
[npm-badge-png]: https://nodei.co/npm/typed-array-byte-offset.png?downloads=true&stars=true
63+
[license-image]: https://img.shields.io/npm/l/typed-array-byte-offset.svg
64+
[license-url]: LICENSE
65+
[downloads-image]: https://img.shields.io/npm/dm/typed-array-byte-offset.svg
66+
[downloads-url]: https://npm-stat.com/charts.html?package=typed-array-byte-offset
67+
[codecov-image]: https://codecov.io/gh/inspect-js/typed-array-byte-offset/branch/main/graphs/badge.svg
68+
[codecov-url]: https://app.codecov.io/gh/inspect-js/typed-array-byte-offset/
69+
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/typed-array-byte-offset
70+
[actions-url]: https://github.com/inspect-js/typed-array-byte-offset/actions

0 commit comments

Comments
 (0)