cstep
Usage
Last updated 7 years ago by architectd .
BSD · Repository · Original npm · Tarball · package.json
$ cnpm install cstep 
SYNC missed versions from official npm registry.

Flow-control library used for coffeescript classes

Usage

cstep = require "cstep"

class Config
  
  ###
    Function: Constructor

    Parameters:
      source - source of the configuration file

  ###

  constructor: (@source) ->

  ###
    Function: load

    Loads the configuration file

    Parameters:

    next - called when load is complete
  ###

  load: cstep (next) ->
    fs.readFile @source, (err, content) =>
      @_content = JSON.parse content
      next()

  ###
    Function: set

    sets a value to the configuration file

    Parameters:

    next - called when set is complete (used mostly for cstep)
  ###

  set: cstep (key, value, next) ->
    @_content[key] = value
    next()

  ###
    Function: save

    Parameters:

    next - called when save is complete
  ###

  save: cstep (next) ->
    fs.writeFile @source, JSON.stringify(@_content), next

Using Config.coffee

config = new Config __dirname + "/config.json"
config.load().set("hello", "world").save () ->
  #successfully saved {"hello":"world"}

Current Tags

  • 0.0.1                                ...           latest (7 years ago)

2 Versions

  • 0.0.1                                ...           7 years ago
  • 0.0.0                                ...           7 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (1)
  • tq 0.2.x
Dev Dependencies (0)
None

Copyright 2014 - 2016 © taobao.org |