Skip to content

Commit

Permalink
move utils to index.js, run update
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Apr 3, 2017
1 parent e6f47c7 commit 183ab8a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 55 deletions.
52 changes: 30 additions & 22 deletions index.js
@@ -1,14 +1,21 @@
'use strict';

var util = require('util');
var utils = require('./utils');
var union = require('arr-union');
var CacheBase = require('cache-base');
var define = require('define-property');
var Emitter = require('component-emitter');
var isObject = require('isobject');
var merge = require('mixin-deep');
var pascal = require('pascalcase');
var cu = require('class-utils');

/**
* Optionally define a custom `cache` namespace to use.
*/

function namespace(name) {
var Cache = name ? utils.Cache.namespace(name) : utils.Cache;
var Cache = name ? CacheBase.namespace(name) : CacheBase;
var fns = [];

/**
Expand Down Expand Up @@ -54,23 +61,23 @@ function namespace(name) {
* Add static emitter methods
*/

for (var key in utils.Emitter.prototype) {
utils.define(Base, key, utils.Emitter.prototype[key]);
for (var key in Emitter.prototype) {
define(Base, key, Emitter.prototype[key]);
}

/**
* Initialize `Base` defaults with the given `config` object
*/

Base.prototype.initBase = function(config, options) {
this.options = utils.merge({}, this.options, options);
this.options = merge({}, this.options, options);
this.cache = this.cache || {};
this.define('registered', {});
if (name) this[name] = {};

// make `app._callbacks` non-enumerable
this.define('_callbacks', this._callbacks);
if (utils.isObject(config)) {
if (isObject(config)) {
this.visit('set', config);
}
Base.run(this, 'use', fns);
Expand Down Expand Up @@ -106,7 +113,7 @@ function namespace(name) {
}

this.define('type', name);
this.define('is' + utils.pascal(name), true);
this.define('is' + pascal(name), true);

// the following properties are deprecated and will
// be removed in a future release
Expand Down Expand Up @@ -196,10 +203,10 @@ function namespace(name) {
*/

Base.prototype.define = function(key, val) {
if (utils.isObject(key)) {
if (isObject(key)) {
return this.visit('define', key);
}
utils.define(this, key, val);
define(this, key, val);
return this;
};

Expand Down Expand Up @@ -291,7 +298,7 @@ function namespace(name) {
* @api public
*/

utils.define(Base, 'use', function(fn) {
define(Base, 'use', function(fn) {
fns.push(fn);
return Base;
});
Expand All @@ -305,7 +312,7 @@ function namespace(name) {
* @param {Array} `arr` Array of functions to pass to the method.
*/

utils.define(Base, 'run', function(obj, prop, arr) {
define(Base, 'run', function(obj, prop, arr) {
var len = arr.length, i = 0;
while (len--) {
obj[prop](arr[i++]);
Expand Down Expand Up @@ -335,18 +342,18 @@ function namespace(name) {
* @api public
*/

utils.define(Base, 'extend', utils.cu.extend(Base, function(Ctor, Parent) {
define(Base, 'extend', cu.extend(Base, function(Ctor, Parent) {
Ctor.prototype.mixins = Ctor.prototype.mixins || [];

utils.define(Ctor, 'mixin', function(fn) {
define(Ctor, 'mixin', function(fn) {
var mixin = fn(Ctor.prototype, Ctor);
if (typeof mixin === 'function') {
Ctor.prototype.mixins.push(mixin);
}
return Ctor;
});

utils.define(Ctor, 'mixins', function(Child) {
define(Ctor, 'mixins', function(Child) {
Base.run(Child, 'mixin', Ctor.prototype.mixins);
return Ctor;
});
Expand Down Expand Up @@ -377,7 +384,7 @@ function namespace(name) {
* @api public
*/

utils.define(Base, 'mixin', function(fn) {
define(Base, 'mixin', function(fn) {
var mixin = fn(Base.prototype, Base);
if (typeof mixin === 'function') {
Base.prototype.mixins.push(mixin);
Expand All @@ -399,14 +406,15 @@ function namespace(name) {
* @api public
*/

utils.define(Base, 'mixins', function(Child) {
define(Base, 'mixins', function(Child) {
Base.run(Child, 'mixin', Base.prototype.mixins);
return Base;
});

/**
* Similar to `util.inherit`, but copies all static properties, prototype properties, and
* getters/setters from `Provider` to `Receiver`. See [class-utils][]{#inherit} for more details.
* Similar to `util.inherits`, but copies all static properties,
* prototype properties, and getters/setters from `Provider` to
* `Receiver`. See [class-utils][]{#inherit} for more details.
*
* ```js
* Base.inherit(Foo, Bar);
Expand All @@ -418,10 +426,10 @@ function namespace(name) {
* @api public
*/

utils.define(Base, 'inherit', utils.cu.inherit);
utils.define(Base, 'bubble', utils.cu.bubble);
utils.define(Base, '_callbacks', Base._callbacks);
utils.define(Base, 'super_', Base.super_);
define(Base, 'inherit', cu.inherit);
define(Base, 'bubble', cu.bubble);
define(Base, '_callbacks', Base._callbacks);
define(Base, 'super_', Base.super_);
return Base;
}

Expand Down
14 changes: 6 additions & 8 deletions package.json
Expand Up @@ -9,6 +9,7 @@
"Jon Schlinkert (https://github.com/jonschlinkert)"
],
"contributors": [
"<wtgtybhertgeghgtwtg@gmail.com> (https://github.com/wtgtybhertgeghgtwtg)",
"Brian Woodward <brian.woodward@gmail.com> (https://twitter.com/doowb)",
"Charlike Mike Reagent (https://i.am.charlike.online)",
"John O'Donnell (https://github.com/criticalmash)",
Expand All @@ -20,9 +21,7 @@
},
"license": "MIT",
"files": [
"index.js",
"utils.js",
"verbfile.js"
"index.js"
],
"main": "index.js",
"engines": {
Expand All @@ -38,16 +37,15 @@
"component-emitter": "^1.2.1",
"define-property": "^0.2.5",
"isobject": "^3.0.0",
"lazy-cache": "^2.0.2",
"mixin-deep": "^1.2.0",
"pascalcase": "^0.1.1",
"through2": "^2.0.3",
"verb-generate-readme": "^0.4.3"
"pascalcase": "^0.1.1"
},
"devDependencies": {
"gulp-format-md": "^0.1.11",
"helper-changelog": "^0.3.0",
"mocha": "^3.2.0"
"mocha": "^3.2.0",
"through2": "^2.0.3",
"verb-generate-readme": "^0.4.3"
},
"keywords": [
"base",
Expand Down
25 changes: 0 additions & 25 deletions utils.js

This file was deleted.

0 comments on commit 183ab8a

Please sign in to comment.