Skip to content
This repository has been archived by the owner on Aug 12, 2018. It is now read-only.
/ nyce Public archive

JavaScript component interface definition and adherence utility

License

Notifications You must be signed in to change notification settings

recursivefunk/nyce

Repository files navigation

nyce

Circle CI

js-standard-style

JavaScript component interface definition and adherence utility

Component.js

exports.index = (foo, bar) => { /* ... */ }
exports.aProp = {}

ComponentInterface.js

module.exports = {
  index: {
    type: 'function',
    args: [ 'foo', 'bar' ],
    // By default, for function validation, nyce will only check the number
    // of arguments present with no regard to naming. If you would like to
    // fail validation if the names of the function arguments don't match the names
    // of the the interface arguments set this to true
    enforceArgNaming: true
  },
  aProp: {
    type: 'object'
  }
}

Elsewhere

const nyce = require('nyce')()
const impl = require('./Component')
const interface = require('./ComponentInterface')

nyce
  .define('resource', interface)
  .then(nyce.assertImplements('resource', impl))
  .then(() => {
    console.log('yay!')
  })
  .catch((e) => {
    console.log('oh no!')
  })

About

JavaScript component interface definition and adherence utility

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published