dss_tech_docs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +29 -0
  3. data/.gitignore +37 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +11 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +9 -0
  8. data/CHANGELOG.md +274 -0
  9. data/CONTRIBUTING.md +9 -0
  10. data/Gemfile +4 -0
  11. data/LICENCE +21 -0
  12. data/README.md +89 -0
  13. data/Rakefile +13 -0
  14. data/docs/configuration.md +205 -0
  15. data/docs/core-layout-without-sidebar.png +0 -0
  16. data/docs/core-layout.png +0 -0
  17. data/docs/expired-page.png +0 -0
  18. data/docs/frontmatter.md +145 -0
  19. data/docs/last-reviewed-only.png +0 -0
  20. data/docs/last-reviewed-only.svg +1 -0
  21. data/docs/layout-layout.png +0 -0
  22. data/docs/not-expired-page.png +0 -0
  23. data/docs/page-expiry.md +85 -0
  24. data/dss_tech_docs.gemspec +46 -0
  25. data/example/.ruby-version +1 -0
  26. data/example/Gemfile +3 -0
  27. data/example/config.rb +9 -0
  28. data/example/config/hide-expiry.yml +51 -0
  29. data/example/config/tech-docs.yml +50 -0
  30. data/example/source/api-path.html.md +7 -0
  31. data/example/source/api-reference.html.md +5 -0
  32. data/example/source/child-of-expired-page.html.md +8 -0
  33. data/example/source/core-layout-without-sidebar.html.md.erb +7 -0
  34. data/example/source/core-layout.html.md.erb +12 -0
  35. data/example/source/expired-page-with-owner.html.md +10 -0
  36. data/example/source/expired-page.html.md +9 -0
  37. data/example/source/headings.html.md +11 -0
  38. data/example/source/index.html.md.erb +19 -0
  39. data/example/source/javascripts/application.js +1 -0
  40. data/example/source/not-expired-page.html.md +9 -0
  41. data/example/source/pets.yml +109 -0
  42. data/example/source/stylesheets/print.css.scss +3 -0
  43. data/example/source/stylesheets/screen-old-ie.css.scss +4 -0
  44. data/example/source/stylesheets/screen.css.scss +1 -0
  45. data/example/source/templates/proxy_template.html.md +8 -0
  46. data/lib/assets/javascripts/_analytics.js +58 -0
  47. data/lib/assets/javascripts/_govuk/modules.js +57 -0
  48. data/lib/assets/javascripts/_modules/anchored-headings.js +18 -0
  49. data/lib/assets/javascripts/_modules/collapsible-navigation.js +95 -0
  50. data/lib/assets/javascripts/_modules/in-page-navigation.js +132 -0
  51. data/lib/assets/javascripts/_modules/navigation.js +34 -0
  52. data/lib/assets/javascripts/_modules/page-expiry.js +15 -0
  53. data/lib/assets/javascripts/_modules/search.js +367 -0
  54. data/lib/assets/javascripts/_modules/table-of-contents.js +111 -0
  55. data/lib/assets/javascripts/_start-modules.js +13 -0
  56. data/lib/assets/javascripts/_vendor/fixedsticky.js +194 -0
  57. data/lib/assets/javascripts/_vendor/jquery.js +5 -0
  58. data/lib/assets/javascripts/_vendor/jquery.mark.js +1081 -0
  59. data/lib/assets/javascripts/_vendor/lodash.js +613 -0
  60. data/lib/assets/javascripts/_vendor/modernizr.js +3 -0
  61. data/lib/assets/javascripts/govuk_tech_docs.js +10 -0
  62. data/lib/assets/stylesheets/_accessibility.scss +9 -0
  63. data/lib/assets/stylesheets/_core.scss +71 -0
  64. data/lib/assets/stylesheets/_fonts.scss +29 -0
  65. data/lib/assets/stylesheets/_govuk_tech_docs.scss +2 -0
  66. data/lib/assets/stylesheets/_syntax-highlighting.scss +196 -0
  67. data/lib/assets/stylesheets/_variables.scss +12 -0
  68. data/lib/assets/stylesheets/govuk_frontend_toolkit/_colours.scss +2 -0
  69. data/lib/assets/stylesheets/govuk_frontend_toolkit/_conditionals.scss +81 -0
  70. data/lib/assets/stylesheets/govuk_frontend_toolkit/_css3.scss +90 -0
  71. data/lib/assets/stylesheets/govuk_frontend_toolkit/_device-pixels.scss +10 -0
  72. data/lib/assets/stylesheets/govuk_frontend_toolkit/_font_stack.scss +19 -0
  73. data/lib/assets/stylesheets/govuk_frontend_toolkit/_grid_layout.scss +136 -0
  74. data/lib/assets/stylesheets/govuk_frontend_toolkit/_helpers.scss +16 -0
  75. data/lib/assets/stylesheets/govuk_frontend_toolkit/_measurements.scss +14 -0
  76. data/lib/assets/stylesheets/govuk_frontend_toolkit/_shims.scss +55 -0
  77. data/lib/assets/stylesheets/govuk_frontend_toolkit/_typography.scss +249 -0
  78. data/lib/assets/stylesheets/govuk_frontend_toolkit/_url-helpers.scss +16 -0
  79. data/lib/assets/stylesheets/govuk_frontend_toolkit/colours/_organisation.scss +103 -0
  80. data/lib/assets/stylesheets/govuk_frontend_toolkit/colours/_palette.scss +77 -0
  81. data/lib/assets/stylesheets/govuk_frontend_toolkit/design-patterns/_alpha-beta.scss +66 -0
  82. data/lib/assets/stylesheets/govuk_frontend_toolkit/design-patterns/_breadcrumbs.scss +53 -0
  83. data/lib/assets/stylesheets/govuk_frontend_toolkit/design-patterns/_buttons.scss +141 -0
  84. data/lib/assets/stylesheets/govuk_frontend_toolkit/design-patterns/_media-player.scss +242 -0
  85. data/lib/assets/stylesheets/modules/_anchored-heading.scss +54 -0
  86. data/lib/assets/stylesheets/modules/_app-pane.scss +64 -0
  87. data/lib/assets/stylesheets/modules/_collapsible.scss +52 -0
  88. data/lib/assets/stylesheets/modules/_contribution-banner.scss +22 -0
  89. data/lib/assets/stylesheets/modules/_footer.scss +130 -0
  90. data/lib/assets/stylesheets/modules/_govuk-logo.scss +47 -0
  91. data/lib/assets/stylesheets/modules/_header.scss +290 -0
  92. data/lib/assets/stylesheets/modules/_page-review.scss +35 -0
  93. data/lib/assets/stylesheets/modules/_phase-banner.scss +22 -0
  94. data/lib/assets/stylesheets/modules/_search.scss +137 -0
  95. data/lib/assets/stylesheets/modules/_skip-link.scss +31 -0
  96. data/lib/assets/stylesheets/modules/_technical-documentation.scss +241 -0
  97. data/lib/assets/stylesheets/modules/_toc.scss +216 -0
  98. data/lib/assets/stylesheets/modules/_warning-text.scss +73 -0
  99. data/lib/assets/stylesheets/palette/_syntax-highlighting.scss +23 -0
  100. data/lib/assets/stylesheets/utilities/_fonts.scss +29 -0
  101. data/lib/assets/stylesheets/utilities/_printable.scss +13 -0
  102. data/lib/assets/stylesheets/vendor/_fixedsticky.scss +22 -0
  103. data/lib/dss_tech_docs.rb +121 -0
  104. data/lib/govuk_tech_docs/api_reference/api_reference_extension.rb +101 -0
  105. data/lib/govuk_tech_docs/api_reference/api_reference_renderer.rb +279 -0
  106. data/lib/govuk_tech_docs/api_reference/templates/api_reference_full.html.erb +19 -0
  107. data/lib/govuk_tech_docs/api_reference/templates/operation.html.erb +11 -0
  108. data/lib/govuk_tech_docs/api_reference/templates/parameters.html.erb +28 -0
  109. data/lib/govuk_tech_docs/api_reference/templates/path.html.erb +4 -0
  110. data/lib/govuk_tech_docs/api_reference/templates/responses.html.erb +33 -0
  111. data/lib/govuk_tech_docs/api_reference/templates/schema.html.erb +29 -0
  112. data/lib/govuk_tech_docs/contribution_banner.rb +62 -0
  113. data/lib/govuk_tech_docs/meta_tags.rb +67 -0
  114. data/lib/govuk_tech_docs/page_review.rb +52 -0
  115. data/lib/govuk_tech_docs/pages.rb +32 -0
  116. data/lib/govuk_tech_docs/redirects.rb +39 -0
  117. data/lib/govuk_tech_docs/table_of_contents/heading.rb +30 -0
  118. data/lib/govuk_tech_docs/table_of_contents/heading_tree.rb +27 -0
  119. data/lib/govuk_tech_docs/table_of_contents/heading_tree_builder.rb +41 -0
  120. data/lib/govuk_tech_docs/table_of_contents/heading_tree_renderer.rb +46 -0
  121. data/lib/govuk_tech_docs/table_of_contents/headings_builder.rb +39 -0
  122. data/lib/govuk_tech_docs/table_of_contents/helpers.rb +79 -0
  123. data/lib/govuk_tech_docs/tech_docs_html_renderer.rb +34 -0
  124. data/lib/govuk_tech_docs/unique_identifier_extension.rb +13 -0
  125. data/lib/govuk_tech_docs/unique_identifier_generator.rb +72 -0
  126. data/lib/govuk_tech_docs/version.rb +3 -0
  127. data/lib/govuk_tech_docs/warning_text_extension.rb +23 -0
  128. data/lib/source/api/pages.json.erb +1 -0
  129. data/lib/source/favicon.ico +0 -0
  130. data/lib/source/images/anchored-heading-icon-2x.png +0 -0
  131. data/lib/source/images/anchored-heading-icon.png +0 -0
  132. data/lib/source/images/gov.uk_logotype_crown-2x.png +0 -0
  133. data/lib/source/images/gov.uk_logotype_crown.png +0 -0
  134. data/lib/source/images/gov.uk_logotype_crown_invert_trans.png +0 -0
  135. data/lib/source/images/govuk-crest-2x.png +0 -0
  136. data/lib/source/images/govuk-crest.png +0 -0
  137. data/lib/source/images/govuk-icn-close.png +0 -0
  138. data/lib/source/images/govuk-icn-close@2x.png +0 -0
  139. data/lib/source/images/govuk-icn-numbered-list.png +0 -0
  140. data/lib/source/images/govuk-icn-numbered-list@2x.png +0 -0
  141. data/lib/source/images/open-government-licence.png +0 -0
  142. data/lib/source/images/open-government-licence_2x.png +0 -0
  143. data/lib/source/images/search-result-caret.svg +13 -0
  144. data/lib/source/layouts/_analytics.erb +15 -0
  145. data/lib/source/layouts/_footer.erb +10 -0
  146. data/lib/source/layouts/_header.erb +44 -0
  147. data/lib/source/layouts/_page_review.erb +22 -0
  148. data/lib/source/layouts/_search.erb +16 -0
  149. data/lib/source/layouts/core.erb +82 -0
  150. data/lib/source/layouts/layout.erb +18 -0
  151. metadata +474 -0
@@ -0,0 +1,613 @@
1
+ /**
2
+ * @license
3
+ * Lodash (Custom Build) <https://lodash.com/>
4
+ * Build: `lodash -d -o lodash.js include="debounce" exports="global"`
5
+ * Copyright JS Foundation and other contributors <https://js.foundation/>
6
+ * Released under MIT license <https://lodash.com/license>
7
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
8
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
9
+ */
10
+ ;(function() {
11
+
12
+ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
13
+ var undefined;
14
+
15
+ /** Used as the semantic version number. */
16
+ var VERSION = '4.17.4';
17
+
18
+ /** Error message constants. */
19
+ var FUNC_ERROR_TEXT = 'Expected a function';
20
+
21
+ /** Used as references for various `Number` constants. */
22
+ var NAN = 0 / 0;
23
+
24
+ /** `Object#toString` result references. */
25
+ var nullTag = '[object Null]',
26
+ symbolTag = '[object Symbol]',
27
+ undefinedTag = '[object Undefined]';
28
+
29
+ /** Used to match leading and trailing whitespace. */
30
+ var reTrim = /^\s+|\s+$/g;
31
+
32
+ /** Used to detect bad signed hexadecimal string values. */
33
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
34
+
35
+ /** Used to detect binary string values. */
36
+ var reIsBinary = /^0b[01]+$/i;
37
+
38
+ /** Used to detect octal string values. */
39
+ var reIsOctal = /^0o[0-7]+$/i;
40
+
41
+ /** Built-in method references without a dependency on `root`. */
42
+ var freeParseInt = parseInt;
43
+
44
+ /** Detect free variable `global` from Node.js. */
45
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
46
+
47
+ /** Detect free variable `self`. */
48
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
49
+
50
+ /** Used as a reference to the global object. */
51
+ var root = freeGlobal || freeSelf || Function('return this')();
52
+
53
+ /*--------------------------------------------------------------------------*/
54
+
55
+ /** Used for built-in method references. */
56
+ var objectProto = Object.prototype;
57
+
58
+ /** Used to check objects for own properties. */
59
+ var hasOwnProperty = objectProto.hasOwnProperty;
60
+
61
+ /**
62
+ * Used to resolve the
63
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
64
+ * of values.
65
+ */
66
+ var nativeObjectToString = objectProto.toString;
67
+
68
+ /** Built-in value references. */
69
+ var Symbol = root.Symbol,
70
+ symToStringTag = Symbol ? Symbol.toStringTag : undefined;
71
+
72
+ /* Built-in method references for those with the same name as other `lodash` methods. */
73
+ var nativeMax = Math.max,
74
+ nativeMin = Math.min;
75
+
76
+ /** Used to lookup unminified function names. */
77
+ var realNames = {};
78
+
79
+ /*------------------------------------------------------------------------*/
80
+
81
+ /**
82
+ * Creates a `lodash` object which wraps `value` to enable implicit method
83
+ * chain sequences. Methods that operate on and return arrays, collections,
84
+ * and functions can be chained together. Methods that retrieve a single value
85
+ * or may return a primitive value will automatically end the chain sequence
86
+ * and return the unwrapped value. Otherwise, the value must be unwrapped
87
+ * with `_#value`.
88
+ *
89
+ * Explicit chain sequences, which must be unwrapped with `_#value`, may be
90
+ * enabled using `_.chain`.
91
+ *
92
+ * The execution of chained methods is lazy, that is, it's deferred until
93
+ * `_#value` is implicitly or explicitly called.
94
+ *
95
+ * Lazy evaluation allows several methods to support shortcut fusion.
96
+ * Shortcut fusion is an optimization to merge iteratee calls; this avoids
97
+ * the creation of intermediate arrays and can greatly reduce the number of
98
+ * iteratee executions. Sections of a chain sequence qualify for shortcut
99
+ * fusion if the section is applied to an array and iteratees accept only
100
+ * one argument. The heuristic for whether a section qualifies for shortcut
101
+ * fusion is subject to change.
102
+ *
103
+ * Chaining is supported in custom builds as long as the `_#value` method is
104
+ * directly or indirectly included in the build.
105
+ *
106
+ * In addition to lodash methods, wrappers have `Array` and `String` methods.
107
+ *
108
+ * The wrapper `Array` methods are:
109
+ * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
110
+ *
111
+ * The wrapper `String` methods are:
112
+ * `replace` and `split`
113
+ *
114
+ * The wrapper methods that support shortcut fusion are:
115
+ * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
116
+ * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
117
+ * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
118
+ *
119
+ * The chainable wrapper methods are:
120
+ * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
121
+ * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
122
+ * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
123
+ * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
124
+ * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
125
+ * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
126
+ * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
127
+ * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
128
+ * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
129
+ * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
130
+ * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
131
+ * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
132
+ * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
133
+ * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
134
+ * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
135
+ * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
136
+ * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
137
+ * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
138
+ * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
139
+ * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
140
+ * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
141
+ * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
142
+ * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
143
+ * `zipObject`, `zipObjectDeep`, and `zipWith`
144
+ *
145
+ * The wrapper methods that are **not** chainable by default are:
146
+ * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
147
+ * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
148
+ * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
149
+ * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
150
+ * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
151
+ * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
152
+ * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
153
+ * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
154
+ * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
155
+ * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
156
+ * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
157
+ * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
158
+ * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
159
+ * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
160
+ * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
161
+ * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
162
+ * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
163
+ * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
164
+ * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
165
+ * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
166
+ * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
167
+ * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
168
+ * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
169
+ * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
170
+ * `upperFirst`, `value`, and `words`
171
+ *
172
+ * @name _
173
+ * @constructor
174
+ * @category Seq
175
+ * @param {*} value The value to wrap in a `lodash` instance.
176
+ * @returns {Object} Returns the new `lodash` wrapper instance.
177
+ * @example
178
+ *
179
+ * function square(n) {
180
+ * return n * n;
181
+ * }
182
+ *
183
+ * var wrapped = _([1, 2, 3]);
184
+ *
185
+ * // Returns an unwrapped value.
186
+ * wrapped.reduce(_.add);
187
+ * // => 6
188
+ *
189
+ * // Returns a wrapped value.
190
+ * var squares = wrapped.map(square);
191
+ *
192
+ * _.isArray(squares);
193
+ * // => false
194
+ *
195
+ * _.isArray(squares.value());
196
+ * // => true
197
+ */
198
+ function lodash() {
199
+ // No operation performed.
200
+ }
201
+
202
+ /*------------------------------------------------------------------------*/
203
+
204
+ /**
205
+ * The base implementation of `getTag` without fallbacks for buggy environments.
206
+ *
207
+ * @private
208
+ * @param {*} value The value to query.
209
+ * @returns {string} Returns the `toStringTag`.
210
+ */
211
+ function baseGetTag(value) {
212
+ if (value == null) {
213
+ return value === undefined ? undefinedTag : nullTag;
214
+ }
215
+ return (symToStringTag && symToStringTag in Object(value))
216
+ ? getRawTag(value)
217
+ : objectToString(value);
218
+ }
219
+
220
+ /**
221
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
222
+ *
223
+ * @private
224
+ * @param {*} value The value to query.
225
+ * @returns {string} Returns the raw `toStringTag`.
226
+ */
227
+ function getRawTag(value) {
228
+ var isOwn = hasOwnProperty.call(value, symToStringTag),
229
+ tag = value[symToStringTag];
230
+
231
+ try {
232
+ value[symToStringTag] = undefined;
233
+ var unmasked = true;
234
+ } catch (e) {}
235
+
236
+ var result = nativeObjectToString.call(value);
237
+ if (unmasked) {
238
+ if (isOwn) {
239
+ value[symToStringTag] = tag;
240
+ } else {
241
+ delete value[symToStringTag];
242
+ }
243
+ }
244
+ return result;
245
+ }
246
+
247
+ /**
248
+ * Converts `value` to a string using `Object.prototype.toString`.
249
+ *
250
+ * @private
251
+ * @param {*} value The value to convert.
252
+ * @returns {string} Returns the converted string.
253
+ */
254
+ function objectToString(value) {
255
+ return nativeObjectToString.call(value);
256
+ }
257
+
258
+ /*------------------------------------------------------------------------*/
259
+
260
+ /**
261
+ * Gets the timestamp of the number of milliseconds that have elapsed since
262
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
263
+ *
264
+ * @static
265
+ * @memberOf _
266
+ * @since 2.4.0
267
+ * @category Date
268
+ * @returns {number} Returns the timestamp.
269
+ * @example
270
+ *
271
+ * _.defer(function(stamp) {
272
+ * console.log(_.now() - stamp);
273
+ * }, _.now());
274
+ * // => Logs the number of milliseconds it took for the deferred invocation.
275
+ */
276
+ var now = function() {
277
+ return root.Date.now();
278
+ };
279
+
280
+ /*------------------------------------------------------------------------*/
281
+
282
+ /**
283
+ * Creates a debounced function that delays invoking `func` until after `wait`
284
+ * milliseconds have elapsed since the last time the debounced function was
285
+ * invoked. The debounced function comes with a `cancel` method to cancel
286
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
287
+ * Provide `options` to indicate whether `func` should be invoked on the
288
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
289
+ * with the last arguments provided to the debounced function. Subsequent
290
+ * calls to the debounced function return the result of the last `func`
291
+ * invocation.
292
+ *
293
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
294
+ * invoked on the trailing edge of the timeout only if the debounced function
295
+ * is invoked more than once during the `wait` timeout.
296
+ *
297
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
298
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
299
+ *
300
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
301
+ * for details over the differences between `_.debounce` and `_.throttle`.
302
+ *
303
+ * @static
304
+ * @memberOf _
305
+ * @since 0.1.0
306
+ * @category Function
307
+ * @param {Function} func The function to debounce.
308
+ * @param {number} [wait=0] The number of milliseconds to delay.
309
+ * @param {Object} [options={}] The options object.
310
+ * @param {boolean} [options.leading=false]
311
+ * Specify invoking on the leading edge of the timeout.
312
+ * @param {number} [options.maxWait]
313
+ * The maximum time `func` is allowed to be delayed before it's invoked.
314
+ * @param {boolean} [options.trailing=true]
315
+ * Specify invoking on the trailing edge of the timeout.
316
+ * @returns {Function} Returns the new debounced function.
317
+ * @example
318
+ *
319
+ * // Avoid costly calculations while the window size is in flux.
320
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
321
+ *
322
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
323
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
324
+ * 'leading': true,
325
+ * 'trailing': false
326
+ * }));
327
+ *
328
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
329
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
330
+ * var source = new EventSource('/stream');
331
+ * jQuery(source).on('message', debounced);
332
+ *
333
+ * // Cancel the trailing debounced invocation.
334
+ * jQuery(window).on('popstate', debounced.cancel);
335
+ */
336
+ function debounce(func, wait, options) {
337
+ var lastArgs,
338
+ lastThis,
339
+ maxWait,
340
+ result,
341
+ timerId,
342
+ lastCallTime,
343
+ lastInvokeTime = 0,
344
+ leading = false,
345
+ maxing = false,
346
+ trailing = true;
347
+
348
+ if (typeof func != 'function') {
349
+ throw new TypeError(FUNC_ERROR_TEXT);
350
+ }
351
+ wait = toNumber(wait) || 0;
352
+ if (isObject(options)) {
353
+ leading = !!options.leading;
354
+ maxing = 'maxWait' in options;
355
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
356
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
357
+ }
358
+
359
+ function invokeFunc(time) {
360
+ var args = lastArgs,
361
+ thisArg = lastThis;
362
+
363
+ lastArgs = lastThis = undefined;
364
+ lastInvokeTime = time;
365
+ result = func.apply(thisArg, args);
366
+ return result;
367
+ }
368
+
369
+ function leadingEdge(time) {
370
+ // Reset any `maxWait` timer.
371
+ lastInvokeTime = time;
372
+ // Start the timer for the trailing edge.
373
+ timerId = setTimeout(timerExpired, wait);
374
+ // Invoke the leading edge.
375
+ return leading ? invokeFunc(time) : result;
376
+ }
377
+
378
+ function remainingWait(time) {
379
+ var timeSinceLastCall = time - lastCallTime,
380
+ timeSinceLastInvoke = time - lastInvokeTime,
381
+ result = wait - timeSinceLastCall;
382
+
383
+ return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
384
+ }
385
+
386
+ function shouldInvoke(time) {
387
+ var timeSinceLastCall = time - lastCallTime,
388
+ timeSinceLastInvoke = time - lastInvokeTime;
389
+
390
+ // Either this is the first call, activity has stopped and we're at the
391
+ // trailing edge, the system time has gone backwards and we're treating
392
+ // it as the trailing edge, or we've hit the `maxWait` limit.
393
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
394
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
395
+ }
396
+
397
+ function timerExpired() {
398
+ var time = now();
399
+ if (shouldInvoke(time)) {
400
+ return trailingEdge(time);
401
+ }
402
+ // Restart the timer.
403
+ timerId = setTimeout(timerExpired, remainingWait(time));
404
+ }
405
+
406
+ function trailingEdge(time) {
407
+ timerId = undefined;
408
+
409
+ // Only invoke if we have `lastArgs` which means `func` has been
410
+ // debounced at least once.
411
+ if (trailing && lastArgs) {
412
+ return invokeFunc(time);
413
+ }
414
+ lastArgs = lastThis = undefined;
415
+ return result;
416
+ }
417
+
418
+ function cancel() {
419
+ if (timerId !== undefined) {
420
+ clearTimeout(timerId);
421
+ }
422
+ lastInvokeTime = 0;
423
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
424
+ }
425
+
426
+ function flush() {
427
+ return timerId === undefined ? result : trailingEdge(now());
428
+ }
429
+
430
+ function debounced() {
431
+ var time = now(),
432
+ isInvoking = shouldInvoke(time);
433
+
434
+ lastArgs = arguments;
435
+ lastThis = this;
436
+ lastCallTime = time;
437
+
438
+ if (isInvoking) {
439
+ if (timerId === undefined) {
440
+ return leadingEdge(lastCallTime);
441
+ }
442
+ if (maxing) {
443
+ // Handle invocations in a tight loop.
444
+ timerId = setTimeout(timerExpired, wait);
445
+ return invokeFunc(lastCallTime);
446
+ }
447
+ }
448
+ if (timerId === undefined) {
449
+ timerId = setTimeout(timerExpired, wait);
450
+ }
451
+ return result;
452
+ }
453
+ debounced.cancel = cancel;
454
+ debounced.flush = flush;
455
+ return debounced;
456
+ }
457
+
458
+ /*------------------------------------------------------------------------*/
459
+
460
+ /**
461
+ * Checks if `value` is the
462
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
463
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
464
+ *
465
+ * @static
466
+ * @memberOf _
467
+ * @since 0.1.0
468
+ * @category Lang
469
+ * @param {*} value The value to check.
470
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
471
+ * @example
472
+ *
473
+ * _.isObject({});
474
+ * // => true
475
+ *
476
+ * _.isObject([1, 2, 3]);
477
+ * // => true
478
+ *
479
+ * _.isObject(_.noop);
480
+ * // => true
481
+ *
482
+ * _.isObject(null);
483
+ * // => false
484
+ */
485
+ function isObject(value) {
486
+ var type = typeof value;
487
+ return value != null && (type == 'object' || type == 'function');
488
+ }
489
+
490
+ /**
491
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
492
+ * and has a `typeof` result of "object".
493
+ *
494
+ * @static
495
+ * @memberOf _
496
+ * @since 4.0.0
497
+ * @category Lang
498
+ * @param {*} value The value to check.
499
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
500
+ * @example
501
+ *
502
+ * _.isObjectLike({});
503
+ * // => true
504
+ *
505
+ * _.isObjectLike([1, 2, 3]);
506
+ * // => true
507
+ *
508
+ * _.isObjectLike(_.noop);
509
+ * // => false
510
+ *
511
+ * _.isObjectLike(null);
512
+ * // => false
513
+ */
514
+ function isObjectLike(value) {
515
+ return value != null && typeof value == 'object';
516
+ }
517
+
518
+ /**
519
+ * Checks if `value` is classified as a `Symbol` primitive or object.
520
+ *
521
+ * @static
522
+ * @memberOf _
523
+ * @since 4.0.0
524
+ * @category Lang
525
+ * @param {*} value The value to check.
526
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
527
+ * @example
528
+ *
529
+ * _.isSymbol(Symbol.iterator);
530
+ * // => true
531
+ *
532
+ * _.isSymbol('abc');
533
+ * // => false
534
+ */
535
+ function isSymbol(value) {
536
+ return typeof value == 'symbol' ||
537
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
538
+ }
539
+
540
+ /**
541
+ * Converts `value` to a number.
542
+ *
543
+ * @static
544
+ * @memberOf _
545
+ * @since 4.0.0
546
+ * @category Lang
547
+ * @param {*} value The value to process.
548
+ * @returns {number} Returns the number.
549
+ * @example
550
+ *
551
+ * _.toNumber(3.2);
552
+ * // => 3.2
553
+ *
554
+ * _.toNumber(Number.MIN_VALUE);
555
+ * // => 5e-324
556
+ *
557
+ * _.toNumber(Infinity);
558
+ * // => Infinity
559
+ *
560
+ * _.toNumber('3.2');
561
+ * // => 3.2
562
+ */
563
+ function toNumber(value) {
564
+ if (typeof value == 'number') {
565
+ return value;
566
+ }
567
+ if (isSymbol(value)) {
568
+ return NAN;
569
+ }
570
+ if (isObject(value)) {
571
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
572
+ value = isObject(other) ? (other + '') : other;
573
+ }
574
+ if (typeof value != 'string') {
575
+ return value === 0 ? value : +value;
576
+ }
577
+ value = value.replace(reTrim, '');
578
+ var isBinary = reIsBinary.test(value);
579
+ return (isBinary || reIsOctal.test(value))
580
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
581
+ : (reIsBadHex.test(value) ? NAN : +value);
582
+ }
583
+
584
+ /*------------------------------------------------------------------------*/
585
+
586
+ // Add methods that return wrapped values in chain sequences.
587
+ lodash.debounce = debounce;
588
+
589
+ /*------------------------------------------------------------------------*/
590
+
591
+ // Add methods that return unwrapped values in chain sequences.
592
+ lodash.isObject = isObject;
593
+ lodash.isObjectLike = isObjectLike;
594
+ lodash.isSymbol = isSymbol;
595
+ lodash.now = now;
596
+ lodash.toNumber = toNumber;
597
+
598
+ /*------------------------------------------------------------------------*/
599
+
600
+ /**
601
+ * The semantic version number.
602
+ *
603
+ * @static
604
+ * @memberOf _
605
+ * @type {string}
606
+ */
607
+ lodash.VERSION = VERSION;
608
+
609
+ /*--------------------------------------------------------------------------*/
610
+
611
+ // Export to the global object.
612
+ root._ = lodash;
613
+ }.call(this));