New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

r42

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

r42 - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

.npmignore

7

lib/moduleContext.js

@@ -64,3 +64,8 @@ 'use strict';

if (!exists) {
return callback(null, require(name));
return fs.exists(path.join(this.$baseDir, name, 'index.js'), function (exists) {
if (!exists) {
return callback(null, require(name));
}
this.getModule(callee, path.join(name, 'index'), callback);
}.bind(this));
}

@@ -67,0 +72,0 @@

2

package.json
{
"name": "r42",
"version": "0.0.12",
"version": "0.0.13",
"description": "Dependency injection done right.",

@@ -5,0 +5,0 @@ "author": "Quentin Raynaud <npm@qraynaud.eu>",

@@ -14,2 +14,3 @@ ## r42

#### Installation
```bash

@@ -70,4 +71,3 @@ npm install r42

If you want to resolve complex names in subdirectories, you can use the optional
"replacer" argument of the define function. Here is an example:
If you want to resolve complex names in subdirectories, you can use the optional `replacer` argument of the define function. Here is an example:

@@ -82,7 +82,5 @@ ```js

The object maps an argument's name to the real module name locally. The argument name
will be replaced by the given module name before injection happens.
The object maps an argument's name to the real module name locally. The argument name will be replaced by the given module name before injection happens.
You can also use special r42 comments (looking like `/*! module */`) before your argument
names:
You can also use special r42 comments (looking like `/*! module */`) before your argument names:

@@ -97,11 +95,32 @@ ```js

##### Special case : index.js in a subfolder
You can refer to an index module using only the folder's name just like so:
In file `folder/index.js`:
```js
define(function () {
return {
answer: 42
};
});
```
And in a file at the same level as folder:
```js
define(function ($folder) {
// Here $folder will load folder/index.js
});
```
##### Modules in the same folder
Sometimes, it is a pain to refer to a module in the same folder as you are right now.
r42 allows for a fine way to do so.
Sometimes, it is a pain to refer to a module in the same folder as you are right now. r42 allows for a fine way to do so.
Using '$' to prefix your variable's name will automatically cause r42 to replace it
by your current module's "path". It also works to prefix files in the replacer object.
Using `$` to prefix your variable's name will automatically cause r42 to replace it by your current module's "path". It also works to prefix files in the `replacer` object.
In a module 'module/toto.js'
In a module `module/toto.js`:
```js

@@ -119,8 +138,8 @@ define({

Those are working "automatically" but you NEED to exports barebone objects on both modules
for it to work.
Those are working "automatically" but you NEED to exports barebone objects on both modules for it to work.
Here is an example:
In a module 'a.js'
In a module `a.js`:
```js

@@ -139,3 +158,4 @@ define(function (b) {

In a module 'b.js'
In a module `b.js`:
```js

@@ -160,4 +180,3 @@ define(function (a) {

**BEWARE:** This really can go away in between versions right now, maybe replaced by something achieving
the same purpose but better designed. Don't use this for other purposes than debugging.
**BEWARE:** This really can go away in between versions right now, maybe replaced by something achieving the same purpose but better designed. Don't use this for other purposes than debugging.

@@ -164,0 +183,0 @@ This function does not print modules handled by NPM right now.

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