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 shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; | |
const rgbRegex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i; | |
/** | |
* Converts a CSS hex value into an RGB array | |
*/ | |
export const hexToRgb = (hex: string): number[] | null => { | |
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") | |
const result = rgbRegex.exec( | |
hex.replace(shorthandRegex, (_, red: string, grn: string, blu: string) => `${red}${red}${grn}${grn}${blu}${blu}`) |
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 multiExtend = (targetInstance, SourceClass, ...args) => { | |
const sourceInstance = new SourceClass(...args) | |
const sourceDescriptors = Reflect.ownKeys(SourceClass) | |
.filter(key => !['constructor', 'name'].includes(key)) | |
.reduce((acc, key) => ([...acc, { key, descriptor: Object.getOwnPropertyDescriptor(SourceClass, key) }]), []) | |
const sourceInstanceDescriptors = Reflect.ownKeys(sourceInstance) | |
.reduce((acc, key) => ([...acc, { key, descriptor: Object.getOwnPropertyDescriptor(sourceInstance, key) }]), []) | |
sourceDescriptors.concat(sourceInstanceDescriptors).forEach(({ key, descriptor }) => { | |
Object.defineProperty(targetInstance, key, descriptor) |
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
import { interval } from 'rxjs' | |
import { distinctUntilChanged, mapTo, share } from 'rxjs/operators' | |
export const WEBSOCKET_READYSTATES = { | |
NOOP: null, // Unused in example, but useful to identify when a websocket doesn't exist (ie, not operational) | |
CONNECTING: 0, | |
OPEN: 1, | |
CLOSING: 2, | |
CLOSED: 3 | |
} |

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
/*global define, describe, it, before, after */ | |
define(['chai', 'sinon', 'boilerplate/simple'], function (chai, sinon, simple) { | |
'use strict'; | |
var assert = chai.assert; | |
describe('simple', function () { | |
describe('stamp', function () { | |
var clock; | |
var mockDate; |
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
#!/bin/sh | |
# Script to find the parent branch for a given branch name | |
# If no branch name is specified, then it'll use the existing branch | |
# If you specify a branch to find the source of that doesn't exist, the script will exit with an error exit code | |
currentbranch=`git branch | grep '*' | sed 's/\* //'` | |
exists=`git show-ref refs/heads/$1` | |
if [ "$1" != "" ] && [ -z "$exists" ]; then | |
echo "You've specified a branch that doesn't exist" |