Skip to content

Instantly share code, notes, and snippets.

@JakeChampion
JakeChampion / containsCircularPaths.js
Last active July 15, 2020 11:10
Used to find out whether an object contains a circular reference.
/**
* Used to find out whether an object contains a circular reference.
* @param {*} rootObject The object we want to search within for circular references
* @returns {bool} Returns true if a circular reference was found, otherwise returns false
*/
function containsCircularPaths(rootObject) {
// Used to keep track of all the values the rootObject contains
const traversedValues = new WeakSet();
/**
@JakeChampion
JakeChampion / core-js-polyfills-with-minor-version-targeting.js
Created January 15, 2020 00:33
Core-JS polyfills as of 14th January 2020 which target minor versions of user-agents
const data = {
"symbol.description": {
safari: "12.1"
},
"array.is-array": {
opera: "10.50"
},
"array.join": {
safari: "7.1"
},
@JakeChampion
JakeChampion / polyfills-with-minor-version-targeting.md
Created January 14, 2020 16:25
Polyfills as of 14th January 2020 which target minor versions of user-agents

HTMLPictureElement:

  • opera = "11.6 - 29"

matchMedia:

  • android = "2.1 - 2.3"

matchMedia:

  • opera = "11.5 - 12.1"

WebAnimations:

'use strict';
module.exports.hello = (event, context, callback) => {
callback(null, {
body: "hello",
statusCode: 200
});
};
@JakeChampion
JakeChampion / index.js
Created July 26, 2019 09:38
Open a blank tab in a browser and paste index.js into the DevTools console. Your clipboard now contains a JSON string which has the global variables including their static and instance methods.
/* eslint-env browser */
'use strict';
const blacklist = [
/^webkit/i,
'BeforeInstallPromptEvent',
/^Bluetooth/,
'CDATASection',
'captureEvents',
'InputDeviceCapabilities',
@JakeChampion
JakeChampion / obs-build-paths-to-modules-arrays.js
Created June 26, 2019 14:20
Find out which non-origami-components have been requested for via the origami build service.npm i && npm start
const ndjson = require('ndjson');
const fs = require('fs');
const a = {};
// JSON file generated via Splunk query:
// saved-search: https://financialtimes.splunkcloud.com/en-GB/app/search/search?sid=1561552286.4925882
// query: source="/var/log/apps/heroku/origami-build-service-*.log" status="200" index="heroku" "host=origami-build-service" path="/v2/bundles/*" AND NOT path="*/demos/*" | dedup path | table path
fs.createReadStream('./obs-modules-1-month-26-june-2019.json')
.pipe(ndjson.parse())
import React from "react";
import ReactDOM from "react-dom";
import { renderToStaticMarkup } from "react-dom/server";
function Message(props) {
console.log(props);
return <div>{JSON.stringify(props)}</div>;
}
class DemoBuilder extends React.Component {

All contributions to the polyfill service are made under the MIT licence. It is important therefore that you agree to the following when contributing code to the service:

  • Any contribution I make to the polyfill service by way of Pull Request contains only data that is:
    • wholly my own work, upon which I am legally permitted to grant a licence; or
    • wholly the work of individuals within the same organisation to which the copyright in all work created by employees is assigned, of which I am a current employee and authorised representive for the purposes of this contribution, and which is legally permitted to grant a licence; or
    • licensed by the original author under the MIT licence or equivalent terms
  • In respect of any part of my contribution that is not already available under an MIT or compatible licence, I hereby grant to the Financial Times Limited (FT) and to recipients of software distributed by the FT a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable license to make,
// "Type(x)" is used as shorthand for "the type of x"...
function Type(x) { // eslint-disable-line no-unused-vars
switch (typeof x) {
case 'undefined':
return 'undefined';
case 'boolean':
return 'boolean';
case 'number':
return 'number';
case 'string':