react-native-onyx
Version:
State management for React Native
31 lines (30 loc) • 1.04 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.startsWith = exports.result = exports.guid = void 0;
/**
* Returns true if the haystack begins with the needle
*
* @param haystack The full string to be searched
* @param needle The case-sensitive string to search for
* @return Returns true if the haystack starts with the needle.
*/
function startsWith(haystack, needle) {
return typeof haystack === 'string' && typeof needle === 'string' && haystack.startsWith(needle);
}
exports.startsWith = startsWith;
function result(parameter, ...args) {
return typeof parameter === 'function' ? parameter(...args) : parameter;
}
exports.result = result;
/**
* A simple GUID generator taken from https://stackoverflow.com/a/32760401/9114791
*/
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return `${s4()}${s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;
}
exports.guid = guid;
;