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

classy-traits

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

classy-traits

Thin wrapper around traits.js that supports "classes".

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

Classy Traits

This is just a thin wrapper around traits.js for use with "class" altjs languages like coffeescript and livescript.

For more documentation see traits.js.

Usage

Inherit from Trait somewhere in your hierarchy. It's easiest if you go to most super class of your classes, and inherit from there.

Then you need just one field in your class for the traits.

Example:

require! T: \classy-traits

class Foo extends T

  traits: ->
    trait:
      foo: 3

Options
compose

Compose other traits. Must be an array of traits.

create

Prototype to create traits from. Must be an actual prototype.

exclude

Attributes to exclude from specified traits. Must be an object with the form:

{
    <attribute_to_exclude1>: <trait_to_exclude_from1>,
    <attribute_to_exclude2>: <trait_to_exclude_from2>,
    ...
    <attribute_to_excluden>: <trait_to_exclude_fromn>
}
override

Traits to override. This favors earlier traits. Must be an array of traits.

required

Required attributes. Must be an array of strings.

rename

Attributes to rename from specified traits. Must be an object of the form:

{
    <attribute_to_rename1>: [<new_name1>, <trait_to_rename_from1>],
    <attribute_to_rename2>: [<new_name2>, <trait_to_rename_from2>],
    ...
    <attribute_to_renamen>: [<new_namen>, <trait_to_rename_fromn>]
}
trait

Object to create new trait. Must be an object.

Keywords

FAQs

Package last updated on 17 Mar 2014

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