Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-ng-autoinject

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-ng-autoinject

Transform __autoinject($rootScope) to angularjs' inject((_$rootScope_) => $rootScope = _$rootScope_)

  • 2.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
19
decreased by-20.83%
Maintainers
1
Weekly downloads
 
Created
Source

FOR BABEL 7.X INSTALL V2.X - FOR OLDER V1.X

babel-plugin-transform-ng-autoinject

When writing tests for AngularJS 1.x ease the pain of writing enormous boilerplate like this:

let $rootScope, $httpBackend
beforeEach(inject((_$rootScope_, _$httpBackend_) => {
  $rootScope = _$rootScope_;
  $httpBackend = _$httpBackend_;
}));

With the following syntax:

let $rootScope, $httpBackend
beforeEach(__autoinject($rootScope, $httpBackend));

The plugin simply transforms the __autoinject expression into the former inject(...)

The exact form the plugin outputs the autoinject expression is:

let $rootScope, $httpBackend
beforeEach(inject((_$rootScope_, _$httpBackend_) => {
  ({
    $rootScope,
    $httpBackend
  } = {
    $rootScope: _$rootScope_;
    $httpBackend: _$httpBackend_;
  });
}));

Installation

npm install --save-dev babel-plugin-transform-ng-autoinject

.babelrc

{
  "presets": ["es2016"],
  "plugins": ["transform-ng-autoinject"]
}

FAQs

Package last updated on 20 Feb 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc