{"id":32263071,"url":"https://github.com/emfjson/ecore.js","last_synced_at":"2026-03-11T06:31:09.826Z","repository":{"id":2600824,"uuid":"3583492","full_name":"emfjson/ecore.js","owner":"emfjson","description":"Ecore for JavaScript","archived":false,"fork":false,"pushed_at":"2018-06-01T16:54:44.000Z","size":901,"stargazers_count":70,"open_issues_count":7,"forks_count":29,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-03-10T12:11:29.560Z","etag":null,"topics":["ecore","emf","javascript","xmi"],"latest_commit_sha":null,"homepage":"https://emfjson.github.io/ecore.js/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emfjson.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":"2012-02-29T16:31:20.000Z","updated_at":"2025-11-12T08:53:42.000Z","dependencies_parsed_at":"2022-06-25T19:03:20.350Z","dependency_job_id":null,"html_url":"https://github.com/emfjson/ecore.js","commit_stats":null,"previous_names":["ghillairet/ecore.js"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/emfjson/ecore.js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emfjson%2Fecore.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emfjson%2Fecore.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emfjson%2Fecore.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emfjson%2Fecore.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emfjson","download_url":"https://codeload.github.com/emfjson/ecore.js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emfjson%2Fecore.js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30373440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["ecore","emf","javascript","xmi"],"created_at":"2025-10-22T20:47:18.633Z","updated_at":"2026-03-11T06:31:09.247Z","avatar_url":"https://github.com/emfjson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[Ecore](http://www.eclipse.org/modeling/emf/?project=emf) ([EMOF](http://en.wikipedia.org/wiki/Meta-Object_Facility)) implementation in JavaScript.\n\n## Content\n\n* [Install](#installl)\n* [Usage](#usage)\n* [API](#api)\n* [Contributing](#contributing)\n* [History](https://github.com/ghillairet/ecore.js/releases/)\n* [License](#license)\n\n\n## Install\n\n### Browser\n\nDownload Ecore.js from dist/ folder, and include it in your html along with underscore.js.\n\n```html\n\u003cscript src=\"underscore.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"ecore.js\"\u003e\u003c/script\u003e\n```\n\nAlternatively you can use the dependency manager [Bower](http://bower.io/) to install Ecore.js in your project.\n\n```\nbower install ecore\n```\n\n### Node\n\nEcore.js is available on npm and can be use as a Node module. To install it simply use the following command from your terminal:\n\n```\nnpm install ecore\n```\n\nImporting Ecore.js in a Node module is done as follow:\n\n\n```javascript\nvar Ecore = require('ecore');\n```\n\n## Usage\n\n### Create a model\n\n```javascript\n\n// Resources contain model elements and are identified by a URI.\n\nvar resourceSet = Ecore.ResourceSet.create();\nvar resource = resourceSet.create({ uri: '/model.json' });\n\n// EClass are used to define domain elements, they are identified\n// by name and a set of structural features (attributes and references).\n\nvar User = Ecore.EClass.create({\n    name: 'User',\n    eStructuralFeatures: [\n        // EAttributes are used to define domain elements\n        // elements properties.\n        Ecore.EAttribute.create({\n            name: 'name',\n            upperBound: 1,\n            eType: Ecore.EString\n        }),\n        // EReference are used to define links between domain\n        // elements.\n        Ecore.EReference.create({\n            name: 'friends',\n            upperBound: -1,\n            containment: false,\n            eType: function() { return User; }\n        })\n    ]\n});\n\n// EPackages represent namespaces for a set of EClasses.\n// It's properties name, nsURI and nsPrefix must be set.\n\nvar SamplePackage = Ecore.EPackage.create({\n    name: 'sample',\n    nsURI: 'http://www.example.org/sample',\n    nsPrefix: 'sample',\n    eClassifiers: [\n        User\n    ]\n});\n\n// Packages must be added directly to the model's Resource.\n\nresource.add(SamplePackage);\n\n```\n\nModel Elements can also be created separately.\n\n```javascript\nvar User = Ecore.EClass.create({ name: 'User' });\nvar User_name = Ecore.EAttribute.create({\n   name: 'name',\n   eType: Ecore.EString\n});\nvar User_friends = Ecore.EReference.create({\n   name: 'friends',\n   upperBound: -1,\n   eType: User\n});\nUser.get('eStructuralFeatures').add(User_name);\nUser.get('eStructuralFeatures').add(User_friends);\n```\n\n### Create instances\n\n```javascript\nvar u1 = User.create({ name: 'u1' });\nvar u2 = User.create({ name: 'u2' });\nu1.get('friends').add(u2);\n\nu1.get('friends').each(function(friend) { console.log(friend) });\n```\n\n### JSON Support\n\nJSON is the default serialization format supported by ecore.js. The JSON format is\ndescribed [here](https://github.com/ghillairet/emfjson) and looks like this:\n\n```javascript\n{\n    \"eClass\" : \"/model.json#//User\",\n    \"name\" : \"u1\",\n    \"friends\" : [\n        { \"$ref\" : \"/u2.json#/\", \"eClass\": \"/model.json#//User\" },\n        { \"$ref\" : \"/u3.json#/\", \"eClass\": \"/model.json#//User\" }\n    ]\n}\n```\n\n### XMI Support\n\nSupport for XMI has been added in version 0.3.0. This support requires [sax.js](https://github.com/isaacs/sax-js).\n\n```javascript\nvar Ecore = require('ecore/dist/ecore.xmi');\n\nvar resourceSet = Ecore.ResourceSet.create();\nvar resource = resourceSet.create({ uri: 'test2.xmi' });\n\nresource.parse(data, Ecore.XMI); // data being a string containing the XMI.\n\nresource.to(Ecore.XMI, true); // returns the XMI string\n\n```\n\n## API\n\n### Ecore\n - create(eClass): EObject\n\n### ResourceSet\n - create(): Resource\n - getEObject(uri): EObject\n\n### Resource\n - add(value)\n - addAll(values)\n - clear()\n - each(iterator, [context])\n - save([sucess], [error])\n - load([sucess], [error], [data])\n - toJSON(): Object\n - getEObject(fragment): EObject\n\n### EObject\n - has(property): Boolean\n - isSet(property): Boolean\n - set(property, value)\n - get(property): EObject or EList\n - isTypeOf(type): Boolean\n - isKindOf(type): Boolean\n - eResource(): Resource\n - eURI(): String\n - getEStructuralFeature(name)\n\n### EList\n - add(element)\n - addAll(elements)\n - remove(element)\n - size()\n - at(position)\n - first()\n - last()\n - rest(index)\n - each(iterator, [context])\n - filter(iterator, [context])\n - find(iterator, [context])\n - map(iterator, [context])\n - reject(iterator, [context])\n - contains(iterator, [context])\n - indexOf(iterator, [context])\n\n\n## Contributing\n\nIf you want to contribute to this project or simply build from the source, you first need to clone the project by executing the following command in your terminal.\n\n\n```\n\u003e git clone https://github.com/ghillairet/ecore.js.git\n```\n\nTo build the project or run the tests you first need to install [Node](http://nodejs.org/), [npm](https://www.npmjs.org/) (distributed with Node) and [Grunt](http://gruntjs.com).\n\nOnce these are installed, go back to your terminal and enter the ecore.js directory.\n\n```\n\u003e cd ecore.js\n```\n\nThe tests are written using the [mocha](http://mochajs.org/) library. To run them, execute the following command:\n\n```\n\u003e grunt test\n```\n\nRunning a build will create a new distribution in the folder dist. This is done by executing the command:\n\n```\n\u003e grunt build\n```\n\nThat's it, you are now ready to contribute to the project.\n\n## License\nThis software is distributed under the terms of the Eclipse Public License 1.0 - http://www.eclipse.org/legal/epl-v10.html.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femfjson%2Fecore.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femfjson%2Fecore.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femfjson%2Fecore.js/lists"}