Skip to content

Instantly share code, notes, and snippets.

@ShirtlessKirk
ShirtlessKirk / settimeout.js
Created October 30, 2015 16:04
setInterval / setTimeout / setImmediate / requestAnimationFrame polyfill for IE < 10
/*jslint regexp: true */
/**
* window.setInterval and window.setTimeout polyfill to allow extra parameters (passed to called function) for IE < 10
*/
(function setTimeoutModule(global, partial, setInterval, setTimeout, slice) {
'use strict';
function dogfooder() {
if (arguments.length) { // no need to polyfill
return;
@ShirtlessKirk
ShirtlessKirk / string.js
Created October 30, 2015 16:06
String.endsWith / String.includes / String.startsWith / String.trim polyfill for IE, Opera, Safari
/**
* String.endsWith / String.startsWith polyfills for IE, Opera and Safari
*/
/*global define: false, module: false */
(function stringModule(definition) { // non-exporting module magic dance
'use strict';
var
amd = 'amd',
exports = 'exports'; // keeps the method names for CommonJS / AMD from being compiled to single character variable
@ShirtlessKirk
ShirtlessKirk / object.js
Created October 30, 2015 16:09
Object methods polyfill (partial)
/*global define: false, module: false */
/*jslint forin: true, nomen: true, unparam: true */
(function objectModule(definition) { // non-exporting module magic dance
'use strict';
var
amd = 'amd',
exports = 'exports'; // keeps the method names for CommonJS / AMD from being compiled to single character variable
if (typeof define === 'function' && define[amd]) {