_Generated using [jest-runner-docs](https://ghub.now.sh/jest-runner-docs)._ ### [.parseCommit](./src/commit.ts#L34) Receives a full commit message `string` and parses it into an `Commit` object and returns it. Basically the same as [.parse](#parse), except that it only can accept single string. #### Signature ```ts function(commit: string, options?: Options): Commit ``` #### Params - `commit` **{string}** - a message like `'fix(foo): bar baz\n\nSome awesome body!'` - `options` **{object}** - options to control the header regex and case sensitivity - `options.headerRegex` **{RegExp|string}** - string regular expression or instance of RegExp - `options.caseSensitive` **{boolean}** - whether or not to be case sensitive, defaults to `false` - `returns` **{Commit}** - a standard object like `{ header: Header, body?, footer? }` _The `parse*` methods are not doing any checking and validation, so you may want to pass the result to `validateCommit` or `checkCommit`, or to `validateCommit` with `ret` option set to `true`._ #### Examples ```js import { parseCommit } from 'parse-commit-message'; const commitObj = parseCommit('foo: bar qux\n\nokey dude'); console.log(commitObj); // => { // header: { type: 'foo', scope: null, subject: 'bar qux' }, // body: 'okey dude', // footer: null, // } ``` ### [.stringifyCommit](./src/commit.ts#L68) Receives a `Commit` object, validates it using `validateCommit`, builds a "commit" string and returns it. Method throws if problems found. Basically the same as [.stringify](#stringify), except that it only can accept single `Commit` object. #### Signature ```ts function(commit: Commit | BasicCommit, options?: Options): string ``` #### Params - `commit` **{Commit}** - a `Commit` object like `{ header: Header, body?, footer? }` - `options` **{object}** - options to control the header regex and case sensitivity - `options.headerRegex` **{RegExp|string}** - string regular expression or instance of RegExp - `options.caseSensitive` **{boolean}** - whether or not to be case sensitive, defaults to `false` - `returns` **{string}** - a commit nessage stirng like `'fix(foo): bar baz'` #### Examples ```js import { stringifyCommit } from 'parse-commit-message'; const commitStr = stringifyCommit({ header: { type: 'foo', subject: 'bar qux' }, body: 'okey dude', }); console.log(commitStr); // => 'foo: bar qux\n\nokey dude' ``` ### [.validateCommit](./src/commit.ts#L117) Validates given `Commit` object and returns `Result`. Basically the same as [.validate](#validate), except that it only can accept single `Commit` object. #### Params - `commit` **{Commit|BasicCommit}** - a `Commit` like `{ header: Header, body?, footer? }` - `options` **{object}** - options to control the header regex and case sensitivity - `options.headerRegex` **{RegExp|string}** - string regular expression or instance of RegExp - `options.caseSensitive` **{boolean}** - whether or not to be case sensitive, defaults to `false` - `returns` **{Result}** - an object like `{ value: Array, error: Error }` #### Examples ```js import { validateCommit } from 'parse-commit-message'; const commit = { header: { type: 'foo', subject: 'bar qux' }, body: 'okey dude', }; const commitIsValid = validateCommit(commit); console.log(commitIsValid); // => true const { value } = validateCommit(commit, true); console.log(value); // => { // header: { type: 'foo', scope: null, subject: 'bar qux' }, // body: 'okey dude', // footer: null, // } ``` ### [.checkCommit](./src/commit.ts#L160) Receives a `Commit` and checks if it is valid. Method throws if problems found. Basically the same as [.check](#check), except that it only can accept single `Commit` object. #### Signature ```ts function(commit: Commit | BasicCommit, options?: Options): Commit ``` #### Params - `commit` **{Commit}** - a `Commit` like `{ header: Header, body?, footer? }` - `options` **{object}** - options to control the header regex and case sensitivity - `options.headerRegex` **{RegExp|string}** - string regular expression or instance of RegExp - `options.caseSensitive` **{boolean}** - whether or not to be case sensitive, defaults to `false` - `returns` **{Commit}** - returns the same as given if no problems, otherwise it will throw. #### Examples ```js import { checkCommit } from 'parse-commit-message'; try { checkCommit({ header: { type: 'fix' } }); } catch(err) { console.log(err); // => TypeError: header.subject should be non empty string } // throws because can accept only Commit objects checkCommit('foo bar baz'); checkCommit(123); checkCommit([{ header: { type: 'foo', subject: 'bar' } }]); ```