GithubHelp home page GithubHelp logo

borewit / token-types Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 8.0 1.8 MB

A primitive token library used to read from, and to write a node Buffer

License: MIT License

TypeScript 100.00%
endianness tokenizer stream-reader stream

token-types's People

Contributors

bjornstar avatar borewit avatar dependabot-preview[bot] avatar dependabot[bot] avatar lgtm-migrator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

token-types's Issues

Missing declaration types in 1.0.2

Hi, today I was building some docker images when I suddenly found the following error:

#10 33.94 > [email protected] build /app
#10 33.94 > tsc -p .
#10 33.94 
#10 38.73 node_modules/strtok3/lib/type.d.ts(2,27): error TS7016: Could not find a declaration file for module 'token-types'. '/app/node_modules/token-types/lib/index.js' implicitly has an 'any' type.
#10 38.73   Try `npm install @types/token-types` if it exists or add a new declaration (.d.ts) file containing `declare module 'token-types';`

I'm using the package music-metadata which has a dependency that uses this package and with the 1.0.2 version I'm getting this error. On the other hand, if I force a package downgrade by issuing the command npm install [email protected] I can get the TS files compiled. It seems that the types are not uploaded in 1.0.2, couldn't be? Or maybe I forgot something?

Thanks.

CI does not run on Pull Requests

I just created a PR, but the workflow is only configured to run on pushes. It would be nice if the tests run to ensure that nothing breaks before the PR is merged.

use dataview instead?

DataView is fast in v8 now
could you perhaps switch to operate on Uint8Array + DataView so it would make it less dependent on NodeJS Buffer module so the browser bundle wouldn't have to be as big?

Thoughts about using # instead of private?

# is the defacto way off writing private methods nowdays.
anything that isn't # is a public method.

private static decode(buffer: Uint8Array, offset: number, until: number): string {

I expect public/private to fade away eventually... some linters recommend it instead cuz it's the "right way" to write it

it makes it also more clear when you look at a piece of code and you can instantly tell if a method is a private method just by looking at this.#
I was debugging a other code to look what it was doing and saw: "ah this method seems interesting, i wonder if i can use it directly instead", but turned out that method was private when i tried to use it. Would have instantly know if it had this.#foo() instead...

Issue with determining epub file type getting added empty line

lib/index.ts
class StringType { constructor(len, encoding) { this.len = len; this.encoding = encoding; } get(uint8Array, offset) { return Buffer.from(uint8Array).toString(this.encoding, offset, offset + this.len); } }

Expected value: 'application/epub+zip'
Actual value: 'application/epub+zip
'
Some of the links for the epub files are here:-
https://soundplay-reports.s3.amazonaws.com/1.epub
https://soundplay-reports.s3.amazonaws.com/2.epub

Issue is raised in npm file-type
sindresorhus/file-type#537

Resolution
The extra space should be truncated by the library.

Signed 8-Bit Integer Return Offset

Forgive me if I'm reporting a false alarm, but I'm still wrapping my head around tokenizers. I was looking at lib/index.ts and saw that the 8-bit signed integer is returning offset + 2. Shouldn't this be offset + 1, or am I misunderstanding what's happening here?

Lines 130-145:

/**
 * 8-bit signed integer
 */
export const INT8: IToken<number> = {

  len: 1,

  get(array: Uint8Array, offset: number): number {
    return dv(array).getInt8(offset);
  },

  put(array: Uint8Array, offset: number, value: number): number {
    dv(array).setInt8(offset, value);
    return offset + 2;
  }
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.