Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
a simple class-level mixin module for coffee-script, which provides a handy "composition over inheritance" way for writting complex programs
#acts-as
a simple class-level mixin module for Node.JS, which provides a handy "composition over inheritance" for writting complex programs
require "acts_as"
class A
this.toString = ->
'ClassA'
# after mixed in, use this method to detect who behaves like who (duck typing)
this.isA = (obj) ->
return if obj? then Boolean(obj["__is#{@}"]) else false
a: ->
console.log "[A.a] called"
"AAA"
class B
b: ->
console.log "[B.b] called"
"BBB"
class C
@acts_as A,B
c: ->
console.log "[C.c] called"
"CCC"
i = new C
console.dir i
console.log "i.a():#{i.a()}"
console.log "i.b():#{i.b()}"
console.log "i.c():#{i.c()}"
console.log "i behave like A? : #{A.isA(i)}"
This little module is inspired by:
discussion on coffee-script mixin: https://github.com/jashkenas/coffee-script/issues/452#issuecomment-3699651
acts_as in the Ruby's way: http://yehudakatz.com/2009/11/12/better-ruby-idioms/
FAQs
a simple class-level mixin module for coffee-script, which provides a handy "composition over inheritance" way for writting complex programs
We found that acts-as demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.