function getDomainRegistrationTld( cartItem ) { if ( ! isDomainRegistration( cartItem ) ) { throw new Error( 'This function only works on domain registration cart ' + 'items.' ); } return '.' + tail( cartItem.meta.split( '.' ) ).join( '.' ); }
return reduce( files, ( config, file ) => { const fileConfig = fileToConfig( tail( file.split( '/' ) ) ); return mergeWith( config, fileConfig, ( object, source ) => { if ( Array.isArray( object ) ) { return object.concat( source ); } } ); }, {} );
function fileToConfig( pathParts, folderConfig = {} ) { const folder = head( pathParts ); if ( folder === 'test' && pathParts.length === 2 ) { folderConfig[ folder ] = [ getFileName( pathParts ) ]; } else { folderConfig[ folder ] = fileToConfig( tail( pathParts ) ); } return folderConfig; }
function addFile( file ) { if ( whitelistConfig ) { const pathParts = tail( file.split( '/' ) ); if ( ! isFileWhitelisted( whitelistConfig, pathParts ) ) { debug( `Skipping file: ${file}.` ); return; } } files.push( file ); }
drawStroke(points) { if (points.length >= 3) { let firstPoint = first(points); this.beginStroke(firstPoint.x, firstPoint.y, firstPoint.p); forEach(tail(initial(points)), (point) => { this.extendStroke(point.x, point.y, point.p); }); let lastPoint = last(points); this.endStroke(lastPoint.x, lastPoint.y, lastPoint.p); } }
it( 'should return an object with a new list of cards and deleting disabled when deleting completed', () => { Dispatcher.handleViewAction( { type: ActionTypes.STORED_CARDS_DELETE_COMPLETED, card: head( STORED_CARDS ) } ); expect( StoredCardsStore.get() ).to.be.eql( { isDeleting: false, isFetching: false, list: tail( STORED_CARDS ) } ); } );
const buildTree = createTask(function builder (attributes, levels, mount = false) { function extend (attr) { attr = assign({}, attr) for (let i = levels.length - 1; i >= 0; i--) { const {id: level, mount} = levels[i] const levelInfo = mount(attr) if (levelInfo) { attr[level] = levelInfo } else { return null } } return attr } if (isEmpty(levels)) { return attributes } if (mount) { attributes = compact(map(attributes, extend)) } const {id: level, openByDefault} = head(levels) const grouped = groupBy(attributes, `${level}.id`) const innerLevel = tail(levels) const format = (items, id) => buildTree(items, innerLevel) .then(list => { const sample = head(items) grouped[id] = { id, shared: get(sample, [level, 'shared']), name: get(sample, [level, 'name']), ids: flatten(map(list, ids)), openByDefault, list: list } }) return Promise.all(map(grouped, format)) .then(() => orderBy( grouped, ['shared', 'name'], ['desc', 'asc'] )) })
function isFileWhitelisted( config, pathParts ) { const folder = head( pathParts ); if ( config[ folder ] ) { if ( folder === 'test' && Array.isArray( config[ folder ] ) ) { return ( config[ folder ].indexOf( getFileName( pathParts ) ) !== false ); } return isFileWhitelisted( config[ folder ], tail( pathParts ) ); } return false; }