// @flow // @credits https://gist.github.com/rogozhnikoff/a43cfed27c41e4e68cdc export function findInArray( array: Array | TouchList, callback: Function ): any { for (let i = 0, length = array.length; i < length; i++) { if (callback.apply(callback, [array[i], i, array])) return array[i]; } } export function isFunction(func: any) { // $FlowIgnore[method-unbinding] return ( typeof func === "function" || Object.prototype.toString.call(func) === "[object Function]" ); } export function isNum(num: any) { return typeof num === "number" && !isNaN(num); } export function int(a: string): number { return parseInt(a, 10); } export function dontSetMe( props: Record, propName: string, componentName: string ) { if (props[propName]) { return new Error( `Invalid prop ${propName} passed to ${componentName} - do not set this, set it on the child.` ); } }