Skip to content

Instantly share code, notes, and snippets.

@BenAychh
BenAychh / add.js
Last active October 14, 2016 23:15
function add(n) {
sum = n;
const proxy = new Proxy(function a () {}, {
get () {
return () => sum;
},
apply (receiver, ...args) {
sum += args[1][0];
return proxy;
}
@BenAychh
BenAychh / controllers.application.js
Last active December 15, 2016 19:46
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
twiglet: Ember.inject.service(),
appName: 'Ember Twiddle',
t: Ember.computed('twiglet', function() {
return this.get('twiglet').getTwiglet();
}),
});
const R = require('ramda');
/**
* wanted a functional way to do this that did not modify the params
**/
function deepReplaceInObject(currentValue, newValue, objectToReplaceIn) {
const paramType = R.type(objectToReplaceIn);
if (paramType === 'Object') {
return R.keys(objectToReplaceIn).reduce((object, key) => {
const type = R.type(objectToReplaceIn[key]);