This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

quick-prop
TypeScript icon, indicating that this package has built-in type declarations

1.1.6 • Public • Published

QuickProp

If you are familiar with Vue.js component's prop, you already knows how to use QuickProp. QuickProp is a JavaScript data model made easy.

npm-version npm-download Jest CI Total alerts

Installation

npm i quick-prop

Usage

import QuickProp from 'quick-prop'
import { v4 as uuidv4 } from 'uuid';
 
class Todo extends QuickProp {
    constructor(todo = {}) {
        super({
            id: {
                type: [Number, String],
                default() {
                    return uuidv4()
                }
            },
            title: {
                type: String,
                required: true
            },
            completed: {
                type: Boolean,
                default: () => false
            }
        }, todo)
    }
}
 
const todo = new Todo({
    title: 'Example todo'
})
 
todo.completed = true
 
console.log(JSON.stringify(todo))

Result:

{
    "id": "f24b19a2-e327-4199-88e9-1c5c8e4b8b82",
    "title": "Example todo",
    "completed": true
}

Todo

  • Better implementation
  • Add Type Decorator

License

License under MIT

Readme

Keywords

Package Sidebar

Install

npm i quick-prop

Weekly Downloads

10

Version

1.1.6

License

MIT

Unpacked Size

31.9 kB

Total Files

22

Last publish

Collaborators

  • andrewalex