UNPKG

react-native-azure-auth

Version:

An React Native module implements Azure AD V2.0 authentication flow

23 lines (19 loc) 790 B
function snakeToCamel(str) { var parts = str.split('_') return parts.reduce(function(p, c) { return p + c.charAt(0).toUpperCase() + c.slice(1) }, parts.shift()) } function toCamelCase(object, options = {}) { if (typeof object !== 'object' || toString.call(object) === '[object Array]' || object === null) { return object } const { attributes = [], validate = false, rootOnly = false } = options return Object.keys(object).reduce(function(p, key) { const inList = attributes.indexOf(key) !== -1 var newKey = (inList && validate) || (!inList && !validate) ? snakeToCamel(key) : key p[newKey] = rootOnly ? object[key] : toCamelCase(object[key]) return p }, {}) } module.exports = { snakeToCamel, toCamelCase }