{"id":21615835,"url":"https://github.com/valango/sincere","last_synced_at":"2026-04-17T15:06:13.032Z","repository":{"id":40783824,"uuid":"234789793","full_name":"valango/sincere","owner":"valango","description":"A lightweight javascript base class providing intuitive interface for debugging and diagnostics of Node.js applications","archived":false,"fork":false,"pushed_at":"2023-01-05T05:18:08.000Z","size":749,"stargazers_count":0,"open_issues_count":12,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T10:08:49.438Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/valango.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-18T19:56:51.000Z","updated_at":"2020-02-20T12:45:22.000Z","dependencies_parsed_at":"2023-02-03T12:46:57.959Z","dependency_job_id":null,"html_url":"https://github.com/valango/sincere","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valango%2Fsincere","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valango%2Fsincere/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valango%2Fsincere/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valango%2Fsincere/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/valango","download_url":"https://codeload.github.com/valango/sincere/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244236102,"owners_count":20420752,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T22:12:57.500Z","updated_at":"2026-04-17T15:06:13.002Z","avatar_url":"https://github.com/valango.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sincere [![Build Status](https://travis-ci.org/valango/sincere.svg?branch=master)](https://travis-ci.org/valango/sincere) [![Code coverage](https://codecov.io/gh/valango/sincere/branch/master/graph/badge.svg)](https://codecov.io/gh/valango/sincere)\n\nSincere is a lightweight ES6 base class providing intuitive interface for debugging and diagnostics\nof Node.js applications.\n\n**NB:** v2.0 has breaking changes:\n   1. former static methods _`sincereHook()`_ and _`sincereReset()`_ are renamed to\n   _`hook()`_ and _`reset()`_ respectively;\n   1. both static methods behavior has slightly changed - see description below.\n\nWith Node.js earlier than v8.6.0, something like [`babel`](https://babeljs.io/) is needed.\n\n## Usage\nInstall with npm\n\n```\nnpm i sincere\n```\n\n## Example\n```javascript\nconst Sincere = require('sincere')\n\nclass MyClass extends Sincere {\n    ...\n}\n\n...\n\n//  Before the execution starts...\nSincere.hook(() =\u003e {\n  return 0     //  Set debugger breakpoint here.\n}\n\nconst myInstance = new MyClass(...)\n\nlet goodValue = myInstance.assert({good: true}, 'try')\nlet badValue = myInstance.assert(0, 'try', 'this failed, but %O - you see', goodValue)\n\n```\n\nSo, where's the beef? The above code results in `AssertionError` being thrown and the error\nmessage is something like `'MyClass#1.try: this failed, but {good: true} - you see'`.\n\nThe instance identifier shows exactly which instance of which class failed the assertion. Also,\nif your debugger breakpoint was set, you'd see the whole picture as it was just before throw.\nHow cool is that?\n\n## API\nIn 99% likelihood, **_`assert()`_**, **_`hook()`_** and **_`className`_** is all the API you need.\n\nBoth _`assert()`_ and _`sincereMessage()`_ use Node.js native `util.format()`;\nsee Node.js \n[documentation](https://nodejs.org/dist/latest-v12.x/docs/api/util.html#util_util_format_format_args) \nfor details.\n\n### Static methods\n\n**`hook(callback=)`** \u003cbr /\u003e\nSets a _before-the-assertion-will-throw_ callback.\n_Falsy_ value inhibits previously set callback; _`undefined`_ argument value\nhas no effect. _Truthy_ non-function type argument will result in _`TypeError`_ thrown.\u003cbr /\u003e\n**Returns** callback function or _`false`_. \u003cbr /\u003e\n_**NB:**_ In production environment, this method does nothing.\n\n**`reset()`** \u003cbr /\u003e\nResets internal seed variable for `sincereId` property. \u003cbr /\u003e\n_**NB:**_ available only if **NODE_ENV** was set to `'test'` before loading the module;\ncalling it in non-test environment will throw exception.\n\n### Instance properties\nThe instance properties are non-enumerable read-only and can not be overridden in derived classes.\n\n**`className`** : string - actual class name, like `'MyClass'`.\n\n**`sincereId`** : string - unique id, something like `'MyClass#42'`.\n\n### Instance methods\n\n**`assert(value, locus, …args)`** \u003cbr /\u003e\nA wrapper method around the native `assert.ok()`. Returns the `value`, if it is truthy - e.g. assertion does not fire.\nIf assertion fails, then `args` are processed by native `util.format` and `util.inspect` functions,\nso the first arg may be format string.\n\n**`sincereMessage(locus, args)`** \u003cbr /\u003e\nCompose a diagnostic message string prefixed with _`sincereId`_\n  * `locus : string    ` usually a method name;\n  * `args : Array\u003c*\u003e`  arguments to be passed to Node.js\n[`util.format()`](https://nodejs.org/dist/latest-v12.x/docs/api/util.html#util_util_format_format_args).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalango%2Fsincere","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvalango%2Fsincere","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalango%2Fsincere/lists"}