{"id":21352118,"url":"https://github.com/wolfchamane/amjs-data-types","last_synced_at":"2026-05-20T02:47:26.661Z","repository":{"id":34995290,"uuid":"181197523","full_name":"Wolfchamane/amjs-data-types","owner":"Wolfchamane","description":"Data types for your OOP javascript project","archived":false,"fork":false,"pushed_at":"2023-01-06T01:47:47.000Z","size":1100,"stargazers_count":0,"open_issues_count":12,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T14:49:20.143Z","etag":null,"topics":["cjs","data","javascript","modules","nodejs","oop","types"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Wolfchamane.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-04-13T16:17:35.000Z","updated_at":"2020-11-24T07:02:46.000Z","dependencies_parsed_at":"2023-01-15T11:40:59.216Z","dependency_job_id":null,"html_url":"https://github.com/Wolfchamane/amjs-data-types","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wolfchamane%2Famjs-data-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wolfchamane%2Famjs-data-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wolfchamane%2Famjs-data-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wolfchamane%2Famjs-data-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Wolfchamane","download_url":"https://codeload.github.com/Wolfchamane/amjs-data-types/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826785,"owners_count":20354220,"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":["cjs","data","javascript","modules","nodejs","oop","types"],"created_at":"2024-11-22T03:12:41.388Z","updated_at":"2026-05-20T02:47:26.630Z","avatar_url":"https://github.com/Wolfchamane.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @amjs/data-types 0.1.8\n\n![Statements](https://img.shields.io/badge/Statements-100%25-brightgreen.svg) ![Branches](https://img.shields.io/badge/Branches-100%25-brightgreen.svg) ![Functions](https://img.shields.io/badge/Functions-100%25-brightgreen.svg) ![Lines](https://img.shields.io/badge/Lines-100%25-brightgreen.svg)\n\n\u003e Data types for your OOP javascript project\n\n## Installation\n\n```bash\n$ npm i @amjs/data-types\n```\n## Usage\n\nCan be use directly:\n```javascript\n// some.js file\nconst AmjsDataTypes = require('@amjs/data-types');\nconst str = new AmjsDataTypes.AmjsDataTypesString();\nstr.value = 'My Awesome String';\n\nconsole.log(str.value); // My Awesome String\n```\n\nCan be de-constructed:\n```javascript\nconst { AmjsDataTypesString } = require('@amjs/data-types');\nconst str = new AmjsDataTypesString();\nstr.value = 'My Awesome String';\n\nconsole.log(str.value); // My Awesome String\n```\n\nCan be extended:\n```javascript\n// MyString.js\nconst AmjsDataTypesString = require('@amjs/data-types/src/String');\nmodule.exports = class MyString extends AmjsDataTypesString\n{\n    welcome(name = '')\n    {\n        this.value = `Welcome ${user}`;\n    }\n}\n```\n\n__NOTICE__: in those examples CommonJS architecture + ES6 syntax is being used,\nif its planned to use this ORM solution for web project,\nis suggested to use [@babel](https://babeljs.io)\nto transpile files properly.\n#### Working with Object data type\n\n```javascript\n// Pre-register basic data types\nrequire('@amjs/data-types/src/Date');\nrequire('@amjs/data-types/src/Password');\nrequire('@amjs/data-types/src/String');\n// Requires parent Object class\nconst {AmjsDataTypesObject} = require('@amjs/data-types');\n\n// Extend User from Object\nclass User extends AmjsDataTypesObject\n{\n    constructor(values)\n    {\n        super();\n\n        // $privateProperties flags this object properties that should be handled internally\n        this.$privateProperties = {\n            password : true\n        };\n\n        // $propertyTypes maps the data type of each User property\n        this.$propertyTypes = {\n            password : 'Password',\n            name     : 'String'\n            birth    : 'Date'\n        };\n\n        // Use $propertyMap to map data values to User properties\n        this.$propertyMap = {\n            pwd         : 'password',\n            userName    : 'name',\n            dob         : 'birth'\n        };\n\n        // Flags $useMap to \"true\" to apply $propertyMap\n        this.$useMap = true;\n\n        // Declare properties\n        this.password   = null;\n        this.name       = null;\n        this.birth      = null;\n\n        this._setProperties(values);\n    }\n};\n\n// Register User constructor (optional)\nAmjsDataTypesObject.register('User', User);\n\nconst values = { pwd : '123456', userName : 'Mr. User', dob: '1989-02-03' };\n\n// Direct creation\nconst user = new User();\n\n// Factory creation\nconst user = AmjsDataTypesObject.create('User', values);\n\nconsole.log(user.toJSON()); // { name : 'Mr. User', birth : '1989-02-03' }\n```\n### Working with Collection data types\n\n```javascript\n\nconst { AmjsDataTypesCollection, AmjsDataTypesObject } = require('@amjs/data-types');\n\n// Create (optional) \u0026 pre-register your item type class reference.\nclass MyObject extends AmjsDataTypesObject\n{\n    constructor(values)\n    {\n        super();\n\n        /**\n        * @override\n        */\n        this.$propertyTypes = {\n            key : '*'\n        };\n\n        this.key = null;\n\n        this._setProperties(values);\n    }\n}\n\nAmjsDataTypesObject.register('MyObject', MyObject);\n\n// Create a collection which \"itemType\" property is your new item type class\nclass MyCollection extends AmjsDataTypesCollection\n{\n    constructor(values)\n    {\n        super();\n        this.$itemType = 'MyObject';\n        this.value = values;\n    }\n}\n\nconst values = [{ key : 'value1' }, { key : 'value2' }, { key: 'value3' }];\nconst sut = new MyCollection(values);\nconsole.log(sut.value); // [ MyObject { key: 'value1' }, MyObject { key: 'value2' }, MyObject { key: 'value3' } ]\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolfchamane%2Famjs-data-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwolfchamane%2Famjs-data-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolfchamane%2Famjs-data-types/lists"}