Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Commit 8416b33

Browse files
committed
Merge pull request #1455 from nmccready/dev/nmccready/issue_1433_lodash_get
issue 1433
2 parents 3f9637f + 705cd34 commit 8416b33

9 files changed

+356
-493
lines changed

dist/angular-google-maps.js

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,127 @@ Nicholas McCready - https://twitter.com/nmccready
289289
}).call(this);
290290
;(function() {
291291
angular.module('uiGmapgoogle-maps.extensions').service('uiGmapLodash', function() {
292+
var baseGet, baseToString, get, reIsDeepProp, reIsPlainProp, rePropName, toObject, toPath;
293+
if (_.get == null) {
294+
reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/;
295+
reIsPlainProp = /^\w*$/;
296+
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
297+
298+
/**
299+
* Converts `value` to an object if it's not one.
300+
*
301+
* @private
302+
* @param {*} value The value to process.
303+
* @returns {Object} Returns the object.
304+
*/
305+
toObject = function(value) {
306+
if (_.isObject(value)) {
307+
return value;
308+
} else {
309+
return Object(value);
310+
}
311+
};
312+
313+
/**
314+
* Converts `value` to a string if it's not one. An empty string is returned
315+
* for `null` or `undefined` values.
316+
*
317+
* @private
318+
* @param {*} value The value to process.
319+
* @returns {string} Returns the string.
320+
*/
321+
baseToString = function(value) {
322+
if (value === null) {
323+
return '';
324+
} else {
325+
return value + '';
326+
}
327+
};
328+
329+
/**
330+
* Converts `value` to property path array if it's not one.
331+
*
332+
* @private
333+
* @param {*} value The value to process.
334+
* @returns {Array} Returns the property path array.
335+
*/
336+
toPath = function(value) {
337+
var result;
338+
if (_.isArray(value)) {
339+
return value;
340+
}
341+
result = [];
342+
baseToString(value).replace(rePropName, function(match, number, quote, string) {
343+
result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);
344+
});
345+
return result;
346+
};
347+
348+
/**
349+
* The base implementation of `get` without support for string paths
350+
* and default values.
351+
*
352+
* @private
353+
* @param {Object} object The object to query.
354+
* @param {Array} path The path of the property to get.
355+
* @param {string} [pathKey] The key representation of path.
356+
* @returns {*} Returns the resolved value.
357+
*/
358+
baseGet = function(object, path, pathKey) {
359+
var index, length;
360+
if (object === null) {
361+
return;
362+
}
363+
if (pathKey !== void 0 && pathKey in toObject(object)) {
364+
path = [pathKey];
365+
}
366+
index = 0;
367+
length = path.length;
368+
while (!_.isUndefined(object) && index < length) {
369+
object = object[path[index++]];
370+
}
371+
if (index && index === length) {
372+
return object;
373+
} else {
374+
return void 0;
375+
}
376+
};
377+
378+
/**
379+
* Gets the property value at `path` of `object`. If the resolved value is
380+
* `undefined` the `defaultValue` is used in its place.
381+
*
382+
* @static
383+
* @memberOf _
384+
* @category Object
385+
* @param {Object} object The object to query.
386+
* @param {Array|string} path The path of the property to get.
387+
* @param {*} [defaultValue] The value returned if the resolved value is `undefined`.
388+
* @returns {*} Returns the resolved value.
389+
* @example
390+
*
391+
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
392+
*
393+
* _.get(object, 'a[0].b.c');
394+
* // => 3
395+
*
396+
* _.get(object, ['a', '0', 'b', 'c']);
397+
* // => 3
398+
*
399+
* _.get(object, 'a.b.c', 'default');
400+
* // => 'default'
401+
*/
402+
get = function(object, path, defaultValue) {
403+
var result;
404+
result = object === null ? void 0 : baseGet(object, toPath(path), path + '');
405+
if (result === void 0) {
406+
return defaultValue;
407+
} else {
408+
return result;
409+
}
410+
};
411+
_.get = get;
412+
}
292413

293414
/*
294415
Author Nick McCready

dist/angular-google-maps.min.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-google-maps_dev_mapped.js

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,127 @@ Nicholas McCready - https://twitter.com/nmccready
289289
}).call(this);
290290
;(function() {
291291
angular.module('uiGmapgoogle-maps.extensions').service('uiGmapLodash', function() {
292+
var baseGet, baseToString, get, reIsDeepProp, reIsPlainProp, rePropName, toObject, toPath;
293+
if (_.get == null) {
294+
reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/;
295+
reIsPlainProp = /^\w*$/;
296+
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
297+
298+
/**
299+
* Converts `value` to an object if it's not one.
300+
*
301+
* @private
302+
* @param {*} value The value to process.
303+
* @returns {Object} Returns the object.
304+
*/
305+
toObject = function(value) {
306+
if (_.isObject(value)) {
307+
return value;
308+
} else {
309+
return Object(value);
310+
}
311+
};
312+
313+
/**
314+
* Converts `value` to a string if it's not one. An empty string is returned
315+
* for `null` or `undefined` values.
316+
*
317+
* @private
318+
* @param {*} value The value to process.
319+
* @returns {string} Returns the string.
320+
*/
321+
baseToString = function(value) {
322+
if (value === null) {
323+
return '';
324+
} else {
325+
return value + '';
326+
}
327+
};
328+
329+
/**
330+
* Converts `value` to property path array if it's not one.
331+
*
332+
* @private
333+
* @param {*} value The value to process.
334+
* @returns {Array} Returns the property path array.
335+
*/
336+
toPath = function(value) {
337+
var result;
338+
if (_.isArray(value)) {
339+
return value;
340+
}
341+
result = [];
342+
baseToString(value).replace(rePropName, function(match, number, quote, string) {
343+
result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);
344+
});
345+
return result;
346+
};
347+
348+
/**
349+
* The base implementation of `get` without support for string paths
350+
* and default values.
351+
*
352+
* @private
353+
* @param {Object} object The object to query.
354+
* @param {Array} path The path of the property to get.
355+
* @param {string} [pathKey] The key representation of path.
356+
* @returns {*} Returns the resolved value.
357+
*/
358+
baseGet = function(object, path, pathKey) {
359+
var index, length;
360+
if (object === null) {
361+
return;
362+
}
363+
if (pathKey !== void 0 && pathKey in toObject(object)) {
364+
path = [pathKey];
365+
}
366+
index = 0;
367+
length = path.length;
368+
while (!_.isUndefined(object) && index < length) {
369+
object = object[path[index++]];
370+
}
371+
if (index && index === length) {
372+
return object;
373+
} else {
374+
return void 0;
375+
}
376+
};
377+
378+
/**
379+
* Gets the property value at `path` of `object`. If the resolved value is
380+
* `undefined` the `defaultValue` is used in its place.
381+
*
382+
* @static
383+
* @memberOf _
384+
* @category Object
385+
* @param {Object} object The object to query.
386+
* @param {Array|string} path The path of the property to get.
387+
* @param {*} [defaultValue] The value returned if the resolved value is `undefined`.
388+
* @returns {*} Returns the resolved value.
389+
* @example
390+
*
391+
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
392+
*
393+
* _.get(object, 'a[0].b.c');
394+
* // => 3
395+
*
396+
* _.get(object, ['a', '0', 'b', 'c']);
397+
* // => 3
398+
*
399+
* _.get(object, 'a.b.c', 'default');
400+
* // => 'default'
401+
*/
402+
get = function(object, path, defaultValue) {
403+
var result;
404+
result = object === null ? void 0 : baseGet(object, toPath(path), path + '');
405+
if (result === void 0) {
406+
return defaultValue;
407+
} else {
408+
return result;
409+
}
410+
};
411+
_.get = get;
412+
}
292413

293414
/*
294415
Author Nick McCready

dist/angular-google-maps_dev_mapped.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-google-maps_dev_mapped.min.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-google-maps_dev_mapped.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)