base-methods
Advanced tools
Comparing version
30
index.js
'use strict'; | ||
function base(name) { | ||
function namespace(name) { | ||
var utils = require('./utils'); | ||
/** | ||
* Create an instance of `Base` with optional `options`. | ||
* Create an instance of `Base` with `options`. | ||
* | ||
@@ -24,5 +24,5 @@ * ```js | ||
} | ||
utils.Emitter.call(this); | ||
this.define('_callbacks', this._callbacks); | ||
if (name) this[name] = {}; | ||
this.define('_callbacks', this._callbacks); | ||
if (typeof options === 'object') { | ||
@@ -197,2 +197,20 @@ this.visit('set', options); | ||
return this; | ||
}, | ||
/** | ||
* Mix property `key` onto the Base prototype. If base-methods | ||
* is inherited using `Base.extend` this method will be overridden | ||
* by a new `mixin` method that will only add properties to the | ||
* prototype of the inheriting application. | ||
* | ||
* @name .mixin | ||
* @param {String} `key` | ||
* @param {Object|Array} `val` | ||
* @return {Object} Returns the instance for chaining. | ||
* @api public | ||
*/ | ||
mixin: function(key, val) { | ||
Base.prototype[key] = val; | ||
return this; | ||
} | ||
@@ -227,3 +245,3 @@ }); | ||
module.exports = base(); | ||
module.exports = namespace(); | ||
@@ -234,2 +252,2 @@ /** | ||
module.exports.namespace = base; | ||
module.exports.namespace = namespace; |
{ | ||
"name": "base-methods", | ||
"description": "Starter for creating a node.js application with a handful of common methods, like `set`, `get`, and `del`.", | ||
"version": "0.2.13", | ||
"version": "0.2.14", | ||
"homepage": "https://github.com/jonschlinkert/base-methods", | ||
@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", |
@@ -53,3 +53,3 @@ # base-methods [](http://badge.fury.io/js/base-methods) | ||
Create an instance of `Base` with optional `options`. | ||
Create an instance of `Base` with `options`. | ||
@@ -180,4 +180,17 @@ **Params** | ||
### [.extend](index.js#L207) | ||
### [.mixin](index.js#L211) | ||
Mix property `key` onto the Base prototype. If base-methods | ||
is inherited using `Base.extend` this method will be overridden | ||
by a new `mixin` method that will only add properties to the | ||
prototype of the inheriting application. | ||
**Params** | ||
* `key` **{String}** | ||
* `val` **{Object|Array}** | ||
* `returns` **{Object}**: Returns the instance for chaining. | ||
### [.extend](index.js#L225) | ||
Static method for inheriting both the prototype and | ||
@@ -187,3 +200,3 @@ static methods of the `Base` class. See [class-utils][] | ||
### [.inherit](index.js#L217) | ||
### [.inherit](index.js#L235) | ||
@@ -230,3 +243,3 @@ Similar to `util.inherit`, but copies all static properties, | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 06, 2015._ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 07, 2015._ | ||
@@ -233,0 +246,0 @@ [class-utils]: https://github.com/jonschlinkert/class-utils |
@@ -8,4 +8,4 @@ 'use strict'; | ||
var utils = require('lazy-cache')(require); | ||
var fn = require; | ||
require = utils; | ||
require('set-value', 'set'); | ||
@@ -18,2 +18,3 @@ require('get-value', 'get'); | ||
require('class-utils', 'cu'); | ||
require = fn; | ||
@@ -20,0 +21,0 @@ /** |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
14849
6.52%239
7.66%249
5.51%2
100%