/node_modules/cordova-plugin-disable-bitcode/node_modules/lodash-node/compat/internals/iteratorTemplate.js

https://gitlab.com/blocknotary/IonicInterviews · JavaScript · 109 lines · 84 code · 10 blank · 15 comment · 49 complexity · 07d86f018299a8852ff6b8231eac14cb MD5 · raw file

  1. /**
  2. * Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
  3. * Build: `lodash modularize exports="node" -o ./compat/`
  4. * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
  5. * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
  6. * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  7. * Available under MIT license <http://lodash.com/license>
  8. */
  9. var support = require('../support');
  10. /**
  11. * The template used to create iterator functions.
  12. *
  13. * @private
  14. * @param {Object} data The data object used to populate the text.
  15. * @returns {string} Returns the interpolated text.
  16. */
  17. var iteratorTemplate = function(obj) {
  18. var __p = 'var index, iterable = ' +
  19. (obj.firstArg) +
  20. ', result = ' +
  21. (obj.init) +
  22. ';\nif (!iterable) return result;\n' +
  23. (obj.top) +
  24. ';';
  25. if (obj.array) {
  26. __p += '\nvar length = iterable.length; index = -1;\nif (' +
  27. (obj.array) +
  28. ') { ';
  29. if (support.unindexedChars) {
  30. __p += '\n if (isString(iterable)) {\n iterable = iterable.split(\'\')\n } ';
  31. }
  32. __p += '\n while (++index < length) {\n ' +
  33. (obj.loop) +
  34. ';\n }\n}\nelse { ';
  35. } else if (support.nonEnumArgs) {
  36. __p += '\n var length = iterable.length; index = -1;\n if (length && isArguments(iterable)) {\n while (++index < length) {\n index += \'\';\n ' +
  37. (obj.loop) +
  38. ';\n }\n } else { ';
  39. }
  40. if (support.enumPrototypes) {
  41. __p += '\n var skipProto = typeof iterable == \'function\';\n ';
  42. }
  43. if (support.enumErrorProps) {
  44. __p += '\n var skipErrorProps = iterable === errorProto || iterable instanceof Error;\n ';
  45. }
  46. var conditions = []; if (support.enumPrototypes) { conditions.push('!(skipProto && index == "prototype")'); } if (support.enumErrorProps) { conditions.push('!(skipErrorProps && (index == "message" || index == "name"))'); }
  47. if (obj.useHas && obj.keys) {
  48. __p += '\n var ownIndex = -1,\n ownProps = objectTypes[typeof iterable] && keys(iterable),\n length = ownProps ? ownProps.length : 0;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n';
  49. if (conditions.length) {
  50. __p += ' if (' +
  51. (conditions.join(' && ')) +
  52. ') {\n ';
  53. }
  54. __p +=
  55. (obj.loop) +
  56. '; ';
  57. if (conditions.length) {
  58. __p += '\n }';
  59. }
  60. __p += '\n } ';
  61. } else {
  62. __p += '\n for (index in iterable) {\n';
  63. if (obj.useHas) { conditions.push("hasOwnProperty.call(iterable, index)"); } if (conditions.length) {
  64. __p += ' if (' +
  65. (conditions.join(' && ')) +
  66. ') {\n ';
  67. }
  68. __p +=
  69. (obj.loop) +
  70. '; ';
  71. if (conditions.length) {
  72. __p += '\n }';
  73. }
  74. __p += '\n } ';
  75. if (support.nonEnumShadows) {
  76. __p += '\n\n if (iterable !== objectProto) {\n var ctor = iterable.constructor,\n isProto = iterable === (ctor && ctor.prototype),\n className = iterable === stringProto ? stringClass : iterable === errorProto ? errorClass : toString.call(iterable),\n nonEnum = nonEnumProps[className];\n ';
  77. for (k = 0; k < 7; k++) {
  78. __p += '\n index = \'' +
  79. (obj.shadowedProps[k]) +
  80. '\';\n if ((!(isProto && nonEnum[index]) && hasOwnProperty.call(iterable, index))';
  81. if (!obj.useHas) {
  82. __p += ' || (!nonEnum[index] && iterable[index] !== objectProto[index])';
  83. }
  84. __p += ') {\n ' +
  85. (obj.loop) +
  86. ';\n } ';
  87. }
  88. __p += '\n } ';
  89. }
  90. }
  91. if (obj.array || support.nonEnumArgs) {
  92. __p += '\n}';
  93. }
  94. __p +=
  95. (obj.bottom) +
  96. ';\nreturn result';
  97. return __p
  98. };
  99. module.exports = iteratorTemplate;