Skip to content

Commit 8b24de0

Browse files
author
FiddlyDigital
committed
Changed Github Actions to used TrustedPublisher/OIDC for NPM Publishing
1 parent af862c1 commit 8b24de0

2 files changed

Lines changed: 68 additions & 11 deletions

File tree

.github/workflows/main.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,34 @@ on:
66
- main
77

88
permissions:
9-
contents: write
9+
id-token: write # Required for OIDC
10+
contents: read
1011

1112
jobs:
1213
publish:
1314
runs-on: ubuntu-latest
1415
steps:
1516
- name: Checkout the repository
16-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1718

1819
- name: Setup Node.js
19-
uses: actions/setup-node@v2
20+
uses: actions/setup-node@v4
2021
with:
2122
node-version: 20
23+
registry-url: 'https://registry.npmjs.org'
24+
25+
# Ensure npm 11.5.1 or later is installed
26+
- name: Update npm
27+
run: npm install -g npm@latest
2228

2329
- name: Install Package Dependencies
2430
run: npm ci
2531

2632
- name: Build the Package
27-
run: npm run build
33+
run: npm run build --if-present
2834

2935
- name: Run Tests
3036
run: npm run test
3137

3238
- name: Publish Package to NPM 🚀
33-
uses: JS-DevTools/npm-publish@v1
34-
with:
35-
token: ${{ secrets.NPM_TOKEN }}
36-
access: public
39+
run: npm publish

README.md

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,60 @@
11
# FastMap
22

3-
A simple 2D map that is optimized for performance.
3+
An simple alternative to 2D arrays, with comparative performance.
4+
5+
## Benefits:
6+
7+
- Memory Efficient
8+
- Built on a 1d array; Uses a single contiguous block of memory
9+
- Fewer object allocations = less garbage collection overhead
10+
- Better memory layout for very large maps
11+
12+
- Cleaner API and Type Safety
13+
- Single generic type: `FastMap<T>` vs `T[][]`
14+
- No need to manage nested array initialization
15+
- Consistent bounds checking across all operations (with safe Get/Set methods)
16+
17+
## Usage:
18+
19+
Let's be honest: If you're just storing simple data and don't need safety guarantees, _a 2D array is simpler_.
20+
21+
FastMap is best used for:
22+
- Game dev (tile maps, grids where safety + performance matter)
23+
- Image processing (pixel buffers)
24+
- Large grid simulations
25+
- Other cases where you want built-in bounds checking without manual if statements
26+
27+
## How to use:
28+
`npm install "@speakingsoftware/fastmap"`
29+
30+
``` typescript
31+
import { FastMap } from '@speakingsoftware/fastmap';
32+
33+
interface RGB {
34+
r: number;
35+
g: number;
36+
b: number;
37+
}
38+
39+
const image = new FastMap<RGB>(100, 100);
40+
41+
// Draw a simple gradient
42+
for (let y = 0; y < 100; y++) {
43+
for (let x = 0; x < 100; x++) {
44+
image.Set(x, y, {
45+
r: Math.floor(255 * (x / 100)),
46+
g: Math.floor(255 * (y / 100)),
47+
b: 128
48+
});
49+
}
50+
}
51+
```
52+
53+
----------
54+
55+
Inspired by the CImage class in Vladimir Kovalevsky's book "Modern Algorithms for Image Processing"
56+
57+
58+
59+
460

5-
* Internally, it is a 1D array that is accessed using 2D coordinates. This makes is extremely performant for larger maps, as it avoids the overhead and mess of nested arrays.
6-
* Inspired by the CImage class in Vladimir Kovalevsky's book "Modern Algorithms for Image Processing"

0 commit comments

Comments
 (0)