From 8375807089a5266631ffa1558148c2e690c35ffd Mon Sep 17 00:00:00 2001 From: Daniel Hug Date: Sat, 23 Jan 2016 10:59:06 -0800 Subject: [PATCH] add .gitignore for bower_components --- .gitignore | 1 + bower_components/snoopy/.bower.json | 37 -------------- bower_components/snoopy/README.md | 76 ----------------------------- bower_components/snoopy/bower.json | 26 ---------- bower_components/snoopy/snoopy.js | 62 ----------------------- 5 files changed, 1 insertion(+), 201 deletions(-) create mode 100644 .gitignore delete mode 100644 bower_components/snoopy/.bower.json delete mode 100644 bower_components/snoopy/README.md delete mode 100644 bower_components/snoopy/bower.json delete mode 100644 bower_components/snoopy/snoopy.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8d4ae25 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bower_components diff --git a/bower_components/snoopy/.bower.json b/bower_components/snoopy/.bower.json deleted file mode 100644 index 5a9cd3b..0000000 --- a/bower_components/snoopy/.bower.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "snoopy", - "main": "snoopy.js", - "homepage": "https://github.com/Daniel-Hug/snoopy", - "authors": [ - "Daniel Hug " - ], - "description": "Observable objects in JS", - "moduleType": [ - "globals" - ], - "keywords": [ - "Observable", - "watch", - "subscribe", - "observe" - ], - "license": "MIT", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ], - "version": "0.1.0", - "_release": "0.1.0", - "_resolution": { - "type": "version", - "tag": "0.1.0", - "commit": "1c785f70d07118c38529b23765bb607dcabc31c4" - }, - "_source": "git://github.com/Daniel-Hug/snoopy.git", - "_target": "~0.1.0", - "_originalSource": "snoopy", - "_direct": true -} \ No newline at end of file diff --git a/bower_components/snoopy/README.md b/bower_components/snoopy/README.md deleted file mode 100644 index e34751f..0000000 --- a/bower_components/snoopy/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# snoopy -Observable objects in JS - -## example - -```js -// setup observable data -var counter = new Snoopy({count: 0}); - -// counter.even subscribes to counter.count -counter.snoop('count', function(val) { - counter.set('even', val % 2 === 0); -}); - -// log: "3 is odd." or "0 is even." -counter.snoop('even', function(even) { - console.log(this.counter + ' is ' + (even ? 'even' : 'odd') + '.'); -}); -``` - -## constructor and method usage - -### `Snoopy()` - -Snoopy is a constructor but the `new` keyword is optional. Call it passing an optional object with some initial properties and values: - -```js -var counter = new Snoopy({count: 0}); -``` - -### `Snoopy.prototype.set(property, value)` - -```js -var person = Snoopy(); -person.set('name', 'Hank'); -``` - -### `Snoopy.prototype.get(property)` - -There are two ways to get the value of a property on a Snoopy instance: - -1. `person.get('name');` -2. `person.name` - -### `Snoopy.prototype.snoop(property, mapFn)` - -**arguments** - -Here are the possible ways to call `.snoop()`: - -```js -person.snoop('name')(function snooper(name) { - console.log('name is now ' + name); -}) -``` - -```js -person.snoop('name', function snooper(name) { - console.log('name is now ' + name); -}) -``` - -```js -person.snoop('firstName lastName', function map(firstName, lastName) { - return firstName + ' ' + lastName; -})(function snooper(name) { - console.log('name is now ' + name); -}) -``` - -**return value** -When `.snoop()` is called, it returns a "snoopable" function. The snoopable function accepts a callback, calls it right away passing the values of the properties being snooped, and calls it again whenever one of the values change. - -## use with [DOM Builder](https://github.com/Daniel-Hug/DOM-Builder) - -This Observable module was made with DOM Builder in mind and the two form a very powerful duo. \ No newline at end of file diff --git a/bower_components/snoopy/bower.json b/bower_components/snoopy/bower.json deleted file mode 100644 index 801b240..0000000 --- a/bower_components/snoopy/bower.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "snoopy", - "main": "snoopy.js", - "homepage": "https://github.com/Daniel-Hug/snoopy", - "authors": [ - "Daniel Hug " - ], - "description": "Observable objects in JS", - "moduleType": [ - "globals" - ], - "keywords": [ - "Observable", - "watch", - "subscribe", - "observe" - ], - "license": "MIT", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ] -} diff --git a/bower_components/snoopy/snoopy.js b/bower_components/snoopy/snoopy.js deleted file mode 100644 index dab2511..0000000 --- a/bower_components/snoopy/snoopy.js +++ /dev/null @@ -1,62 +0,0 @@ -var Snoopy = (function() { - function Snoopy(obj) { - if (!(this instanceof Snoopy)) return new Snoopy(obj); - // don't overwrite this.snoopers! - this.snoopers = {}; - Object.keys(obj).forEach(function(key) { - this[key] = obj[key]; - }, this); - } - - var changed = Snoopy.prototype.changed = function(prop) { - var newVal = this[prop]; - (this.snoopers[prop] || []).forEach(function(snooper) { - snooper.call(this, newVal); - }, this); - }; - - Snoopy.prototype.get = function(prop, val) { - return this[prop]; - }; - - Snoopy.prototype.set = function(prop, val) { - this[prop] = val; - changed.call(this, prop); - }; - - Snoopy.prototype.snoop = function(props, map) { - if (map) { - var snooper; - var mapOutput; - var propToVal = this.get.bind(this); - var propsArr = props.split(' '); - - // caller calls map with the values of the passed props - // then, if there is a snooper, calls that passing the value returned from the map - var caller = function caller() { - var propVals = propsArr.map(propToVal); - mapOutput = map.apply(null, propVals); - if (snooper) snooper(mapOutput); - }; - - caller(); - - // push caller to snooper list - var t = this; - propsArr.forEach(function(prop) { - if (!t.snoopers[prop]) t.snoopers[prop] = []; - t.snoopers[prop].push(caller); - }); - - return function mappedSnoop(newSnooper) { - snooper = newSnooper; - snooper(mapOutput); - }; - } else { - // snoopable - return this.snoop.bind(this, props); - } - }; - - return Snoopy; -})(); \ No newline at end of file