view on requirebin
Created
August 23, 2013 10:32
-
-
Save SimonRichardson/6317846 to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Store = require('fantasy-stores'), | |
| target, | |
| store = Store( | |
| function(x) { return target = x; }, | |
| function() { return target; } | |
| ), | |
| newStore; | |
| store.set(1); | |
| console.log(store.get()); | |
| newStore = store.map(function(a) { return a + 1; }); | |
| console.log(newStore.set(1)); // outputs 2. | |
| console.log(newStore.get()); // outputs 1. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require=function(t,e,n){function r(n,u){if(!e[n]){if(!t[n]){var i="function"==typeof require&&require;if(!u&&i)return i(n,!0);if(o)return o(n,!0);throw Error("Cannot find module '"+n+"'")}var s=e[n]={exports:{}};t[n][0].call(s.exports,function(e){var o=t[n][1][e];return r(o?o:e)},s,s.exports)}return e[n].exports}for(var o="function"==typeof require&&require,u=0;n.length>u;u++)r(n[u]);return r}({"fantasy-stores":[function(t,e){e.exports=t("9wPIsL")},{}],"9wPIsL":[function(t,e){var n=t("daggy"),r=n.tagged("set","get");r.prototype.extract=function(){return this.set(this.get())},r.prototype.extend=function(t){var e=this;return r(function(n){return t(r(e.set,function(){return n}))},this.get)},r.prototype.map=function(t){return this.extend(function(e){return t(e.extract())})},e!==void 0&&(e.exports=r)},{daggy:1}],1:[function(t,e,n){(function(){(function(t,e){"use strict";"function"==typeof define&&define.amd?define(["exports"],e):n!==void 0?e(n):(t.daggy={},e(t.daggy))})(this,function(t){function e(t){function e(){}return e.prototype=t,new e}function n(t,n){return t instanceof n?t:e(n.prototype)}function r(){function t(){var r,o=n(this,t);if(arguments.length!=e.length)throw new TypeError("Expected "+e.length+" arguments, got "+arguments.length);for(r=0;e.length>r;r++)o[e[r]]=arguments[r];return o}var e=[].slice.apply(arguments);return t._length=e.length,t}function o(t){function n(){throw new TypeError("Tagged sum was called instead of one of its properties.")}function o(e){return function(n){var r,o=t[e],u=[];if(!n[e])throw new TypeError("Constructors given to cata didn't include: "+e);for(r=0;o.length>r;r++)u.push(this[o[r]]);return n[e].apply(this,u)}}function u(t){var r=e(n.prototype);return r.cata=o(t),r}var i;for(i in t)t[i].length?(n[i]=r.apply(null,t[i]),n[i].prototype=u(i)):n[i]=u(i);return n}t.create=e,t.getInstance=n,t.tagged=r,t.taggedSum=o})})()},{}]},{},[]);var Store=require("fantasy-stores"),target,store=Store(function(t){return target=t},function(){return target}),newStore;store.set(1),console.log(store.get()),newStore=store.map(function(t){return t+1}),console.log(newStore.set(1)),console.log(newStore.get()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style type='text/css'>html, body { margin: 0; padding: 0; border: 0; } | |
| body, html { height: 100%; width: 100%; }</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment