Skip to content

blame-js compares an array of source codes and outputs information about where each line originates from.

License

Notifications You must be signed in to change notification settings

hundeloh-consulting/blame-js

Repository files navigation

blame-js

npm license github-issues
styled with prettier

blame-js compares an array of source codes and outputs information about where each line originates from. Its behaviour is similar to the blame functionality that is integrated in Git.

nodei.co

Install

npm install --save blame-js

Usage

Pay attention to the order of items in the array: the first one in the array is the newest. The items can either be simple texts or objects. The latter requires to pass an getCode and getOrigin function to be passed in the options (see example 2).

const blamejs = require('blame-js');
// or alternatively in ES6 syntax:
// import blamejs from 'blame-js';

/*
Result:
[ { origin: 0, value: 'a' },
  { origin: 0, value: 'b' },
  { origin: 2, value: 'c' } ]
*/
blamejs([`a
b
c`,
`c`,
`a
b
c`
])

/*
Result:
[ { origin: 'Commit #3', value: 'a' },
  { origin: 'Commit #3', value: 'b' },
  { origin: 'Commit #1', value: 'c' } ]
*/
blamejs(
  [
    {
      commit: 'Commit #3',
      code: `a
b
c`,
    },
    {
      commit: 'Commit #2',
      code: `c`,
    },
    {
      commit: 'Commit #1',
      code: `a
b
c`,
    },
  ],
  {
    getCode: item => item.code,
    getOrigin: item => item.commit,
  },
)

Running the tests

Mocha tests are implemented and you can run all tests via

npm run test

Built With

  • diff - a javascript text differencing implementation

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Julian Hundeloh - Initial work - jaulz

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

About

blame-js compares an array of source codes and outputs information about where each line originates from.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published