{"id":18774200,"url":"https://github.com/leny/kompare","last_synced_at":"2025-12-14T06:30:16.370Z","repository":{"id":72964604,"uuid":"50280953","full_name":"leny/kompare","owner":"leny","description":"Compare an object with a simple schema.","archived":false,"fork":false,"pushed_at":"2016-01-29T09:46:22.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-29T17:48:00.669Z","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":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leny.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":"2016-01-24T09:31:32.000Z","updated_at":"2016-06-22T11:10:16.000Z","dependencies_parsed_at":"2023-04-22T23:38:18.909Z","dependency_job_id":null,"html_url":"https://github.com/leny/kompare","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"ac78f7351225f5c677fa90b49e95591cc0bc88ff"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Fkompare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Fkompare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Fkompare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leny%2Fkompare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leny","download_url":"https://codeload.github.com/leny/kompare/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239680988,"owners_count":19679509,"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-07T19:37:43.142Z","updated_at":"2025-12-14T06:30:16.303Z","avatar_url":"https://github.com/leny.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kompare\n\n[![NPM version](http://img.shields.io/npm/v/kompare.svg)](https://www.npmjs.com/package/kompare) [![Build Status](http://img.shields.io/travis/leny/kompare.svg)](https://travis-ci.org/leny/kompare) ![Dependency Status](https://david-dm.org/leny/kompare.svg) ![Downloads counter](http://img.shields.io/npm/dm/kompare.svg)\n\n\u003e Compare an object with a simple schema.\n\n* * *\n\n## Getting Started\n\n### From **browsers** and **node**.\n\nInstall the module with: `npm install kompare`.\n\n\u003e **NOTE:** kompare use the ES6 module definition. For now, it uses Babel to transpile to ES5.  \n\u003e So, if you use ES5, you should require kompare with `var kompare = require( \"kompare\" ).default;`, and, if you use ES6, you should import kompare with `import kompare from \"kompare\";`.\n\n## Documentation\n\n**kompare** returns a `boolean` indicating if the first object conforms to the simple schema given in the second object. Extra properties of the first objects are ignored.\n\n\u003e **NOTE:** kompare is a young lib used for testing in some of my pro-work. It could (and should) change and evolve in the future. For now, its very simple.\n\n### Signature\n\n`is_conform = kompare( source_object, schema_object[, strict_mode ] );`\n\n#### Example\n\n```javascript\nvar source = {\n    \"name\": \"Pierre-Antoine Delnatte\",\n    \"age\": 30,\n    \"address\": \"Liège, Belgium\",\n    \"skills\": [ \"js\", \"css\", \"html\" ],\n    \"experience\": {\n        \"flatland\": {\n            \"from\": 2011\n        }\n    }\n};\n\nvar schema = {\n    \"name\": \"string\",\n    \"age\": \"number\",\n    \"address\": \"string\",\n    \"skills\": \"array\",\n    \"experience\": \"object\"\n};\n\nvar conformity = kompare( source, schema );\n\n```\n\nSee [tests](./test/kompare_test.js) for other examples.\n\n### Schema object\n\nThe **schema object** is a simple javascript object indicating the type (as `string`) of each property in **source object**. The value of a schema property can also be a `boolean`, indicating if the property **must** be present (or not) in the source object, regardless of his type.\n\n### Strict mode\n\nWhen `strict_mode` is set to `true`, the `source_object` must be conform to the `schema_object` and cannot have extra properties.\n\n## Contributing\n\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n\n* **0.1.0**: Initial release (*24/01/16*)\n\n## License\n(Un)licensed under the UNLICENSE, 2016.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleny%2Fkompare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleny%2Fkompare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleny%2Fkompare/lists"}