@dev-sergeev/datalab-kit 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +23 -5
  3. package/THIRD_PARTY_NOTICES.md +6 -2
  4. package/dist/extension.js +8 -1
  5. package/dist/recap.d.ts +2 -0
  6. package/dist/recap.js +31 -0
  7. package/docs/adr/0002-package-delivery.md +2 -0
  8. package/node_modules/@pi-plugins/elapsed/LICENSE +21 -0
  9. package/node_modules/@pi-plugins/elapsed/README.md +45 -0
  10. package/node_modules/@pi-plugins/elapsed/dist/index.d.mts +8 -0
  11. package/node_modules/@pi-plugins/elapsed/dist/index.d.mts.map +1 -0
  12. package/node_modules/@pi-plugins/elapsed/dist/index.mjs +47 -0
  13. package/node_modules/@pi-plugins/elapsed/dist/index.mjs.map +1 -0
  14. package/node_modules/@pi-plugins/elapsed/package.json +65 -0
  15. package/node_modules/@tifan/pi-recap/README.md +61 -0
  16. package/node_modules/@tifan/pi-recap/package.json +43 -0
  17. package/node_modules/@tifan/pi-recap/src/index.ts +584 -0
  18. package/node_modules/@tifan/pi-recap/src/model-picker.ts +233 -0
  19. package/node_modules/@tifan/pi-recap/src/models.ts +183 -0
  20. package/node_modules/@tifan/pi-recap/src/sanitize.ts +119 -0
  21. package/node_modules/@tifan/pi-recap/src/tui.ts +155 -0
  22. package/node_modules/@zigai/pi-extension-internals/README.md +24 -0
  23. package/node_modules/@zigai/pi-extension-internals/dist/editor-enhancer-registry.d.ts +21 -0
  24. package/node_modules/@zigai/pi-extension-internals/dist/editor-enhancer-registry.js +233 -0
  25. package/node_modules/@zigai/pi-extension-internals/dist/index.d.ts +6 -0
  26. package/node_modules/@zigai/pi-extension-internals/dist/index.js +3 -0
  27. package/node_modules/@zigai/pi-extension-internals/dist/linked-method-patch.d.ts +34 -0
  28. package/node_modules/@zigai/pi-extension-internals/dist/linked-method-patch.js +272 -0
  29. package/node_modules/@zigai/pi-extension-internals/dist/pi-internal-import.d.ts +11 -0
  30. package/node_modules/@zigai/pi-extension-internals/dist/pi-internal-import.js +139 -0
  31. package/node_modules/@zigai/pi-extension-internals/package.json +41 -0
  32. package/node_modules/@zigai/pi-extension-settings/LICENSE +21 -0
  33. package/node_modules/@zigai/pi-extension-settings/README.md +36 -0
  34. package/node_modules/@zigai/pi-extension-settings/dist/artifacts.d.ts +23 -0
  35. package/node_modules/@zigai/pi-extension-settings/dist/artifacts.d.ts.map +1 -0
  36. package/node_modules/@zigai/pi-extension-settings/dist/artifacts.js +75 -0
  37. package/node_modules/@zigai/pi-extension-settings/dist/artifacts.js.map +1 -0
  38. package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.d.ts +3 -0
  39. package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.d.ts.map +1 -0
  40. package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.js +5 -0
  41. package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.js.map +1 -0
  42. package/node_modules/@zigai/pi-extension-settings/dist/cli.d.ts +6 -0
  43. package/node_modules/@zigai/pi-extension-settings/dist/cli.d.ts.map +1 -0
  44. package/node_modules/@zigai/pi-extension-settings/dist/cli.js +87 -0
  45. package/node_modules/@zigai/pi-extension-settings/dist/cli.js.map +1 -0
  46. package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.d.ts +2 -0
  47. package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.d.ts.map +1 -0
  48. package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.js +2 -0
  49. package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.js.map +1 -0
  50. package/node_modules/@zigai/pi-extension-settings/dist/definition.d.ts +159 -0
  51. package/node_modules/@zigai/pi-extension-settings/dist/definition.d.ts.map +1 -0
  52. package/node_modules/@zigai/pi-extension-settings/dist/definition.js +248 -0
  53. package/node_modules/@zigai/pi-extension-settings/dist/definition.js.map +1 -0
  54. package/node_modules/@zigai/pi-extension-settings/dist/file-system.d.ts +10 -0
  55. package/node_modules/@zigai/pi-extension-settings/dist/file-system.d.ts.map +1 -0
  56. package/node_modules/@zigai/pi-extension-settings/dist/file-system.js +115 -0
  57. package/node_modules/@zigai/pi-extension-settings/dist/file-system.js.map +1 -0
  58. package/node_modules/@zigai/pi-extension-settings/dist/index.d.ts +2 -0
  59. package/node_modules/@zigai/pi-extension-settings/dist/index.d.ts.map +1 -0
  60. package/node_modules/@zigai/pi-extension-settings/dist/index.js +2 -0
  61. package/node_modules/@zigai/pi-extension-settings/dist/index.js.map +1 -0
  62. package/node_modules/@zigai/pi-extension-settings/dist/json-value.d.ts +18 -0
  63. package/node_modules/@zigai/pi-extension-settings/dist/json-value.d.ts.map +1 -0
  64. package/node_modules/@zigai/pi-extension-settings/dist/json-value.js +56 -0
  65. package/node_modules/@zigai/pi-extension-settings/dist/json-value.js.map +1 -0
  66. package/node_modules/@zigai/pi-extension-settings/dist/paths.d.ts +11 -0
  67. package/node_modules/@zigai/pi-extension-settings/dist/paths.d.ts.map +1 -0
  68. package/node_modules/@zigai/pi-extension-settings/dist/paths.js +23 -0
  69. package/node_modules/@zigai/pi-extension-settings/dist/paths.js.map +1 -0
  70. package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.d.ts +5 -0
  71. package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.d.ts.map +1 -0
  72. package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.js +21 -0
  73. package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.js.map +1 -0
  74. package/node_modules/@zigai/pi-extension-settings/dist/pi.d.ts +106 -0
  75. package/node_modules/@zigai/pi-extension-settings/dist/pi.d.ts.map +1 -0
  76. package/node_modules/@zigai/pi-extension-settings/dist/pi.js +122 -0
  77. package/node_modules/@zigai/pi-extension-settings/dist/pi.js.map +1 -0
  78. package/node_modules/@zigai/pi-extension-settings/dist/pi.ts +2537 -0
  79. package/node_modules/@zigai/pi-extension-settings/dist/pi.ts.map +7 -0
  80. package/node_modules/@zigai/pi-extension-settings/dist/projects.d.ts +10 -0
  81. package/node_modules/@zigai/pi-extension-settings/dist/projects.d.ts.map +1 -0
  82. package/node_modules/@zigai/pi-extension-settings/dist/projects.js +177 -0
  83. package/node_modules/@zigai/pi-extension-settings/dist/projects.js.map +1 -0
  84. package/node_modules/@zigai/pi-extension-settings/dist/runtime.d.ts +40 -0
  85. package/node_modules/@zigai/pi-extension-settings/dist/runtime.d.ts.map +1 -0
  86. package/node_modules/@zigai/pi-extension-settings/dist/runtime.js +158 -0
  87. package/node_modules/@zigai/pi-extension-settings/dist/runtime.js.map +1 -0
  88. package/node_modules/@zigai/pi-extension-settings/dist/runtime.ts +158 -0
  89. package/node_modules/@zigai/pi-extension-settings/dist/runtime.ts.map +7 -0
  90. package/node_modules/@zigai/pi-extension-settings/dist/schema-document.d.ts +19 -0
  91. package/node_modules/@zigai/pi-extension-settings/dist/schema-document.d.ts.map +1 -0
  92. package/node_modules/@zigai/pi-extension-settings/dist/schema-document.js +168 -0
  93. package/node_modules/@zigai/pi-extension-settings/dist/schema-document.js.map +1 -0
  94. package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.d.ts +9 -0
  95. package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.d.ts.map +1 -0
  96. package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.js +242 -0
  97. package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.js.map +1 -0
  98. package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.d.ts +59 -0
  99. package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.d.ts.map +1 -0
  100. package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.js +98 -0
  101. package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.js.map +1 -0
  102. package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.d.ts +80 -0
  103. package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.d.ts.map +1 -0
  104. package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.js +144 -0
  105. package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.js.map +1 -0
  106. package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.d.ts +5 -0
  107. package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.d.ts.map +1 -0
  108. package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.js +30 -0
  109. package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.js.map +1 -0
  110. package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.d.ts +10 -0
  111. package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.d.ts.map +1 -0
  112. package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.js +16 -0
  113. package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.js.map +1 -0
  114. package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.d.ts +54 -0
  115. package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.d.ts.map +1 -0
  116. package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.js +202 -0
  117. package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.js.map +1 -0
  118. package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.d.ts +5 -0
  119. package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.d.ts.map +1 -0
  120. package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.js +9 -0
  121. package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.js.map +1 -0
  122. package/node_modules/@zigai/pi-extension-settings/docs/generation.md +71 -0
  123. package/node_modules/@zigai/pi-extension-settings/docs/manual-setup.md +98 -0
  124. package/node_modules/@zigai/pi-extension-settings/docs/runtime.md +100 -0
  125. package/node_modules/@zigai/pi-extension-settings/docs/ui-controls.md +31 -0
  126. package/node_modules/@zigai/pi-extension-settings/package.json +97 -0
  127. package/node_modules/@zigai/pi-mention-anything/README.md +113 -0
  128. package/node_modules/@zigai/pi-mention-anything/config.schema.json +313 -0
  129. package/node_modules/@zigai/pi-mention-anything/docs/command-protocol.md +106 -0
  130. package/node_modules/@zigai/pi-mention-anything/docs/providers.md +128 -0
  131. package/node_modules/@zigai/pi-mention-anything/examples/query-command.mjs +96 -0
  132. package/node_modules/@zigai/pi-mention-anything/examples/recursive-tree.ts +28 -0
  133. package/node_modules/@zigai/pi-mention-anything/examples/static.ts +28 -0
  134. package/node_modules/@zigai/pi-mention-anything/examples/tmux.ts +90 -0
  135. package/node_modules/@zigai/pi-mention-anything/examples/tree-settings.json +25 -0
  136. package/node_modules/@zigai/pi-mention-anything/package.json +58 -0
  137. package/node_modules/@zigai/pi-mention-anything/src/api.ts +75 -0
  138. package/node_modules/@zigai/pi-mention-anything/src/autocomplete.ts +231 -0
  139. package/node_modules/@zigai/pi-mention-anything/src/chain-autocomplete.ts +596 -0
  140. package/node_modules/@zigai/pi-mention-anything/src/chain-syntax.ts +345 -0
  141. package/node_modules/@zigai/pi-mention-anything/src/command-provider.ts +291 -0
  142. package/node_modules/@zigai/pi-mention-anything/src/configured-source.ts +66 -0
  143. package/node_modules/@zigai/pi-mention-anything/src/editor.ts +180 -0
  144. package/node_modules/@zigai/pi-mention-anything/src/expand-mentions.ts +162 -0
  145. package/node_modules/@zigai/pi-mention-anything/src/index.ts +54 -0
  146. package/node_modules/@zigai/pi-mention-anything/src/initial-suggestions.ts +190 -0
  147. package/node_modules/@zigai/pi-mention-anything/src/list-provider.ts +71 -0
  148. package/node_modules/@zigai/pi-mention-anything/src/mention-hub.ts +307 -0
  149. package/node_modules/@zigai/pi-mention-anything/src/mention-resolution.ts +374 -0
  150. package/node_modules/@zigai/pi-mention-anything/src/mention-syntax.ts +105 -0
  151. package/node_modules/@zigai/pi-mention-anything/src/register-mention.ts +89 -0
  152. package/node_modules/@zigai/pi-mention-anything/src/rendering.ts +53 -0
  153. package/node_modules/@zigai/pi-mention-anything/src/selected-items.ts +21 -0
  154. package/node_modules/@zigai/pi-mention-anything/src/selection-history.ts +135 -0
  155. package/node_modules/@zigai/pi-mention-anything/src/settings-input.ts +317 -0
  156. package/node_modules/@zigai/pi-mention-anything/src/settings.prevalidated.ts +57 -0
  157. package/node_modules/@zigai/pi-mention-anything/src/settings.ts +52 -0
  158. package/node_modules/@zigai/pi-mention-anything/src/source-contract.ts +174 -0
  159. package/node_modules/@zigai/pi-mention-anything/src/source-controller.ts +1070 -0
  160. package/node_modules/@zigai/pi-mention-anything/src/source-runtime.ts +99 -0
  161. package/node_modules/@zigai/pi-mention-skill/README.md +60 -0
  162. package/node_modules/@zigai/pi-mention-skill/config.schema.json +81 -0
  163. package/node_modules/@zigai/pi-mention-skill/package.json +56 -0
  164. package/node_modules/@zigai/pi-mention-skill/src/index.ts +60 -0
  165. package/node_modules/@zigai/pi-mention-skill/src/settings-input.ts +74 -0
  166. package/node_modules/@zigai/pi-mention-skill/src/settings.prevalidated.ts +18 -0
  167. package/node_modules/@zigai/pi-mention-skill/src/settings.ts +54 -0
  168. package/node_modules/@zigai/pi-mention-skill/src/skill-commands.ts +18 -0
  169. package/node_modules/@zigai/pi-mention-skill/src/skill-content.ts +60 -0
  170. package/node_modules/@zigai/pi-mention-skill/src/skill-provider.ts +105 -0
  171. package/node_modules/@zigai/pi-mention-skill/src/slash-skill-filter.ts +29 -0
  172. package/node_modules/argparse/LICENSE +21 -0
  173. package/node_modules/argparse/README.md +257 -0
  174. package/node_modules/argparse/index.js +3 -0
  175. package/node_modules/argparse/lib/action/append/constant.js +47 -0
  176. package/node_modules/argparse/lib/action/append.js +53 -0
  177. package/node_modules/argparse/lib/action/count.js +40 -0
  178. package/node_modules/argparse/lib/action/help.js +47 -0
  179. package/node_modules/argparse/lib/action/store/constant.js +43 -0
  180. package/node_modules/argparse/lib/action/store/false.js +27 -0
  181. package/node_modules/argparse/lib/action/store/true.js +26 -0
  182. package/node_modules/argparse/lib/action/store.js +50 -0
  183. package/node_modules/argparse/lib/action/subparsers.js +149 -0
  184. package/node_modules/argparse/lib/action/version.js +47 -0
  185. package/node_modules/argparse/lib/action.js +146 -0
  186. package/node_modules/argparse/lib/action_container.js +482 -0
  187. package/node_modules/argparse/lib/argparse.js +14 -0
  188. package/node_modules/argparse/lib/argument/error.js +50 -0
  189. package/node_modules/argparse/lib/argument/exclusive.js +54 -0
  190. package/node_modules/argparse/lib/argument/group.js +75 -0
  191. package/node_modules/argparse/lib/argument_parser.js +1161 -0
  192. package/node_modules/argparse/lib/const.js +21 -0
  193. package/node_modules/argparse/lib/help/added_formatters.js +87 -0
  194. package/node_modules/argparse/lib/help/formatter.js +795 -0
  195. package/node_modules/argparse/lib/namespace.js +76 -0
  196. package/node_modules/argparse/lib/utils.js +57 -0
  197. package/node_modules/argparse/package.json +34 -0
  198. package/node_modules/esprima/LICENSE.BSD +21 -0
  199. package/node_modules/esprima/README.md +46 -0
  200. package/node_modules/esprima/bin/esparse.js +139 -0
  201. package/node_modules/esprima/bin/esvalidate.js +236 -0
  202. package/node_modules/esprima/dist/esprima.js +6709 -0
  203. package/node_modules/esprima/package.json +112 -0
  204. package/node_modules/extend-shallow/LICENSE +21 -0
  205. package/node_modules/extend-shallow/README.md +61 -0
  206. package/node_modules/extend-shallow/index.js +33 -0
  207. package/node_modules/extend-shallow/package.json +56 -0
  208. package/node_modules/graceful-fs/LICENSE +15 -0
  209. package/node_modules/graceful-fs/README.md +143 -0
  210. package/node_modules/graceful-fs/clone.js +23 -0
  211. package/node_modules/graceful-fs/graceful-fs.js +448 -0
  212. package/node_modules/graceful-fs/legacy-streams.js +118 -0
  213. package/node_modules/graceful-fs/package.json +53 -0
  214. package/node_modules/graceful-fs/polyfills.js +355 -0
  215. package/node_modules/gray-matter/LICENSE +21 -0
  216. package/node_modules/gray-matter/README.md +565 -0
  217. package/node_modules/gray-matter/gray-matter.d.ts +114 -0
  218. package/node_modules/gray-matter/index.js +228 -0
  219. package/node_modules/gray-matter/lib/defaults.js +18 -0
  220. package/node_modules/gray-matter/lib/engine.js +30 -0
  221. package/node_modules/gray-matter/lib/engines.js +54 -0
  222. package/node_modules/gray-matter/lib/excerpt.js +32 -0
  223. package/node_modules/gray-matter/lib/parse.js +13 -0
  224. package/node_modules/gray-matter/lib/stringify.js +56 -0
  225. package/node_modules/gray-matter/lib/to-file.js +43 -0
  226. package/node_modules/gray-matter/lib/utils.js +66 -0
  227. package/node_modules/gray-matter/package.json +127 -0
  228. package/node_modules/is-extendable/LICENSE +21 -0
  229. package/node_modules/is-extendable/README.md +72 -0
  230. package/node_modules/is-extendable/index.js +13 -0
  231. package/node_modules/is-extendable/package.json +51 -0
  232. package/node_modules/js-yaml/LICENSE +21 -0
  233. package/node_modules/js-yaml/README.md +302 -0
  234. package/node_modules/js-yaml/bin/js-yaml.js +132 -0
  235. package/node_modules/js-yaml/dist/js-yaml.js +4024 -0
  236. package/node_modules/js-yaml/dist/js-yaml.min.js +1 -0
  237. package/node_modules/js-yaml/index.js +7 -0
  238. package/node_modules/js-yaml/lib/js-yaml/common.js +59 -0
  239. package/node_modules/js-yaml/lib/js-yaml/dumper.js +850 -0
  240. package/node_modules/js-yaml/lib/js-yaml/exception.js +43 -0
  241. package/node_modules/js-yaml/lib/js-yaml/loader.js +1679 -0
  242. package/node_modules/js-yaml/lib/js-yaml/mark.js +76 -0
  243. package/node_modules/js-yaml/lib/js-yaml/schema/core.js +18 -0
  244. package/node_modules/js-yaml/lib/js-yaml/schema/default_full.js +25 -0
  245. package/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js +28 -0
  246. package/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js +17 -0
  247. package/node_modules/js-yaml/lib/js-yaml/schema/json.js +25 -0
  248. package/node_modules/js-yaml/lib/js-yaml/schema.js +108 -0
  249. package/node_modules/js-yaml/lib/js-yaml/type/binary.js +138 -0
  250. package/node_modules/js-yaml/lib/js-yaml/type/bool.js +35 -0
  251. package/node_modules/js-yaml/lib/js-yaml/type/float.js +116 -0
  252. package/node_modules/js-yaml/lib/js-yaml/type/int.js +173 -0
  253. package/node_modules/js-yaml/lib/js-yaml/type/js/function.js +93 -0
  254. package/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js +60 -0
  255. package/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js +28 -0
  256. package/node_modules/js-yaml/lib/js-yaml/type/map.js +8 -0
  257. package/node_modules/js-yaml/lib/js-yaml/type/merge.js +12 -0
  258. package/node_modules/js-yaml/lib/js-yaml/type/null.js +34 -0
  259. package/node_modules/js-yaml/lib/js-yaml/type/omap.js +44 -0
  260. package/node_modules/js-yaml/lib/js-yaml/type/pairs.js +53 -0
  261. package/node_modules/js-yaml/lib/js-yaml/type/seq.js +8 -0
  262. package/node_modules/js-yaml/lib/js-yaml/type/set.js +29 -0
  263. package/node_modules/js-yaml/lib/js-yaml/type/str.js +8 -0
  264. package/node_modules/js-yaml/lib/js-yaml/type/timestamp.js +88 -0
  265. package/node_modules/js-yaml/lib/js-yaml/type.js +61 -0
  266. package/node_modules/js-yaml/lib/js-yaml.js +39 -0
  267. package/node_modules/js-yaml/package.json +52 -0
  268. package/node_modules/kind-of/LICENSE +21 -0
  269. package/node_modules/kind-of/README.md +367 -0
  270. package/node_modules/kind-of/index.js +129 -0
  271. package/node_modules/kind-of/package.json +88 -0
  272. package/node_modules/pi-toggle-skills/README.md +213 -0
  273. package/node_modules/pi-toggle-skills/package.json +60 -0
  274. package/node_modules/pi-toggle-skills/src/index.ts +112 -0
  275. package/node_modules/pi-toggle-skills/src/skill-discovery.ts +258 -0
  276. package/node_modules/pi-toggle-skills/src/skill-selector.ts +435 -0
  277. package/node_modules/pi-toggle-skills/toggle-skills.ts +316 -0
  278. package/node_modules/pi-toggle-skills/vitest.config.ts +15 -0
  279. package/node_modules/proper-lockfile/LICENSE +21 -0
  280. package/node_modules/proper-lockfile/README.md +183 -0
  281. package/node_modules/proper-lockfile/index.js +40 -0
  282. package/node_modules/proper-lockfile/lib/adapter.js +85 -0
  283. package/node_modules/proper-lockfile/lib/lockfile.js +342 -0
  284. package/node_modules/proper-lockfile/lib/mtime-precision.js +55 -0
  285. package/node_modules/proper-lockfile/node_modules/retry/.npmignore +3 -0
  286. package/node_modules/proper-lockfile/node_modules/retry/.travis.yml +15 -0
  287. package/node_modules/proper-lockfile/node_modules/retry/License +21 -0
  288. package/node_modules/proper-lockfile/node_modules/retry/Makefile +18 -0
  289. package/node_modules/proper-lockfile/node_modules/retry/README.md +227 -0
  290. package/node_modules/proper-lockfile/node_modules/retry/equation.gif +0 -0
  291. package/node_modules/proper-lockfile/node_modules/retry/example/dns.js +31 -0
  292. package/node_modules/proper-lockfile/node_modules/retry/example/stop.js +40 -0
  293. package/node_modules/proper-lockfile/node_modules/retry/index.js +1 -0
  294. package/node_modules/proper-lockfile/node_modules/retry/lib/retry.js +100 -0
  295. package/node_modules/proper-lockfile/node_modules/retry/lib/retry_operation.js +158 -0
  296. package/node_modules/proper-lockfile/node_modules/retry/package.json +32 -0
  297. package/node_modules/proper-lockfile/node_modules/retry/test/common.js +10 -0
  298. package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-forever.js +24 -0
  299. package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-retry-operation.js +258 -0
  300. package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-retry-wrap.js +101 -0
  301. package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-timeouts.js +69 -0
  302. package/node_modules/proper-lockfile/package.json +71 -0
  303. package/node_modules/section-matter/LICENSE +21 -0
  304. package/node_modules/section-matter/README.md +236 -0
  305. package/node_modules/section-matter/index.js +136 -0
  306. package/node_modules/section-matter/package.json +55 -0
  307. package/node_modules/signal-exit/LICENSE.txt +16 -0
  308. package/node_modules/signal-exit/README.md +39 -0
  309. package/node_modules/signal-exit/index.js +202 -0
  310. package/node_modules/signal-exit/package.json +38 -0
  311. package/node_modules/signal-exit/signals.js +53 -0
  312. package/node_modules/sprintf-js/.npmignore +1 -0
  313. package/node_modules/sprintf-js/LICENSE +24 -0
  314. package/node_modules/sprintf-js/README.md +88 -0
  315. package/node_modules/sprintf-js/bower.json +14 -0
  316. package/node_modules/sprintf-js/demo/angular.html +20 -0
  317. package/node_modules/sprintf-js/dist/angular-sprintf.min.js +4 -0
  318. package/node_modules/sprintf-js/dist/angular-sprintf.min.js.map +1 -0
  319. package/node_modules/sprintf-js/dist/angular-sprintf.min.map +1 -0
  320. package/node_modules/sprintf-js/dist/sprintf.min.js +4 -0
  321. package/node_modules/sprintf-js/dist/sprintf.min.js.map +1 -0
  322. package/node_modules/sprintf-js/dist/sprintf.min.map +1 -0
  323. package/node_modules/sprintf-js/gruntfile.js +36 -0
  324. package/node_modules/sprintf-js/package.json +22 -0
  325. package/node_modules/sprintf-js/src/angular-sprintf.js +18 -0
  326. package/node_modules/sprintf-js/src/sprintf.js +208 -0
  327. package/node_modules/sprintf-js/test/test.js +82 -0
  328. package/node_modules/strip-bom-string/LICENSE +21 -0
  329. package/node_modules/strip-bom-string/README.md +66 -0
  330. package/node_modules/strip-bom-string/index.js +15 -0
  331. package/node_modules/strip-bom-string/package.json +60 -0
  332. package/package.json +13 -4
@@ -0,0 +1,342 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const fs = require('graceful-fs');
5
+ const retry = require('retry');
6
+ const onExit = require('signal-exit');
7
+ const mtimePrecision = require('./mtime-precision');
8
+
9
+ const locks = {};
10
+
11
+ function getLockFile(file, options) {
12
+ return options.lockfilePath || `${file}.lock`;
13
+ }
14
+
15
+ function resolveCanonicalPath(file, options, callback) {
16
+ if (!options.realpath) {
17
+ return callback(null, path.resolve(file));
18
+ }
19
+
20
+ // Use realpath to resolve symlinks
21
+ // It also resolves relative paths
22
+ options.fs.realpath(file, callback);
23
+ }
24
+
25
+ function acquireLock(file, options, callback) {
26
+ const lockfilePath = getLockFile(file, options);
27
+
28
+ // Use mkdir to create the lockfile (atomic operation)
29
+ options.fs.mkdir(lockfilePath, (err) => {
30
+ if (!err) {
31
+ // At this point, we acquired the lock!
32
+ // Probe the mtime precision
33
+ return mtimePrecision.probe(lockfilePath, options.fs, (err, mtime, mtimePrecision) => {
34
+ // If it failed, try to remove the lock..
35
+ /* istanbul ignore if */
36
+ if (err) {
37
+ options.fs.rmdir(lockfilePath, () => {});
38
+
39
+ return callback(err);
40
+ }
41
+
42
+ callback(null, mtime, mtimePrecision);
43
+ });
44
+ }
45
+
46
+ // If error is not EEXIST then some other error occurred while locking
47
+ if (err.code !== 'EEXIST') {
48
+ return callback(err);
49
+ }
50
+
51
+ // Otherwise, check if lock is stale by analyzing the file mtime
52
+ if (options.stale <= 0) {
53
+ return callback(Object.assign(new Error('Lock file is already being held'), { code: 'ELOCKED', file }));
54
+ }
55
+
56
+ options.fs.stat(lockfilePath, (err, stat) => {
57
+ if (err) {
58
+ // Retry if the lockfile has been removed (meanwhile)
59
+ // Skip stale check to avoid recursiveness
60
+ if (err.code === 'ENOENT') {
61
+ return acquireLock(file, { ...options, stale: 0 }, callback);
62
+ }
63
+
64
+ return callback(err);
65
+ }
66
+
67
+ if (!isLockStale(stat, options)) {
68
+ return callback(Object.assign(new Error('Lock file is already being held'), { code: 'ELOCKED', file }));
69
+ }
70
+
71
+ // If it's stale, remove it and try again!
72
+ // Skip stale check to avoid recursiveness
73
+ removeLock(file, options, (err) => {
74
+ if (err) {
75
+ return callback(err);
76
+ }
77
+
78
+ acquireLock(file, { ...options, stale: 0 }, callback);
79
+ });
80
+ });
81
+ });
82
+ }
83
+
84
+ function isLockStale(stat, options) {
85
+ return stat.mtime.getTime() < Date.now() - options.stale;
86
+ }
87
+
88
+ function removeLock(file, options, callback) {
89
+ // Remove lockfile, ignoring ENOENT errors
90
+ options.fs.rmdir(getLockFile(file, options), (err) => {
91
+ if (err && err.code !== 'ENOENT') {
92
+ return callback(err);
93
+ }
94
+
95
+ callback();
96
+ });
97
+ }
98
+
99
+ function updateLock(file, options) {
100
+ const lock = locks[file];
101
+
102
+ // Just for safety, should never happen
103
+ /* istanbul ignore if */
104
+ if (lock.updateTimeout) {
105
+ return;
106
+ }
107
+
108
+ lock.updateDelay = lock.updateDelay || options.update;
109
+ lock.updateTimeout = setTimeout(() => {
110
+ lock.updateTimeout = null;
111
+
112
+ // Stat the file to check if mtime is still ours
113
+ // If it is, we can still recover from a system sleep or a busy event loop
114
+ options.fs.stat(lock.lockfilePath, (err, stat) => {
115
+ const isOverThreshold = lock.lastUpdate + options.stale < Date.now();
116
+
117
+ // If it failed to update the lockfile, keep trying unless
118
+ // the lockfile was deleted or we are over the threshold
119
+ if (err) {
120
+ if (err.code === 'ENOENT' || isOverThreshold) {
121
+ return setLockAsCompromised(file, lock, Object.assign(err, { code: 'ECOMPROMISED' }));
122
+ }
123
+
124
+ lock.updateDelay = 1000;
125
+
126
+ return updateLock(file, options);
127
+ }
128
+
129
+ const isMtimeOurs = lock.mtime.getTime() === stat.mtime.getTime();
130
+
131
+ if (!isMtimeOurs) {
132
+ return setLockAsCompromised(
133
+ file,
134
+ lock,
135
+ Object.assign(
136
+ new Error('Unable to update lock within the stale threshold'),
137
+ { code: 'ECOMPROMISED' }
138
+ ));
139
+ }
140
+
141
+ const mtime = mtimePrecision.getMtime(lock.mtimePrecision);
142
+
143
+ options.fs.utimes(lock.lockfilePath, mtime, mtime, (err) => {
144
+ const isOverThreshold = lock.lastUpdate + options.stale < Date.now();
145
+
146
+ // Ignore if the lock was released
147
+ if (lock.released) {
148
+ return;
149
+ }
150
+
151
+ // If it failed to update the lockfile, keep trying unless
152
+ // the lockfile was deleted or we are over the threshold
153
+ if (err) {
154
+ if (err.code === 'ENOENT' || isOverThreshold) {
155
+ return setLockAsCompromised(file, lock, Object.assign(err, { code: 'ECOMPROMISED' }));
156
+ }
157
+
158
+ lock.updateDelay = 1000;
159
+
160
+ return updateLock(file, options);
161
+ }
162
+
163
+ // All ok, keep updating..
164
+ lock.mtime = mtime;
165
+ lock.lastUpdate = Date.now();
166
+ lock.updateDelay = null;
167
+ updateLock(file, options);
168
+ });
169
+ });
170
+ }, lock.updateDelay);
171
+
172
+ // Unref the timer so that the nodejs process can exit freely
173
+ // This is safe because all acquired locks will be automatically released
174
+ // on process exit
175
+
176
+ // We first check that `lock.updateTimeout.unref` exists because some users
177
+ // may be using this module outside of NodeJS (e.g., in an electron app),
178
+ // and in those cases `setTimeout` return an integer.
179
+ /* istanbul ignore else */
180
+ if (lock.updateTimeout.unref) {
181
+ lock.updateTimeout.unref();
182
+ }
183
+ }
184
+
185
+ function setLockAsCompromised(file, lock, err) {
186
+ // Signal the lock has been released
187
+ lock.released = true;
188
+
189
+ // Cancel lock mtime update
190
+ // Just for safety, at this point updateTimeout should be null
191
+ /* istanbul ignore if */
192
+ if (lock.updateTimeout) {
193
+ clearTimeout(lock.updateTimeout);
194
+ }
195
+
196
+ if (locks[file] === lock) {
197
+ delete locks[file];
198
+ }
199
+
200
+ lock.options.onCompromised(err);
201
+ }
202
+
203
+ // ----------------------------------------------------------
204
+
205
+ function lock(file, options, callback) {
206
+ /* istanbul ignore next */
207
+ options = {
208
+ stale: 10000,
209
+ update: null,
210
+ realpath: true,
211
+ retries: 0,
212
+ fs,
213
+ onCompromised: (err) => { throw err; },
214
+ ...options,
215
+ };
216
+
217
+ options.retries = options.retries || 0;
218
+ options.retries = typeof options.retries === 'number' ? { retries: options.retries } : options.retries;
219
+ options.stale = Math.max(options.stale || 0, 2000);
220
+ options.update = options.update == null ? options.stale / 2 : options.update || 0;
221
+ options.update = Math.max(Math.min(options.update, options.stale / 2), 1000);
222
+
223
+ // Resolve to a canonical file path
224
+ resolveCanonicalPath(file, options, (err, file) => {
225
+ if (err) {
226
+ return callback(err);
227
+ }
228
+
229
+ // Attempt to acquire the lock
230
+ const operation = retry.operation(options.retries);
231
+
232
+ operation.attempt(() => {
233
+ acquireLock(file, options, (err, mtime, mtimePrecision) => {
234
+ if (operation.retry(err)) {
235
+ return;
236
+ }
237
+
238
+ if (err) {
239
+ return callback(operation.mainError());
240
+ }
241
+
242
+ // We now own the lock
243
+ const lock = locks[file] = {
244
+ lockfilePath: getLockFile(file, options),
245
+ mtime,
246
+ mtimePrecision,
247
+ options,
248
+ lastUpdate: Date.now(),
249
+ };
250
+
251
+ // We must keep the lock fresh to avoid staleness
252
+ updateLock(file, options);
253
+
254
+ callback(null, (releasedCallback) => {
255
+ if (lock.released) {
256
+ return releasedCallback &&
257
+ releasedCallback(Object.assign(new Error('Lock is already released'), { code: 'ERELEASED' }));
258
+ }
259
+
260
+ // Not necessary to use realpath twice when unlocking
261
+ unlock(file, { ...options, realpath: false }, releasedCallback);
262
+ });
263
+ });
264
+ });
265
+ });
266
+ }
267
+
268
+ function unlock(file, options, callback) {
269
+ options = {
270
+ fs,
271
+ realpath: true,
272
+ ...options,
273
+ };
274
+
275
+ // Resolve to a canonical file path
276
+ resolveCanonicalPath(file, options, (err, file) => {
277
+ if (err) {
278
+ return callback(err);
279
+ }
280
+
281
+ // Skip if the lock is not acquired
282
+ const lock = locks[file];
283
+
284
+ if (!lock) {
285
+ return callback(Object.assign(new Error('Lock is not acquired/owned by you'), { code: 'ENOTACQUIRED' }));
286
+ }
287
+
288
+ lock.updateTimeout && clearTimeout(lock.updateTimeout); // Cancel lock mtime update
289
+ lock.released = true; // Signal the lock has been released
290
+ delete locks[file]; // Delete from locks
291
+
292
+ removeLock(file, options, callback);
293
+ });
294
+ }
295
+
296
+ function check(file, options, callback) {
297
+ options = {
298
+ stale: 10000,
299
+ realpath: true,
300
+ fs,
301
+ ...options,
302
+ };
303
+
304
+ options.stale = Math.max(options.stale || 0, 2000);
305
+
306
+ // Resolve to a canonical file path
307
+ resolveCanonicalPath(file, options, (err, file) => {
308
+ if (err) {
309
+ return callback(err);
310
+ }
311
+
312
+ // Check if lockfile exists
313
+ options.fs.stat(getLockFile(file, options), (err, stat) => {
314
+ if (err) {
315
+ // If does not exist, file is not locked. Otherwise, callback with error
316
+ return err.code === 'ENOENT' ? callback(null, false) : callback(err);
317
+ }
318
+
319
+ // Otherwise, check if lock is stale by analyzing the file mtime
320
+ return callback(null, !isLockStale(stat, options));
321
+ });
322
+ });
323
+ }
324
+
325
+ function getLocks() {
326
+ return locks;
327
+ }
328
+
329
+ // Remove acquired locks on exit
330
+ /* istanbul ignore next */
331
+ onExit(() => {
332
+ for (const file in locks) {
333
+ const options = locks[file].options;
334
+
335
+ try { options.fs.rmdirSync(getLockFile(file, options)); } catch (e) { /* Empty */ }
336
+ }
337
+ });
338
+
339
+ module.exports.lock = lock;
340
+ module.exports.unlock = unlock;
341
+ module.exports.check = check;
342
+ module.exports.getLocks = getLocks;
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ const cacheSymbol = Symbol();
4
+
5
+ function probe(file, fs, callback) {
6
+ const cachedPrecision = fs[cacheSymbol];
7
+
8
+ if (cachedPrecision) {
9
+ return fs.stat(file, (err, stat) => {
10
+ /* istanbul ignore if */
11
+ if (err) {
12
+ return callback(err);
13
+ }
14
+
15
+ callback(null, stat.mtime, cachedPrecision);
16
+ });
17
+ }
18
+
19
+ // Set mtime by ceiling Date.now() to seconds + 5ms so that it's "not on the second"
20
+ const mtime = new Date((Math.ceil(Date.now() / 1000) * 1000) + 5);
21
+
22
+ fs.utimes(file, mtime, mtime, (err) => {
23
+ /* istanbul ignore if */
24
+ if (err) {
25
+ return callback(err);
26
+ }
27
+
28
+ fs.stat(file, (err, stat) => {
29
+ /* istanbul ignore if */
30
+ if (err) {
31
+ return callback(err);
32
+ }
33
+
34
+ const precision = stat.mtime.getTime() % 1000 === 0 ? 's' : 'ms';
35
+
36
+ // Cache the precision in a non-enumerable way
37
+ Object.defineProperty(fs, cacheSymbol, { value: precision });
38
+
39
+ callback(null, stat.mtime, precision);
40
+ });
41
+ });
42
+ }
43
+
44
+ function getMtime(precision) {
45
+ let now = Date.now();
46
+
47
+ if (precision === 's') {
48
+ now = Math.ceil(now / 1000) * 1000;
49
+ }
50
+
51
+ return new Date(now);
52
+ }
53
+
54
+ module.exports.probe = probe;
55
+ module.exports.getMtime = getMtime;
@@ -0,0 +1,3 @@
1
+ /node_modules/*
2
+ npm-debug.log
3
+ coverage
@@ -0,0 +1,15 @@
1
+ language: node_js
2
+ node_js:
3
+ - "4"
4
+ before_install:
5
+ - pip install --user codecov
6
+ after_success:
7
+ - codecov --file coverage/lcov.info --disable search
8
+ # travis encrypt [subdomain]:[api token]@[room id]
9
+ # notifications:
10
+ # email: false
11
+ # campfire:
12
+ # rooms:
13
+ # secure: xyz
14
+ # on_failure: always
15
+ # on_success: always
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2011:
2
+ Tim Koschützki (tim@debuggable.com)
3
+ Felix Geisendörfer (felix@debuggable.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ SHELL := /bin/bash
2
+
3
+ release-major: test
4
+ npm version major -m "Release %s"
5
+ git push
6
+ npm publish
7
+
8
+ release-minor: test
9
+ npm version minor -m "Release %s"
10
+ git push
11
+ npm publish
12
+
13
+ release-patch: test
14
+ npm version patch -m "Release %s"
15
+ git push
16
+ npm publish
17
+
18
+ .PHONY: test release-major release-minor release-patch
@@ -0,0 +1,227 @@
1
+ <!-- badges/ -->
2
+ [![Build Status](https://secure.travis-ci.org/tim-kos/node-retry.png?branch=master)](http://travis-ci.org/tim-kos/node-retry "Check this project's build status on TravisCI")
3
+ [![codecov](https://codecov.io/gh/tim-kos/node-retry/branch/master/graph/badge.svg)](https://codecov.io/gh/tim-kos/node-retry)
4
+ <!-- /badges -->
5
+
6
+ # retry
7
+
8
+ Abstraction for exponential and custom retry strategies for failed operations.
9
+
10
+ ## Installation
11
+
12
+ npm install retry
13
+
14
+ ## Current Status
15
+
16
+ This module has been tested and is ready to be used.
17
+
18
+ ## Tutorial
19
+
20
+ The example below will retry a potentially failing `dns.resolve` operation
21
+ `10` times using an exponential backoff strategy. With the default settings, this
22
+ means the last attempt is made after `17 minutes and 3 seconds`.
23
+
24
+ ``` javascript
25
+ var dns = require('dns');
26
+ var retry = require('retry');
27
+
28
+ function faultTolerantResolve(address, cb) {
29
+ var operation = retry.operation();
30
+
31
+ operation.attempt(function(currentAttempt) {
32
+ dns.resolve(address, function(err, addresses) {
33
+ if (operation.retry(err)) {
34
+ return;
35
+ }
36
+
37
+ cb(err ? operation.mainError() : null, addresses);
38
+ });
39
+ });
40
+ }
41
+
42
+ faultTolerantResolve('nodejs.org', function(err, addresses) {
43
+ console.log(err, addresses);
44
+ });
45
+ ```
46
+
47
+ Of course you can also configure the factors that go into the exponential
48
+ backoff. See the API documentation below for all available settings.
49
+ currentAttempt is an int representing the number of attempts so far.
50
+
51
+ ``` javascript
52
+ var operation = retry.operation({
53
+ retries: 5,
54
+ factor: 3,
55
+ minTimeout: 1 * 1000,
56
+ maxTimeout: 60 * 1000,
57
+ randomize: true,
58
+ });
59
+ ```
60
+
61
+ ## API
62
+
63
+ ### retry.operation([options])
64
+
65
+ Creates a new `RetryOperation` object. `options` is the same as `retry.timeouts()`'s `options`, with two additions:
66
+
67
+ * `forever`: Whether to retry forever, defaults to `false`.
68
+ * `unref`: Whether to [unref](https://nodejs.org/api/timers.html#timers_unref) the setTimeout's, defaults to `false`.
69
+ * `maxRetryTime`: The maximum time (in milliseconds) that the retried operation is allowed to run. Default is `Infinity`.
70
+
71
+ ### retry.timeouts([options])
72
+
73
+ Returns an array of timeouts. All time `options` and return values are in
74
+ milliseconds. If `options` is an array, a copy of that array is returned.
75
+
76
+ `options` is a JS object that can contain any of the following keys:
77
+
78
+ * `retries`: The maximum amount of times to retry the operation. Default is `10`. Seting this to `1` means `do it once, then retry it once`.
79
+ * `factor`: The exponential factor to use. Default is `2`.
80
+ * `minTimeout`: The number of milliseconds before starting the first retry. Default is `1000`.
81
+ * `maxTimeout`: The maximum number of milliseconds between two retries. Default is `Infinity`.
82
+ * `randomize`: Randomizes the timeouts by multiplying with a factor between `1` to `2`. Default is `false`.
83
+
84
+ The formula used to calculate the individual timeouts is:
85
+
86
+ ```
87
+ Math.min(random * minTimeout * Math.pow(factor, attempt), maxTimeout)
88
+ ```
89
+
90
+ Have a look at [this article][article] for a better explanation of approach.
91
+
92
+ If you want to tune your `factor` / `times` settings to attempt the last retry
93
+ after a certain amount of time, you can use wolfram alpha. For example in order
94
+ to tune for `10` attempts in `5 minutes`, you can use this equation:
95
+
96
+ ![screenshot](https://github.com/tim-kos/node-retry/raw/master/equation.gif)
97
+
98
+ Explaining the various values from left to right:
99
+
100
+ * `k = 0 ... 9`: The `retries` value (10)
101
+ * `1000`: The `minTimeout` value in ms (1000)
102
+ * `x^k`: No need to change this, `x` will be your resulting factor
103
+ * `5 * 60 * 1000`: The desired total amount of time for retrying in ms (5 minutes)
104
+
105
+ To make this a little easier for you, use wolfram alpha to do the calculations:
106
+
107
+ <http://www.wolframalpha.com/input/?i=Sum%5B1000*x^k%2C+{k%2C+0%2C+9}%5D+%3D+5+*+60+*+1000>
108
+
109
+ [article]: http://dthain.blogspot.com/2009/02/exponential-backoff-in-distributed.html
110
+
111
+ ### retry.createTimeout(attempt, opts)
112
+
113
+ Returns a new `timeout` (integer in milliseconds) based on the given parameters.
114
+
115
+ `attempt` is an integer representing for which retry the timeout should be calculated. If your retry operation was executed 4 times you had one attempt and 3 retries. If you then want to calculate a new timeout, you should set `attempt` to 4 (attempts are zero-indexed).
116
+
117
+ `opts` can include `factor`, `minTimeout`, `randomize` (boolean) and `maxTimeout`. They are documented above.
118
+
119
+ `retry.createTimeout()` is used internally by `retry.timeouts()` and is public for you to be able to create your own timeouts for reinserting an item, see [issue #13](https://github.com/tim-kos/node-retry/issues/13).
120
+
121
+ ### retry.wrap(obj, [options], [methodNames])
122
+
123
+ Wrap all functions of the `obj` with retry. Optionally you can pass operation options and
124
+ an array of method names which need to be wrapped.
125
+
126
+ ```
127
+ retry.wrap(obj)
128
+
129
+ retry.wrap(obj, ['method1', 'method2'])
130
+
131
+ retry.wrap(obj, {retries: 3})
132
+
133
+ retry.wrap(obj, {retries: 3}, ['method1', 'method2'])
134
+ ```
135
+ The `options` object can take any options that the usual call to `retry.operation` can take.
136
+
137
+ ### new RetryOperation(timeouts, [options])
138
+
139
+ Creates a new `RetryOperation` where `timeouts` is an array where each value is
140
+ a timeout given in milliseconds.
141
+
142
+ Available options:
143
+ * `forever`: Whether to retry forever, defaults to `false`.
144
+ * `unref`: Wether to [unref](https://nodejs.org/api/timers.html#timers_unref) the setTimeout's, defaults to `false`.
145
+
146
+ If `forever` is true, the following changes happen:
147
+ * `RetryOperation.errors()` will only output an array of one item: the last error.
148
+ * `RetryOperation` will repeatedly use the `timeouts` array. Once all of its timeouts have been used up, it restarts with the first timeout, then uses the second and so on.
149
+
150
+ #### retryOperation.errors()
151
+
152
+ Returns an array of all errors that have been passed to `retryOperation.retry()` so far. The
153
+ returning array has the errors ordered chronologically based on when they were passed to
154
+ `retryOperation.retry()`, which means the first passed error is at index zero and the last is
155
+ at the last index.
156
+
157
+ #### retryOperation.mainError()
158
+
159
+ A reference to the error object that occured most frequently. Errors are
160
+ compared using the `error.message` property.
161
+
162
+ If multiple error messages occured the same amount of time, the last error
163
+ object with that message is returned.
164
+
165
+ If no errors occured so far, the value is `null`.
166
+
167
+ #### retryOperation.attempt(fn, timeoutOps)
168
+
169
+ Defines the function `fn` that is to be retried and executes it for the first
170
+ time right away. The `fn` function can receive an optional `currentAttempt` callback that represents the number of attempts to execute `fn` so far.
171
+
172
+ Optionally defines `timeoutOps` which is an object having a property `timeout` in miliseconds and a property `cb` callback function.
173
+ Whenever your retry operation takes longer than `timeout` to execute, the timeout callback function `cb` is called.
174
+
175
+
176
+ #### retryOperation.try(fn)
177
+
178
+ This is an alias for `retryOperation.attempt(fn)`. This is deprecated. Please use `retryOperation.attempt(fn)` instead.
179
+
180
+ #### retryOperation.start(fn)
181
+
182
+ This is an alias for `retryOperation.attempt(fn)`. This is deprecated. Please use `retryOperation.attempt(fn)` instead.
183
+
184
+ #### retryOperation.retry(error)
185
+
186
+ Returns `false` when no `error` value is given, or the maximum amount of retries
187
+ has been reached.
188
+
189
+ Otherwise it returns `true`, and retries the operation after the timeout for
190
+ the current attempt number.
191
+
192
+ #### retryOperation.stop()
193
+
194
+ Allows you to stop the operation being retried. Useful for aborting the operation on a fatal error etc.
195
+
196
+ #### retryOperation.reset()
197
+
198
+ Resets the internal state of the operation object, so that you can call `attempt()` again as if this was a new operation object.
199
+
200
+ #### retryOperation.attempts()
201
+
202
+ Returns an int representing the number of attempts it took to call `fn` before it was successful.
203
+
204
+ ## License
205
+
206
+ retry is licensed under the MIT license.
207
+
208
+
209
+ # Changelog
210
+
211
+ 0.10.0 Adding `stop` functionality, thanks to @maxnachlinger.
212
+
213
+ 0.9.0 Adding `unref` functionality, thanks to @satazor.
214
+
215
+ 0.8.0 Implementing retry.wrap.
216
+
217
+ 0.7.0 Some bug fixes and made retry.createTimeout() public. Fixed issues [#10](https://github.com/tim-kos/node-retry/issues/10), [#12](https://github.com/tim-kos/node-retry/issues/12), and [#13](https://github.com/tim-kos/node-retry/issues/13).
218
+
219
+ 0.6.0 Introduced optional timeOps parameter for the attempt() function which is an object having a property timeout in milliseconds and a property cb callback function. Whenever your retry operation takes longer than timeout to execute, the timeout callback function cb is called.
220
+
221
+ 0.5.0 Some minor refactoring.
222
+
223
+ 0.4.0 Changed retryOperation.try() to retryOperation.attempt(). Deprecated the aliases start() and try() for it.
224
+
225
+ 0.3.0 Added retryOperation.start() which is an alias for retryOperation.try().
226
+
227
+ 0.2.0 Added attempts() function and parameter to retryOperation.try() representing the number of attempts it took to call fn().