npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tokendiff

v1.0.3

Published

git compatible external diff utility based on token level comparison for (much) shorter patch files

Downloads

7

Readme

tokendiff

git compatible external diff utility based on token level comparison for (much) shorter patch files

about

tokendiff expects valid c-like language files as input, all other file types are ** most-likely unsupported ** and will not work

WARNING: tokendiff treats all comments as whitespaces, but only changes them if the preceding token are changed!

usage

First you need to install as a global node package, then you can set it as the external diff tool for git:

npm install -g tokendiff
git config --global diff.external tokendiffgit

To produce a patch file, go to your source directory and run:

cd /my/source/directory
git diff > changes.patch

NOTE: This requires your working tree to have modified files

If you finished, disable it by executing:

git config --global --unset diff.external

customization

To further tweak optimization of the output, you can provide a customization file named .tokendiff, placed in the directory where the git operation will be comitted. The file is a standard JSON file.

.tokendiff

{
  "map": [
    {
      "type": "NUMBER",
      "condition": "e.subtype.includes(TNT.FLOAT)",
      "side": "all",
      "apply": "e.type = 'NUMBER_VALUE_COMP'",
      "include": "^src\\/($|.*)",
      "exclude": "^src\\/forbid\\/($|.*)"
    }
  ],
  "equal": [
    {
      "type": "NUMBER_VALUE_COMP",
      "comparator": "a.value == b.value",
      "include": "^src\\/($|.*)",
      "exclude": "^src\\/forbid\\/($|.*)"
    }
  ]
}

This example will tell tokendiff to compare any floating number tokens by value, instead of the default string comparsion.

map array of records

You can run one of these mapping records on any token(s) with the type, condition, side, include and exclude given, which will run the apply snipet given on them, after tokendiff parsed the file. Only the first record will be applied if the condition is true, but it will continue to fall-over on records with a false result.

  • type is a builtin token type, where the main ones are: STRING "" or LITERAL '', NUMBER, NAME or PUNCTUATION extensive list in Lexer.js
  • condition is a snipet of code what will be evaluated, with available objects are: e is the token itself, TT token types, TNT number types
  • side can be all for both input files (same if omitted), left for the original only or right for the modified file only in the working tree
  • apply the snipet what will be run if the condition is true, same inputs as condition
  • include regex pattern for allowed file paths, all files allowed if its omitted
  • exclude regex pattern to filter out file paths, no files filtered out if omitted

equal array of records

This will control what will be a difference in data, only same typed tokens will be compared for performance considerations. (This is why you hence 'remap' the token types).

  • type is a builtin or mapped token type
  • comparator is a snipet of code will determine equality, with same inputs as map.condition
  • include regex pattern for allowed file paths, all files allowed if its omitted
  • exclude regex pattern to filter out file paths, no files filtered out if omitted