Skip to content

Draft: Added dump function to allow to write back arrays on files#54

Merged
j6k4m8 merged 3 commits into
aplbrain:modernize-repofrom
vallsv:dump
Sep 1, 2025
Merged

Draft: Added dump function to allow to write back arrays on files#54
j6k4m8 merged 3 commits into
aplbrain:modernize-repofrom
vallsv:dump

Conversation

@vallsv
Copy link
Copy Markdown
Contributor

@vallsv vallsv commented Aug 30, 2025

Hi,

Here is an implementation to create npy binary data from a TypedArray.

It was rebased on top of #52. This closes #53.

It can be used the following way:

import * as fs from 'fs';
import * as npyjs from 'npyjs';

const myarray = new Uint8Array([1, 2, 3, 4});
const shape = [2, 2];
const bytes = npyjs.dump(myarray, shape);
fs.writeFileSync('myarray.npy', new Uint8Array(bytes));

Notice that i have added the function isLittleEndian() to check the endianness of the system. This can also be used while loading an array for safety.

@vallsv vallsv changed the title Draft: Added dump function to allow to write back arrayes on files Draft: Added dump function to allow to write back arrays on files Aug 30, 2025
@j6k4m8 j6k4m8 changed the base branch from master to modernize-repo August 30, 2025 11:35
@j6k4m8
Copy link
Copy Markdown
Member

j6k4m8 commented Aug 30, 2025

Wow, this is super! Thank you @vallsv! I've changed the merge target to the modernize-repo branch so I can merge this in ASAP; is this ready to go or do you want me to wait before merging?

@vallsv
Copy link
Copy Markdown
Contributor Author

vallsv commented Aug 31, 2025

Hi, thanks. It's up to you. I put draft because you are working in the other PR, but it's done. You can do what ever you want with it. Or also asking me changes.

@j6k4m8
Copy link
Copy Markdown
Member

j6k4m8 commented Sep 1, 2025

Amazing — I'm going to merge it in!! Thank you again for this great work!

@j6k4m8 j6k4m8 merged commit f64a4a3 into aplbrain:modernize-repo Sep 1, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create npy data from TypedArray

2 participants