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
| /** | |
| * @param obj {Object} | |
| * @returns {string} Object's type {string} value | |
| */ | |
| export function getType (obj) { | |
| return Object.prototype.toString.call(obj); | |
| }; | |
| /** | |
| * @param {string} url |
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
| 'use strict'; | |
| /** | |
| * @param obj {Object} | |
| * @returns {string} Object's type {string} value | |
| */ | |
| function getType (obj) { | |
| return Object.prototype.toString.call(obj); | |
| }; |
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
| setTimeout(function () | |
| { | |
| let element = document.createElement('div'); | |
| element.textContent = 'subtree modification test'; | |
| document.body.appendChild(element); | |
| console.log('setTimeout exit'); | |
| }, 1000); | |
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
| 'use strict'; | |
| /** | |
| * @param obj {Object} | |
| * @returns {string} Object's type {string} value | |
| */ | |
| function getType (obj) { | |
| return Object.prototype.toString.call(obj); | |
| }; |
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
| 'use strict'; | |
| /** | |
| * @param obj {Object} | |
| * @returns {string} Object's type {string} value | |
| */ | |
| function getType (obj) { | |
| return Object.prototype.toString.call(obj); | |
| }; |
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
| window.addEventListener('DOMContentLoaded', function() { | |
| //check support | |
| if (!supportsWebGL()) { | |
| $('webgl-canvas').innerHTML = 'Your browser doesn\'t seem to support WebGL. More info <a href=\'http://get.webgl.org/\'>here</a>.'; | |
| return; | |
| } | |
| //get context | |
| var canvas = $('webgl-canvas'), | |
| gl = getWebGLContext(canvas); |
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
| 'use strict'; | |
| /** | |
| * @param {Function} a - Function is called using the result of 'b' as the argument | |
| * @param {Function} b - Function 'b' is executed first with the callback arguments; the result is passed to 'a' | |
| * @returns {*} | |
| */ | |
| function compose (a, b) | |
| { | |
| return (...args) => a(b(...args)); |
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
| const eventHandler = message => event => { | |
| alert(message, event.target.id); | |
| } | |
| // <button id="button1" onClick="eventHandler('hello from')">click</button> | |
| // Ramda | |
| const requestWithOpts = R.curry((protocol, hostname, port) => | |
| protocol + '://' + hostname + (port === 80 ? '' : ':' + port) |
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
| function namedCurry(source_fn, arg_order){ | |
| function receiver( received_values, n_received, defaults ){ | |
| received_values = (received_values || []).slice() | |
| n_received = n_received || 0 | |
| Object.keys(defaults).forEach(function( input_arg ){ | |
| var value = defaults[ input_arg ] | |
| var required_index = arg_order.indexOf( input_arg ) | |
| var is_known_argument = required_index > -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
| var R = require('./ramda'); | |
| // Discussion at https://github.com/ramda/ramda/issues/1258 | |
| var namedCurry = function(fn, argNames) { | |
| // TODO: what if fn.length != argNames.length? | |
| var f = R.curryN(fn.length, function() { | |
| return fn.apply(this, arguments); | |
| }); | |
| f['secret-sauce'] = { |