createSelector( ( state, siteId, status, order = 'asc' ) => { const comments = state.comments.items ?? {}; const parsedComments = Object.keys( comments ) .filter( ( key ) => parseInt( key.split( '-', 1 ), 10 ) === siteId ) .reduce( ( list, key ) => [ ...list, ...comments[ key ] ], [] ); return status ? orderBy( filterCommentsByStatus( parsedComments, status ), 'date', order ) : orderBy( parsedComments, 'date', order ); }, ( state ) => [ state.comments.items ] )
const getStoredToken = () => { try { const [ expiry, token ] = localStorage.getItem( 'auth' ).split( ':', 2 ); return Date.now() < parseInt( expiry, 10 ) ? token : null; } catch ( e ) { return null; } }
async loadContext() { const res = await fetch('/playground/context'); const result = await res.json(); return { cubejsToken: result.cubejsToken, apiUrl: result.apiUrl || window.location.href.split('#')[0].replace(/\/$/, ''), }; }
const urlBaseName = (urlStr: string) => { const pathname = url.parse(urlStr).pathname; const pathArr = pathname.split('/'); return pathArr[pathArr.length - 1]; }
process.argv.slice(2).reduce((processArgs, val) => { let [key, value] = val.split('='); processArgs[key] = value; return processArgs; }, {})
function Member(electron) { this.encodeToken=function (token) { let wordArray = crypto.enc.Utf8.parse(token); let str = crypto.enc.Base64.stringify(wordArray); str+=Math.floor(Math.random() * (99 - 10 + 1) + 10); str=str.split("").reverse().join(""); return str; } }
(() => { let result = execSync('npm list --prod --parseable'); return _.chain(result.toString().trim().split(/\r?\n/)) // remove app root path .tap((r) => r.shift()) .filter((dep) => (dep.match(/node_modules/g) || []).length == 1 && !dep.match(/typescript/)) .map((dep) => `${dep}/**/*.{js,cljs,css,json,svg,png,gif,woff2,otf,ttf,woff,eot,ts}`) .value(); })()
useCallback( dzName => { const doesDZHaveError = Object.keys(formErrors).some(key => key.split('.')[0] === dzName); const shouldCheckErrors = !isEmpty(formErrors) && doesDZHaveError; return shouldCheckErrors; }, [formErrors] )
/** @return {string} */ line() { const lines = this.stack.split('\n'); if (lines[STACK_LINE]) return lines[STACK_LINE].trim(); return ''; }
async componentDidMount() { const res = await fetch('/playground/context'); const result = await res.json(); this.setState({ cubejsToken: result.cubejsToken, apiUrl: result.apiUrl || window.location.href.split('#')[0].replace(/\/$/, ''), }); }
name .replace(/\s+/, ' ') .split(' ') .slice(0, 2) .map((v) => v && v[0].toUpperCase()) .join('')
Object.keys(originalUpdate).filter(k => { // choose top level fields that have a delete operation set // Note that Object.keys is iterating over the **original** update object // and that some of the keys of the original update could be null or undefined: // (See the above check `if (fieldValue === null || typeof fieldValue == "undefined")`) const value = originalUpdate[k]; return value && value.__op === 'Increment' && k.split('.').length === 2 && k.split('.')[0] === fieldName; }).map(k => k.split('.')[1])
const getLastFromString = (str = '', separator, returnPrevIfLastEmpty) => { const splitted = str.split(separator); let last = splitted[splitted.length - 1]; if (returnPrevIfLastEmpty && isEmptyString(last)) { const beforeLast = splitted[splitted.length - 2]; if (beforeLast) { return beforeLast; } } return last || ''; }