npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-di

v0.2.1

Published

Dependency Injection for Javascript. Both for Browser and Node

Downloads

89

Readme

ng-di

Spectacular Angular Dependency Injection isolated as a library. Working in Browser and Node environments

Current Canary Version 0.1.1 Build Status

Status: STABLE API - UNSTABLE Code sources location - All Test passing

  • Recommended *

Current Version 0.0.4

Status: UNSTABLE API - UNSTABLE Code sources location - No test

  • Not recommended *

Getting Started

On the server

Install the canary version module with:

npm install ng-di@canary

or

npm install [email protected]

Or the pre-development one

npm install ng-di

Once installed, start using it

var di = require('ng-di');
di.module(...);
di.injector(...);

In the browser

Download the production version or the development version.

You can also download a ZIP version with both flavours and the mocks helper.

In your web page:

<script src="dist/ng-di.min.js"></script>
<script>
di.module(...);
di.injector(...);
</script>

Documentation

This library simply isolates AngularJS dependency injection, exposing its module API as part of it.

All the DOM management has been removed, and makes this library the ideal artifact for using Javascript Dependency Injection in javascript only apps, libraries...

It's available as di instead of angular

The public API, considered stable, is(*):

(*)As this library is framework agnostic, the AngularJS concepts and module API methods module.directive and module.controller are NOT available inside the Module API

Other non documented utility methods here are for private usage, and can be removed

Please, refer to Angular Documentation on this topics, as ng-di exposes them as-is.

Examples

You can go to the examples folder to see how to use in node and browser

Testing

The tests provided have been written in jasmine, and are executed in browser with Karma Runner and in Node with jasmine-node

For your convenience on writing testable code using ng-di, as well as in angular, two utility functions are exposed

mock.module(...);
mock.inject(...);

You can read through code documentation or learn by watching examples

node

var mock = require('ng-di/mock'),
//mock.module and mock.inject are available

Browser

Include the mock helper in your test flow.

<script type="text/javascript" src="mock.js"></script>
<!-- mock.module and mock.inject are available -->

Development

After cloning, the repository...

Install all dependencies

npm install 

ng-di uses grunt 0.4.x for building the browser version and for testing. You will need to have installed grunt-cli as global

Pass all test in browser and node.

Relies on Karma and assumes a PhantomJS(*) browser installed on your machine

grunt test

Build the browser version

Creates all browser compatible code on /dist directory

grunt build

Test and build

grunt 

(*) After installing PhantomJS, add the executable to your path

#Add phantomJS to MacOSX PATH by editing ~/.bash_profile
export PHANTOMJS_BIN=/Applications/phantomjs-1.9.0-macosx/bin/phantomjs 

Aim of this project

The goal behind this project is closing the gap between the browser and node environments for developing testable libraries and applications that could be used in both environments.

Just provide different implementations for those environment dependant code (Browser XMLHttpRequest vs. Node http) and reuse all the application code

ng-di isolates you from the dependency injection in environments, but you will have to deal with the CommonsJS/AMD/no-module problem by yourself. Ideas are always welcome!

Release History

ng-di uses semantic versioning

v0.2.0

  • Expose annotate function

v0.1.1

  • FIX compatibility with mocha in mocks

v0.1.0

  • Completely rewrite internals using commonsJS module.
  • Adding mocks for both environments

BREAKING CHANGES

  • $utils is not exposed anymore.
  • Module 'di' is not registered by default
  • Removed lots of utility functions from being accesible. See utils for details.
  • Requiring in node does not need to recall di. Use: var di = require('ng-di');

v0.0.4

  • Adding more utilities functions to the code

v0.0.3

  • Adding more utilities functions to the code

v0.0.2

  • new service in module di exposing $utils functions

v0.0.1

  • First approach

License

This work is more-than-heavily based on AngularJS Dependency injection. All credits must go to the Angular Developers Licensed under the MIT license.

Bitdeli Badge