Giter VIP home page Giter VIP logo

stf-syrup's Introduction

syrup

Syrup is an extremely simple Promise-based Dependency Injection framework (or rather, a library) for Node.js. While many related efforts already exist, Syrup attempts to break the mold by focusing on a single feature (dependency resolution) and relying on Node.js for the rest.

Features

  • Configuration-free. No need to set up configuration files just to get up and running.
  • Magic-free module loader. It's just require() and you'll be the one calling it (i.e. you have full control).
  • Promise-only.
  • Mock-friendly. Invoke modules with mock dependencies for easy testing.
  • Non-intrusive. You can use Syrup in just one part of your app.
  • Runs in parallel with an optional serial mode.

Mockability

Much like in Architect, you can invoke modules directly by passing your own mock dependencies to them.

archive.js

var syrup = require('syrup')

module.exports = syrup()
  .dependency(require('./box'))
  .define(function(options, box) {
    return {
      store: function(thing) {
        return box.put(thing)
      }
    }
  })

archive-test.js

var sinon = require('sinon')
var chai = require('chai')
chai.use require('sinon-chai')
var expect = chai.expect

var archive = require('./archive')

describe('archive', function() {

  it('should put the thing in the box', function() {
    var mockBox = {
      put: sinon.spy()
    }
    var treasure = 42
    archive.invoke(null, mockBox).store(treasure)
    expect(mockBox.put).to.have.been.calledWith(treasure)
  })

})

Contributing

See CONTRIBUTING.md.

License

See LICENSE.

Copyright © CyberAgent, Inc. All Rights Reserved.

stf-syrup's People

Contributors

dependabot-preview[bot] avatar koral-- avatar sorccu avatar syncxplus avatar

Watchers

 avatar  avatar

Forkers

samkenxstream

stf-syrup's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.