Skip to content

Instantly share code, notes, and snippets.

View machine.js
const test = (regex, base) => base && base.name && regex.test(base.name);
const isStart = ({ base }) => test(/^start-/, base);
const isFull = ({ base }) => !test(/^start-/, base);
const baseMachine = Machine({
id: 'base',
initial: 'init',
context: {
startBase: null,
base: {}
@saadshahd
saadshahd / svg-to-icon.js
Last active Aug 7, 2017
Runtime generator not found
View svg-to-icon.js
const path = require('path');
const pascalCase = require('pascal-case');
const {stringifyRequest} = require('loader-utils');
const {stringifySymbol, stringify} = require('../../lib/utils');
module.exports = function ({symbol, config, context, loaderContext}) {
const {spriteModule, symbolModule, runtimeOptions} = config;
const compilerContext = loaderContext._compiler.context;
const iconModulePath = path.resolve(compilerContext, runtimeOptions.iconModule);
View sameCharsWords.js
function getSameCharStrings(strings) {
const repeatedCharsOrSpaceRegex = /(\w)(?=.*\1)|\s/g;
const uniqueSortedChars = strings.map(word => {
return word
.replace(repeatedCharsOrSpaceRegex, '')
.split('')
.sort()
.join('');
});
View side-effects
// Generates two conditional methods
// 1. (isBroken: true, method: 'some') filters the abandoned shipments
// 2. (isBroken: false, method: 'every') filters the ready shipments
function checkShipment(isBroken, method) {
return function (curShipment) {
return curShipment.packagesList[method](function (curPackage) {
return curPackage.isBroken === isBroken;
});
};
}
You can’t perform that action at this time.