1.1.6 • Published 4 years ago

quick-prop v1.1.6

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago