Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jaysalvat/smart-model

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jaysalvat/smart-model

Javascript object model

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by400%
Maintainers
1
Weekly downloads
 
Created
Source

npm version

Model

Javascript object model.

  • 1Kb gzipped
  • Value transformation
  • Value format
  • Value type validation
  • Value content validation (required, custom rules)
  • Default value
  • Virtual property
  • Live cycle events
  • Proper documentation ^^
  • decent tests ^^

Install

Install npm package

npm install @jaysalvat/smart-model

Module

import SmartModel from '@jaysalvat/smart-model'

CDN

<script src="https://unpkg.com/@jaysalvat/model@latest/build/smart-model.umd.min.js"></script>

Usage

Better documentation soon...

const Post = SmartModel.create('Post', {
  title: {
    required: true,
    type: String,
  },
  body: {
    required: true,
    type: String,
  },
  date: {
    type: Date,
    default: new Date(),
    transform: (value) => new Date(value),
    format: (value) => new Date().toLocaleString()
  }
})

const post = new Post({
  title: 'my new post',
  body: 'lorem ipsum...'
})

Dev

Dev mode

npm run dev

Build

npm run build

Lint

npm run lint

Fix lint errors

npm run lint:fix

Bump version and publish to NPM

npm run release
npm run release:patch
npm run release:minor
npm run release:major

Keywords

FAQs

Package last updated on 18 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc