Skip to content

layerssss/unchained.coffee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

coffee-unchained

unchained.coffee

Problem

There are just too many chains in the JavaScript world.

too fancy for CoffeeScript !

# jquery
$(document.createElement 'div')
  .appendTo('body')
  .css(
    width: 100
    height: 50
  )
  .text('haha')


# d3
circle = d3.select('svg').selectAll("circle")
    .data(data)
circle.enter()
    .append("circle")
    .attr("r", 2.5)
circle
    .attr("cx", (d)-> d.x)
    .attr("cy", (d)-> d.y)
circle.exit().remove()

this is more CoffeeScript!

# jquery
unchain $, (document.createElement div), ->
  @$ @appendTo, 'body', ->
    @css
      width: 100
      height: 50
    @text 'haha'

# d3
unchain d3.select, 'svg', ->
  @$ @selectAll, 'circle', ->
    @$ @data, data, ->
      @$ @enter, ->
        @$ @append, circle, ->
          @attr r: 2.5
      @attr
        cx: (d)-> d.x
        cy: (d)-> d.y
      @$ @exit, ->
        @remove()

Usage

Development

Releases

No releases published

Packages

No packages published