Skip to content

Commit

Permalink
Merge pull request #89 from troutowicz/conflicts
Browse files Browse the repository at this point in the history
Fix silly merge conflicts
  • Loading branch information
koresar committed Jun 1, 2015
2 parents 9b19ead + 08cf083 commit 8b232dc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 95 deletions.
41 changes: 14 additions & 27 deletions README.md
Expand Up @@ -246,7 +246,6 @@ myStamp = myStamp.refs({
});
```

<<<<<<< HEAD
And `.props()` ...

```js
Expand All @@ -257,8 +256,6 @@ myStamp = myStamp.props({
});
```

And `.init()` ...
=======
And `.static()` ...

```js
Expand All @@ -271,8 +268,7 @@ myStamp.static({
});
```

And `.enclose()` ...
>>>>>>> master
And `.init()` ...

```js
myStamp = myStamp.init(function () {
Expand Down Expand Up @@ -306,11 +302,7 @@ And `.compose()`.
var newStamp = baseStamp.compose(myStamp);
```

<<<<<<< HEAD
## Pass multiple objects into .methods(), .refs(), .init(), props(), or .compose().
=======
## Pass multiple objects into .methods(), .state(), .enclose(), .static(), or .compose().
>>>>>>> master
## Pass multiple objects into .methods(), .refs(), .init(), props(), .static(), or .compose().

Stampit mimics the behavior of `_.extend()`, `$.extend()` when you pass multiple objects into one of the stamp methods.
In other words, it will copy all of the properties from those objects to the `.methods`, `.refs`, `.init` or `.props` of the stamp.
Expand Down Expand Up @@ -349,13 +341,22 @@ Or `.init()` ...
Or `.props()` ...

```js
var obj = stampit().refs({
var obj = stampit().props({
name: { first: 'John' }
}, {
name: { last: 'Doe' }
}).create();
```

Or `.static()` ...

```js
var obj = stampit().static({
foo: 'foo'
}, {
bar: 'bar'
}).create();
```

Or even `.compose()` ...

Expand All @@ -370,7 +371,6 @@ Or even `.compose()` ...
### stampit() ###

Return a factory function (called a stamp) that will produce new objects using the
<<<<<<< HEAD
components that are passed in or composed.

* @param {Object} [options] Options to build stamp from: `{ methods, refs, init, props }`
Expand All @@ -385,21 +385,8 @@ components that are passed in or composed.
* @return {Function} factory.refs Add references to the stamp. Chainable.
* @return {Function} factory.init Add a closure which called on object instantiation. Chainable.
* @return {Function} factory.props Add deeply cloned properties to the produced objects. Chainable.
=======
prototypes that are passed in or composed.

* `@param {Object} [methods]` A map of method names and bodies for delegation.
* `@param {Object} [state]` A map of property names and values to clone for each new object.
* `@param {Function} [enclose]` A closure (function) used to create private data and privileged methods.
* `@return {Function} stamp` A factory to produce objects using the given prototypes.
* `@return {Function} stamp.create` Chaining sugar that invokes the stamp.
* `@return {Object} stamp.fixed` An object map containing the fixed prototypes.
* `@return {Function} stamp.methods` Add methods to the methods prototype. Chainable.
* `@return {Function} stamp.state` Add properties to the state prototype. Chainable.
* `@return {Function} stamp.enclose` Add or replace the closure prototype. Chainable.
* `@return {Function} stamp.compose` Add stamp to stamp. Chainable.
* `@return {Function} stamp.static` Add properties to the factory object. Chainable.
>>>>>>> master
* @return {Function} factory.compose Add stamp to stamp. Chainable.
* @return {Function} factory.static Add properties to the factory object. Chainable.


## The stamp object ##
Expand Down
4 changes: 0 additions & 4 deletions package.json
@@ -1,10 +1,6 @@
{
"name": "stampit",
<<<<<<< HEAD
"version": "2.0.0",
=======
"version": "1.2.0",
>>>>>>> master
"description": "Create objects from reusable, composable behaviors.",
"author": {
"name": "Eric Elliott",
Expand Down
65 changes: 1 addition & 64 deletions stampit.js
Expand Up @@ -16,21 +16,9 @@ var isArray = Array.isArray;
var isObject = require('lodash/lang/isObject');
var create = Object.create;
var slice = require('lodash/array/slice');

<<<<<<< HEAD
var mixer = require('./mixer');
=======
/*jshint -W024 */

// Avoiding JSHist W003 violations.
var create, extractFunctions, stampit, compose, isStamp, convertConstructor;

create = function (o) {
if (arguments.length > 1) {
throw new Error('Object.create implementation only accepts the first parameter.');
}
function F() {}
>>>>>>> master
/* jshint -W024 */

// Avoiding JSHist W003 violations.
var stampit;
Expand Down Expand Up @@ -124,7 +112,6 @@ function compose(factories) {
* @return {Function} factory.props Add deeply cloned properties to the produced objects. Chainable.
* @return {Function} factory.compose Combine several stamps into single. Chainable.
*/
<<<<<<< HEAD
stampit = function stampit(options) {
var fixed = {methods: {}, refs: {}, init: [], props: {}, static: {}};
fixed.state = fixed.refs; // Backward compatibility. 'state' is the old name for 'refs'.
Expand All @@ -136,15 +123,6 @@ stampit = function stampit(options) {
addProps(fixed, options.props);
addStatic(fixed, options.static);
}
=======
stampit = function stampit(methods, state, enclose) {
var fixed = {
methods: methods || {},
state: state,
enclose: extractFunctions(enclose),
static: {}
},
>>>>>>> master

var factory = function Factory(properties, args) {
properties = properties ? mixer.merge({}, fixed.props, properties) : deepClone(fixed.props);
Expand Down Expand Up @@ -221,17 +199,6 @@ stampit = function stampit(methods, state, enclose) {
return mixer.mixin(newStamp, newStamp.fixed.static);
},

/**
* Take n objects and add all props to the factory object.
* @return {Object} stamp The factory in question (`this`).
*/
static: function stampStatic() {
var obj = fixed.static || {},
args = [obj].concat(slice.call(arguments));
fixed.static = mixInChain.apply(this, args);

return mixIn(this, fixed.static);
},
/**
* Take one or more factories produced from stampit() and
* combine them with `this` to produce and return a new factory.
Expand Down Expand Up @@ -262,7 +229,6 @@ function isStamp(obj) {
);
}

<<<<<<< HEAD
function convertConstructor(Constructor) {
var stamp = stampit();
mixer.mixinChainFunctions(stamp.fixed.methods, Constructor.prototype);
Expand All @@ -279,35 +245,6 @@ function shortcutMethod(extensionFunction, args) {
extensionFunction(stamp.fixed, args);
return stamp;
}
=======
if (source.fixed.enclose) {
f.enclose = f.enclose.concat(source.fixed.enclose);
}

if (source.fixed.static) {
f.static = mixIn(f.static, source.fixed.static);
}
}
});
return mixIn(result, f.static);
};

/**
* Check if an object is a stamp.
* @param {Object} obj An object to check.
* @returns {Boolean}
*/
isStamp = function isStamp(obj) {
return (
typeof obj === 'function' &&
typeof obj.fixed === 'object' &&
typeof obj.methods === 'function' &&
typeof obj.state === 'function' &&
typeof obj.enclose === 'function' &&
typeof obj.static === 'function'
);
};
>>>>>>> master

module.exports = mixer.mixin(stampit, {

Expand Down

0 comments on commit 8b232dc

Please sign in to comment.