elderwand 0.1.75 → 0.1.78

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 (444) hide show
  1. package/Environment/environment.js +2 -2
  2. package/NoDuplicate/README.md +94 -46
  3. package/NoDuplicate/no-duplicate.js +43 -25
  4. package/NoDuplicate/package-lock.json +1420 -0
  5. package/NoDuplicate/package.json +22 -24
  6. package/NoDuplicate/tests/characterization.test.js +359 -0
  7. package/SoftDelete/mongoose-soft-delete.js +60 -8
  8. package/SoftDelete/package-lock.json +1391 -0
  9. package/SoftDelete/package.json +20 -22
  10. package/SoftDelete/tests/characterization.test.js +375 -0
  11. package/ToolBox/RequestTrackTools.js +0 -14
  12. package/ToolBox/Routes.js +148 -54
  13. package/ToolBox/package-lock.json +2533 -0
  14. package/ToolBox/package.json +23 -7
  15. package/ToolBox/tests/event-log.test.js +365 -0
  16. package/ToolBox/tests/helpers.js +241 -0
  17. package/ToolBox/tests/request-track-tools.test.js +197 -0
  18. package/ToolBox/tests/routes.test.js +313 -0
  19. package/package.json +39 -29
  20. package/threads/Workers/ControllerWorker.js +38 -58
  21. package/threads/Workers/DBWorker.js +21 -17
  22. package/threads/Workers/MongoClientWorker.js +36 -24
  23. package/threads/package-lock.json +2082 -27
  24. package/threads/package.json +21 -10
  25. package/threads/tests/CrashWorker.js +17 -0
  26. package/threads/tests/DuplicatePartialWorker.js +32 -0
  27. package/threads/tests/EchoWorker.js +13 -0
  28. package/threads/tests/LargePayloadWorker.js +39 -0
  29. package/threads/tests/MalformedPartialWorker.js +27 -0
  30. package/threads/tests/SlowWorker.js +17 -0
  31. package/threads/tests/StreamingPartialWorker.js +47 -0
  32. package/threads/tests/bug-reproducers.js +309 -0
  33. package/threads/tests/locked-interface.js +250 -0
  34. package/threads/tests/tests.js +529 -46
  35. package/threads/threads.js +438 -382
  36. package/utils/package-lock.json +1343 -0
  37. package/utils/package.json +14 -5
  38. package/utils/tests/coordination.test.js +247 -0
  39. package/utils/tests/crypto.test.js +81 -0
  40. package/utils/tests/helpers.js +111 -0
  41. package/utils/tests/http.test.js +324 -0
  42. package/utils/tests/pure.test.js +284 -0
  43. package/utils/tests/strings.test.js +112 -0
  44. package/utils/utils.js +37 -17
  45. package/.idea/.name +0 -1
  46. package/.idea/encodings.xml +0 -6
  47. package/.idea/jsLibraryMappings.xml +0 -6
  48. package/.idea/kle-ElderWand.iml +0 -9
  49. package/.idea/libraries/kle_ElderWand_node_modules.xml +0 -14
  50. package/.idea/misc.xml +0 -13
  51. package/.idea/modules.xml +0 -8
  52. package/.idea/vcs.xml +0 -6
  53. package/.idea/workspace.xml +0 -793
  54. package/BoilerPlate/Documents/.editorconfig +0 -10
  55. package/BoilerPlate/Documents/.sailsrc +0 -5
  56. package/BoilerPlate/Documents/CONTRIBUTING.md +0 -1
  57. package/BoilerPlate/Documents/LICENSE.txt +0 -21
  58. package/BoilerPlate/Documents/Procfile +0 -1
  59. package/BoilerPlate/Documents/README.md +0 -63
  60. package/BoilerPlate/Documents/app/controllers/documents.js +0 -45
  61. package/BoilerPlate/Documents/app/controllers/sectionGrups.js +0 -22
  62. package/BoilerPlate/Documents/app/controllers/sectionTypes.js +0 -51
  63. package/BoilerPlate/Documents/app/controllers/sections.js +0 -139
  64. package/BoilerPlate/Documents/app/controllers/users.js +0 -74
  65. package/BoilerPlate/Documents/app/models/document.js +0 -105
  66. package/BoilerPlate/Documents/app/models/section.js +0 -156
  67. package/BoilerPlate/Documents/app/models/sectionGrup.js +0 -136
  68. package/BoilerPlate/Documents/app/models/sectionType.js +0 -135
  69. package/BoilerPlate/Documents/app/models/user.js +0 -202
  70. package/BoilerPlate/Documents/app/views/404.html +0 -5
  71. package/BoilerPlate/Documents/app/views/500.html +0 -13
  72. package/BoilerPlate/Documents/app/views/documentation.html +0 -37
  73. package/BoilerPlate/Documents/app/views/documents/document.html +0 -11
  74. package/BoilerPlate/Documents/app/views/documents/edit.html +0 -1
  75. package/BoilerPlate/Documents/app/views/documents/form.html +0 -43
  76. package/BoilerPlate/Documents/app/views/documents/index.html +0 -58
  77. package/BoilerPlate/Documents/app/views/documents/new.html +0 -1
  78. package/BoilerPlate/Documents/app/views/documents/show.html +0 -2
  79. package/BoilerPlate/Documents/app/views/includes/foot.html +0 -29
  80. package/BoilerPlate/Documents/app/views/includes/footer.html +0 -1
  81. package/BoilerPlate/Documents/app/views/includes/head.html +0 -31
  82. package/BoilerPlate/Documents/app/views/includes/header.html +0 -47
  83. package/BoilerPlate/Documents/app/views/includes/messages.html +0 -43
  84. package/BoilerPlate/Documents/app/views/layouts/default.html +0 -25
  85. package/BoilerPlate/Documents/app/views/sectionGrups/edit.html +0 -1
  86. package/BoilerPlate/Documents/app/views/sectionGrups/form.html +0 -47
  87. package/BoilerPlate/Documents/app/views/sectionGrups/index.html +0 -33
  88. package/BoilerPlate/Documents/app/views/sectionGrups/new.html +0 -1
  89. package/BoilerPlate/Documents/app/views/sectionGrups/sectionGrup.html +0 -11
  90. package/BoilerPlate/Documents/app/views/sectionGrups/show.html +0 -55
  91. package/BoilerPlate/Documents/app/views/sectionTypes/edit.html +0 -1
  92. package/BoilerPlate/Documents/app/views/sectionTypes/form.html +0 -42
  93. package/BoilerPlate/Documents/app/views/sectionTypes/index.html +0 -33
  94. package/BoilerPlate/Documents/app/views/sectionTypes/new.html +0 -1
  95. package/BoilerPlate/Documents/app/views/sectionTypes/sectionType.html +0 -17
  96. package/BoilerPlate/Documents/app/views/sectionTypes/show.html +0 -55
  97. package/BoilerPlate/Documents/app/views/sections/edit.html +0 -320
  98. package/BoilerPlate/Documents/app/views/sections/form.html +0 -277
  99. package/BoilerPlate/Documents/app/views/sections/index.html +0 -40
  100. package/BoilerPlate/Documents/app/views/sections/liste.html +0 -39
  101. package/BoilerPlate/Documents/app/views/sections/new.html +0 -1
  102. package/BoilerPlate/Documents/app/views/sections/section.html +0 -1
  103. package/BoilerPlate/Documents/app/views/sections/section_Like_blog.html +0 -32
  104. package/BoilerPlate/Documents/app/views/sections/section_Like_project.html +0 -35
  105. package/BoilerPlate/Documents/app/views/sections/section_about.html +0 -31
  106. package/BoilerPlate/Documents/app/views/sections/section_blog.html +0 -47
  107. package/BoilerPlate/Documents/app/views/sections/section_clients.html +0 -23
  108. package/BoilerPlate/Documents/app/views/sections/section_contact.html +0 -74
  109. package/BoilerPlate/Documents/app/views/sections/section_detay1Resimli.html +0 -23
  110. package/BoilerPlate/Documents/app/views/sections/section_detay1Resimsiz.html +0 -11
  111. package/BoilerPlate/Documents/app/views/sections/section_features.html +0 -23
  112. package/BoilerPlate/Documents/app/views/sections/section_funfact.html +0 -19
  113. package/BoilerPlate/Documents/app/views/sections/section_projects.html +0 -49
  114. package/BoilerPlate/Documents/app/views/sections/section_sadeceParagraf.html +0 -13
  115. package/BoilerPlate/Documents/app/views/sections/section_services.html +0 -34
  116. package/BoilerPlate/Documents/app/views/sections/section_slider.html +0 -195
  117. package/BoilerPlate/Documents/app/views/sections/section_team.html +0 -42
  118. package/BoilerPlate/Documents/app/views/sections/section_testimonialSSS.html +0 -51
  119. package/BoilerPlate/Documents/app/views/sections/section_video_about.html +0 -31
  120. package/BoilerPlate/Documents/app/views/sections/show.html +0 -55
  121. package/BoilerPlate/Documents/app/views/users/auth.html +0 -12
  122. package/BoilerPlate/Documents/app/views/users/index.html +0 -26
  123. package/BoilerPlate/Documents/app/views/users/login.html +0 -33
  124. package/BoilerPlate/Documents/app/views/users/show.html +0 -5
  125. package/BoilerPlate/Documents/app/views/users/signup.html +0 -43
  126. package/BoilerPlate/Documents/app/views/users/user.html +0 -28
  127. package/BoilerPlate/Documents/config/config.js +0 -35
  128. package/BoilerPlate/Documents/config/env/development.js +0 -53
  129. package/BoilerPlate/Documents/config/env/env.json +0 -12
  130. package/BoilerPlate/Documents/config/env/production.js +0 -33
  131. package/BoilerPlate/Documents/config/env/test.js +0 -33
  132. package/BoilerPlate/Documents/config/express.js +0 -124
  133. package/BoilerPlate/Documents/config/imager.js +0 -36
  134. package/BoilerPlate/Documents/config/middlewares/authorization.js +0 -55
  135. package/BoilerPlate/Documents/config/passport/facebook.js +0 -43
  136. package/BoilerPlate/Documents/config/passport/github.js +0 -43
  137. package/BoilerPlate/Documents/config/passport/google.js +0 -43
  138. package/BoilerPlate/Documents/config/passport/linkedin.js +0 -44
  139. package/BoilerPlate/Documents/config/passport/local.js +0 -37
  140. package/BoilerPlate/Documents/config/passport/twitter.js +0 -42
  141. package/BoilerPlate/Documents/config/passport.js +0 -40
  142. package/BoilerPlate/Documents/config/routes.js +0 -104
  143. package/BoilerPlate/Documents/lib/utils.js +0 -79
  144. package/BoilerPlate/Documents/nodemon.json +0 -5
  145. package/BoilerPlate/Documents/package-lock.json +0 -8993
  146. package/BoilerPlate/Documents/package.json +0 -49
  147. package/BoilerPlate/Documents/public/css/TheDocs.min.css +0 -1
  148. package/BoilerPlate/Documents/public/css/custom.css +0 -102
  149. package/BoilerPlate/Documents/public/css/skin/skin-blue.css +0 -71
  150. package/BoilerPlate/Documents/public/css/skin/skin-blue.css.map +0 -10
  151. package/BoilerPlate/Documents/public/css/skin/skin-blue.min.css +0 -1
  152. package/BoilerPlate/Documents/public/css/skin/skin-brown.css +0 -71
  153. package/BoilerPlate/Documents/public/css/skin/skin-brown.css.map +0 -10
  154. package/BoilerPlate/Documents/public/css/skin/skin-brown.min.css +0 -1
  155. package/BoilerPlate/Documents/public/css/skin/skin-cyan.css +0 -71
  156. package/BoilerPlate/Documents/public/css/skin/skin-cyan.css.map +0 -10
  157. package/BoilerPlate/Documents/public/css/skin/skin-cyan.min.css +0 -1
  158. package/BoilerPlate/Documents/public/css/skin/skin-dark.css +0 -71
  159. package/BoilerPlate/Documents/public/css/skin/skin-dark.css.map +0 -10
  160. package/BoilerPlate/Documents/public/css/skin/skin-dark.min.css +0 -1
  161. package/BoilerPlate/Documents/public/css/skin/skin-gray.css +0 -71
  162. package/BoilerPlate/Documents/public/css/skin/skin-gray.css.map +0 -10
  163. package/BoilerPlate/Documents/public/css/skin/skin-gray.min.css +0 -1
  164. package/BoilerPlate/Documents/public/css/skin/skin-green.css +0 -71
  165. package/BoilerPlate/Documents/public/css/skin/skin-green.css.map +0 -10
  166. package/BoilerPlate/Documents/public/css/skin/skin-green.min.css +0 -1
  167. package/BoilerPlate/Documents/public/css/skin/skin-orange.css +0 -71
  168. package/BoilerPlate/Documents/public/css/skin/skin-orange.css.map +0 -10
  169. package/BoilerPlate/Documents/public/css/skin/skin-orange.min.css +0 -1
  170. package/BoilerPlate/Documents/public/css/skin/skin-pink.css +0 -71
  171. package/BoilerPlate/Documents/public/css/skin/skin-pink.css.map +0 -10
  172. package/BoilerPlate/Documents/public/css/skin/skin-pink.min.css +0 -1
  173. package/BoilerPlate/Documents/public/css/skin/skin-purple.css +0 -71
  174. package/BoilerPlate/Documents/public/css/skin/skin-purple.css.map +0 -10
  175. package/BoilerPlate/Documents/public/css/skin/skin-purple.min.css +0 -1
  176. package/BoilerPlate/Documents/public/css/skin/skin-red.css +0 -71
  177. package/BoilerPlate/Documents/public/css/skin/skin-red.css.map +0 -10
  178. package/BoilerPlate/Documents/public/css/skin/skin-red.min.css +0 -1
  179. package/BoilerPlate/Documents/public/css/skin/skin-teal.css +0 -71
  180. package/BoilerPlate/Documents/public/css/skin/skin-teal.css.map +0 -10
  181. package/BoilerPlate/Documents/public/css/skin/skin-teal.min.css +0 -1
  182. package/BoilerPlate/Documents/public/css/skin/skin-yellow.css +0 -71
  183. package/BoilerPlate/Documents/public/css/skin/skin-yellow.css.map +0 -10
  184. package/BoilerPlate/Documents/public/css/skin/skin-yellow.min.css +0 -1
  185. package/BoilerPlate/Documents/public/css/theDocs/_alerts.scss +0 -49
  186. package/BoilerPlate/Documents/public/css/theDocs/_banner.scss +0 -225
  187. package/BoilerPlate/Documents/public/css/theDocs/_blog.scss +0 -240
  188. package/BoilerPlate/Documents/public/css/theDocs/_breadcrumb.scss +0 -10
  189. package/BoilerPlate/Documents/public/css/theDocs/_buttons.scss +0 -143
  190. package/BoilerPlate/Documents/public/css/theDocs/_carousel.scss +0 -92
  191. package/BoilerPlate/Documents/public/css/theDocs/_code.scss +0 -372
  192. package/BoilerPlate/Documents/public/css/theDocs/_color.scss +0 -38
  193. package/BoilerPlate/Documents/public/css/theDocs/_content.scss +0 -108
  194. package/BoilerPlate/Documents/public/css/theDocs/_faq.scss +0 -82
  195. package/BoilerPlate/Documents/public/css/theDocs/_files.scss +0 -137
  196. package/BoilerPlate/Documents/public/css/theDocs/_footer.scss +0 -82
  197. package/BoilerPlate/Documents/public/css/theDocs/_form.scss +0 -24
  198. package/BoilerPlate/Documents/public/css/theDocs/_header.scss +0 -374
  199. package/BoilerPlate/Documents/public/css/theDocs/_jumbotron.scss +0 -150
  200. package/BoilerPlate/Documents/public/css/theDocs/_labels.scss +0 -23
  201. package/BoilerPlate/Documents/public/css/theDocs/_media.scss +0 -24
  202. package/BoilerPlate/Documents/public/css/theDocs/_mixins.scss +0 -66
  203. package/BoilerPlate/Documents/public/css/theDocs/_pagination.scss +0 -75
  204. package/BoilerPlate/Documents/public/css/theDocs/_promo.scss +0 -112
  205. package/BoilerPlate/Documents/public/css/theDocs/_requirements.scss +0 -53
  206. package/BoilerPlate/Documents/public/css/theDocs/_sidebar.scss +0 -666
  207. package/BoilerPlate/Documents/public/css/theDocs/_step.scss +0 -161
  208. package/BoilerPlate/Documents/public/css/theDocs/_tab.scss +0 -105
  209. package/BoilerPlate/Documents/public/css/theDocs/_tables.scss +0 -106
  210. package/BoilerPlate/Documents/public/css/theDocs/_toc.scss +0 -78
  211. package/BoilerPlate/Documents/public/css/theDocs/_typography.scss +0 -282
  212. package/BoilerPlate/Documents/public/css/theDocs/_variables.scss +0 -98
  213. package/BoilerPlate/Documents/public/css/theDocs/_views.scss +0 -215
  214. package/BoilerPlate/Documents/public/css/theDocs/skins/_skin.scss +0 -76
  215. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-blue.scss +0 -3
  216. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-brown.scss +0 -3
  217. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-cyan.scss +0 -3
  218. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-dark.scss +0 -3
  219. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-gray.scss +0 -3
  220. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-green.scss +0 -3
  221. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-orange.scss +0 -3
  222. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-pink.scss +0 -3
  223. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-purple.scss +0 -3
  224. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-red.scss +0 -3
  225. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-teal.scss +0 -3
  226. package/BoilerPlate/Documents/public/css/theDocs/skins/skin-yellow.scss +0 -3
  227. package/BoilerPlate/Documents/public/css/theDocs.all.min.css +0 -24
  228. package/BoilerPlate/Documents/public/css/theDocs.css +0 -3945
  229. package/BoilerPlate/Documents/public/css/theDocs.css.map +0 -38
  230. package/BoilerPlate/Documents/public/css/theDocs.scss +0 -70
  231. package/BoilerPlate/Documents/public/fonts/FontAwesome.otf +0 -0
  232. package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.eot +0 -0
  233. package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.svg +0 -2671
  234. package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.ttf +0 -0
  235. package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.woff +0 -0
  236. package/BoilerPlate/Documents/public/fonts/fontawesome-webfont.woff2 +0 -0
  237. package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.eot +0 -0
  238. package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.svg +0 -288
  239. package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  240. package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.woff +0 -0
  241. package/BoilerPlate/Documents/public/fonts/glyphicons-halflings-regular.woff2 +0 -0
  242. package/BoilerPlate/Documents/public/img/apple-touch-icon-114x114.png +0 -0
  243. package/BoilerPlate/Documents/public/img/apple-touch-icon-72x72.png +0 -0
  244. package/BoilerPlate/Documents/public/img/apple-touch-icon.png +0 -0
  245. package/BoilerPlate/Documents/public/img/arrow-circle-down.svg +0 -1
  246. package/BoilerPlate/Documents/public/img/arrow-circle-right.svg +0 -1
  247. package/BoilerPlate/Documents/public/img/atlassian.svg +0 -1
  248. package/BoilerPlate/Documents/public/img/avatar-1.jpg +0 -0
  249. package/BoilerPlate/Documents/public/img/banner-default.png +0 -0
  250. package/BoilerPlate/Documents/public/img/banner-full-height.png +0 -0
  251. package/BoilerPlate/Documents/public/img/banner-lg.png +0 -0
  252. package/BoilerPlate/Documents/public/img/banner-sample1.png +0 -0
  253. package/BoilerPlate/Documents/public/img/banner-sample2.png +0 -0
  254. package/BoilerPlate/Documents/public/img/banner-sample3.png +0 -0
  255. package/BoilerPlate/Documents/public/img/banner-sm.png +0 -0
  256. package/BoilerPlate/Documents/public/img/banner.jpg +0 -0
  257. package/BoilerPlate/Documents/public/img/banner1.jpg +0 -0
  258. package/BoilerPlate/Documents/public/img/banner2.jpg +0 -0
  259. package/BoilerPlate/Documents/public/img/banner3.jpg +0 -0
  260. package/BoilerPlate/Documents/public/img/banner4.png +0 -0
  261. package/BoilerPlate/Documents/public/img/banner5.png +0 -0
  262. package/BoilerPlate/Documents/public/img/check-circle.svg +0 -1
  263. package/BoilerPlate/Documents/public/img/chevron-circle-right.svg +0 -1
  264. package/BoilerPlate/Documents/public/img/circle-with-minus.svg +0 -1
  265. package/BoilerPlate/Documents/public/img/circle-with-plus.svg +0 -1
  266. package/BoilerPlate/Documents/public/img/cloud.svg +0 -1
  267. package/BoilerPlate/Documents/public/img/conference-image-1.jpg +0 -0
  268. package/BoilerPlate/Documents/public/img/conference-image-2.jpg +0 -0
  269. package/BoilerPlate/Documents/public/img/conference-image-3.jpg +0 -0
  270. package/BoilerPlate/Documents/public/img/edward.jpg +0 -0
  271. package/BoilerPlate/Documents/public/img/elderwand-logo.png +0 -0
  272. package/BoilerPlate/Documents/public/img/email.svg +0 -1
  273. package/BoilerPlate/Documents/public/img/envato.svg +0 -1
  274. package/BoilerPlate/Documents/public/img/facebook.svg +0 -1
  275. package/BoilerPlate/Documents/public/img/favicon.png +0 -0
  276. package/BoilerPlate/Documents/public/img/heart.svg +0 -1
  277. package/BoilerPlate/Documents/public/img/images.svg +0 -1
  278. package/BoilerPlate/Documents/public/img/index.png +0 -0
  279. package/BoilerPlate/Documents/public/img/jacob.jpg +0 -0
  280. package/BoilerPlate/Documents/public/img/jquery.svg +0 -1
  281. package/BoilerPlate/Documents/public/img/jumbotron-bg.png +0 -0
  282. package/BoilerPlate/Documents/public/img/layout-single1.png +0 -0
  283. package/BoilerPlate/Documents/public/img/layout-single2.png +0 -0
  284. package/BoilerPlate/Documents/public/img/layout-single3.png +0 -0
  285. package/BoilerPlate/Documents/public/img/location-pin.svg +0 -1
  286. package/BoilerPlate/Documents/public/img/lucy.jpg +0 -0
  287. package/BoilerPlate/Documents/public/img/mamtas-logo-simple.png +0 -0
  288. package/BoilerPlate/Documents/public/img/music.svg +0 -1
  289. package/BoilerPlate/Documents/public/img/nathan.jpg +0 -0
  290. package/BoilerPlate/Documents/public/img/navbar-dark.png +0 -0
  291. package/BoilerPlate/Documents/public/img/navbar-default.png +0 -0
  292. package/BoilerPlate/Documents/public/img/navbar-fullwidth.png +0 -0
  293. package/BoilerPlate/Documents/public/img/navbar-lg.png +0 -0
  294. package/BoilerPlate/Documents/public/img/navbar-light.png +0 -0
  295. package/BoilerPlate/Documents/public/img/navbar-sm.png +0 -0
  296. package/BoilerPlate/Documents/public/img/phone.svg +0 -1
  297. package/BoilerPlate/Documents/public/img/placeholder-1900.png +0 -0
  298. package/BoilerPlate/Documents/public/img/placeholder.png +0 -0
  299. package/BoilerPlate/Documents/public/img/sidebar-default.png +0 -0
  300. package/BoilerPlate/Documents/public/img/sidebar-icon.png +0 -0
  301. package/BoilerPlate/Documents/public/img/sidebar-line.png +0 -0
  302. package/BoilerPlate/Documents/public/img/skin-blue.png +0 -0
  303. package/BoilerPlate/Documents/public/img/skin-brown.png +0 -0
  304. package/BoilerPlate/Documents/public/img/skin-cyan.png +0 -0
  305. package/BoilerPlate/Documents/public/img/skin-dark.png +0 -0
  306. package/BoilerPlate/Documents/public/img/skin-default.png +0 -0
  307. package/BoilerPlate/Documents/public/img/skin-gray.png +0 -0
  308. package/BoilerPlate/Documents/public/img/skin-green.png +0 -0
  309. package/BoilerPlate/Documents/public/img/skin-orange.png +0 -0
  310. package/BoilerPlate/Documents/public/img/skin-pink.png +0 -0
  311. package/BoilerPlate/Documents/public/img/skin-purple.png +0 -0
  312. package/BoilerPlate/Documents/public/img/skin-red.png +0 -0
  313. package/BoilerPlate/Documents/public/img/skin-teal.png +0 -0
  314. package/BoilerPlate/Documents/public/img/skin-yellow.png +0 -0
  315. package/BoilerPlate/Documents/public/img/skype.svg +0 -1
  316. package/BoilerPlate/Documents/public/img/step1.png +0 -0
  317. package/BoilerPlate/Documents/public/img/step2.png +0 -0
  318. package/BoilerPlate/Documents/public/img/step3.png +0 -0
  319. package/BoilerPlate/Documents/public/img/step4.png +0 -0
  320. package/BoilerPlate/Documents/public/img/tumblr.svg +0 -1
  321. package/BoilerPlate/Documents/public/img/twitter.svg +0 -1
  322. package/BoilerPlate/Documents/public/img/video-dawn.mp4 +0 -0
  323. package/BoilerPlate/Documents/public/img/video.svg +0 -1
  324. package/BoilerPlate/Documents/public/js/custom.js +0 -26
  325. package/BoilerPlate/Documents/public/js/default.js +0 -1
  326. package/BoilerPlate/Documents/public/js/theDocs.all.min.js +0 -102
  327. package/BoilerPlate/Documents/public/js/theDocs.js +0 -482
  328. package/BoilerPlate/Documents/public/js/theDocs.min.js +0 -6
  329. package/BoilerPlate/Documents/public/js/vendor/bootstrap.carousel.js +0 -1
  330. package/BoilerPlate/Documents/public/js/vendor/bootstrap.collapse.js +0 -1
  331. package/BoilerPlate/Documents/public/js/vendor/bootstrap.dropdown.js +0 -1
  332. package/BoilerPlate/Documents/public/js/vendor/bootstrap.tab.js +0 -1
  333. package/BoilerPlate/Documents/public/js/vendor/bootstrap.transition.js +0 -1
  334. package/BoilerPlate/Documents/public/js/vendor/jquery-1.11.3.min.js +0 -4
  335. package/BoilerPlate/Documents/public/js/vendor/jquery.drawsvg.js +0 -1
  336. package/BoilerPlate/Documents/public/js/vendor/jquery.mobile.custom.min.js +0 -1
  337. package/BoilerPlate/Documents/public/js/vendor/webfontloader.js +0 -1
  338. package/BoilerPlate/Documents/public/sample.html +0 -530
  339. package/BoilerPlate/Documents/public/style.css +0 -10
  340. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap-theme.css +0 -587
  341. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap-theme.css.map +0 -1
  342. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap-theme.min.css +0 -6
  343. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap-theme.min.css.map +0 -1
  344. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap.css +0 -6757
  345. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap.css.map +0 -1
  346. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap.min.css +0 -6
  347. package/BoilerPlate/Documents/public/vendors/bootstrap/css/bootstrap.min.css.map +0 -1
  348. package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
  349. package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.svg +0 -288
  350. package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
  351. package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
  352. package/BoilerPlate/Documents/public/vendors/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
  353. package/BoilerPlate/Documents/public/vendors/bootstrap/js/bootstrap.js +0 -2377
  354. package/BoilerPlate/Documents/public/vendors/bootstrap/js/bootstrap.min.js +0 -7
  355. package/BoilerPlate/Documents/public/vendors/bootstrap/js/npm.js +0 -13
  356. package/BoilerPlate/Documents/public/vendors/clipboard.js/clipboard.js +0 -778
  357. package/BoilerPlate/Documents/public/vendors/clipboard.js/clipboard.min.js +0 -7
  358. package/BoilerPlate/Documents/public/vendors/fitvids/jquery.fitvids.js +0 -11
  359. package/BoilerPlate/Documents/public/vendors/font-awesome/css/font-awesome.css +0 -2337
  360. package/BoilerPlate/Documents/public/vendors/font-awesome/css/font-awesome.min.css +0 -4
  361. package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/FontAwesome.otf +0 -0
  362. package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.eot +0 -0
  363. package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.svg +0 -2671
  364. package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
  365. package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.woff +0 -0
  366. package/BoilerPlate/Documents/public/vendors/font-awesome/fonts/fontawesome-webfont.woff2 +0 -0
  367. package/BoilerPlate/Documents/public/vendors/font-awesome/less/animated.less +0 -34
  368. package/BoilerPlate/Documents/public/vendors/font-awesome/less/bordered-pulled.less +0 -25
  369. package/BoilerPlate/Documents/public/vendors/font-awesome/less/core.less +0 -12
  370. package/BoilerPlate/Documents/public/vendors/font-awesome/less/fixed-width.less +0 -6
  371. package/BoilerPlate/Documents/public/vendors/font-awesome/less/font-awesome.less +0 -18
  372. package/BoilerPlate/Documents/public/vendors/font-awesome/less/icons.less +0 -789
  373. package/BoilerPlate/Documents/public/vendors/font-awesome/less/larger.less +0 -13
  374. package/BoilerPlate/Documents/public/vendors/font-awesome/less/list.less +0 -19
  375. package/BoilerPlate/Documents/public/vendors/font-awesome/less/mixins.less +0 -60
  376. package/BoilerPlate/Documents/public/vendors/font-awesome/less/path.less +0 -15
  377. package/BoilerPlate/Documents/public/vendors/font-awesome/less/rotated-flipped.less +0 -20
  378. package/BoilerPlate/Documents/public/vendors/font-awesome/less/screen-reader.less +0 -5
  379. package/BoilerPlate/Documents/public/vendors/font-awesome/less/stacked.less +0 -20
  380. package/BoilerPlate/Documents/public/vendors/font-awesome/less/variables.less +0 -800
  381. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_animated.scss +0 -34
  382. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_bordered-pulled.scss +0 -25
  383. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_core.scss +0 -12
  384. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_fixed-width.scss +0 -6
  385. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_icons.scss +0 -789
  386. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_larger.scss +0 -13
  387. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_list.scss +0 -19
  388. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_mixins.scss +0 -60
  389. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_path.scss +0 -15
  390. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_rotated-flipped.scss +0 -20
  391. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_screen-reader.scss +0 -5
  392. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_stacked.scss +0 -20
  393. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/_variables.scss +0 -800
  394. package/BoilerPlate/Documents/public/vendors/font-awesome/scss/font-awesome.scss +0 -18
  395. package/BoilerPlate/Documents/public/vendors/jquery/jquery.min.js +0 -4
  396. package/BoilerPlate/Documents/public/vendors/lity/lity.css +0 -200
  397. package/BoilerPlate/Documents/public/vendors/lity/lity.js +0 -637
  398. package/BoilerPlate/Documents/public/vendors/lity/lity.min.css +0 -3
  399. package/BoilerPlate/Documents/public/vendors/lity/lity.min.js +0 -4
  400. package/BoilerPlate/Documents/public/vendors/matchHeight.min.js +0 -11
  401. package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/css/perfect-scrollbar.css +0 -113
  402. package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/css/perfect-scrollbar.min.css +0 -2
  403. package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/js/perfect-scrollbar.jquery.js +0 -1580
  404. package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/js/perfect-scrollbar.jquery.min.js +0 -2
  405. package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/js/perfect-scrollbar.js +0 -1553
  406. package/BoilerPlate/Documents/public/vendors/perfect-scrollbar/js/perfect-scrollbar.min.js +0 -2
  407. package/BoilerPlate/Documents/public/vendors/prism/prism.css +0 -7
  408. package/BoilerPlate/Documents/public/vendors/prism/prism.js +0 -54
  409. package/BoilerPlate/Documents/server.js +0 -63
  410. package/BoilerPlate/Documents/tempUploads/068f2b77c0e0723b97909b2ffa438fe6.pdf +0 -0
  411. package/BoilerPlate/Documents/tempUploads/6443f8fd5d507b5a5f76829962fc2dc0.docx +0 -0
  412. package/BoilerPlate/Documents/tempUploads/7e4560af2cd6cae130bdb79fecaa6437.pdf +0 -0
  413. package/BoilerPlate/Documents/tempUploads/84b6ad7e0deefc348cfd582c9715ec1d.pdf +0 -0
  414. package/BoilerPlate/Documents/tempUploads/a894549ed062ada5f48f364a236a7e76.png +0 -0
  415. package/BoilerPlate/Documents/tempUploads/c2727b94bc909b118b25ae35f0897713.png +0 -0
  416. package/BoilerPlate/Documents/tempUploads/c588a76c8b0c4b76df2e36bd602a8821.docx +0 -0
  417. package/BoilerPlate/Documents/tempUploads/d6476c43a03950899e6db91c95dbc8aa.docx +0 -0
  418. package/BoilerPlate/Documents/tempUploads/dc4ffdc0a703353e0280384afc6ad082.png +0 -0
  419. package/BoilerPlate/Documents/test/helper.js +0 -27
  420. package/BoilerPlate/Documents/test/test-articles.js +0 -176
  421. package/BoilerPlate/Documents/test/test-users.js +0 -106
  422. package/BoilerPlate/Documents/uploads/section/5ad9bb9853017c217c6673d5/0cb1f166cbb6b46ffc630cb1c86db0a1.png +0 -0
  423. package/BoilerPlate/Documents/uploads/section/5ad9bb9853017c217c6673d5/37fbc499e5eea091ab7215855bf7918b.png +0 -0
  424. package/BoilerPlate/Documents/uploads/section/5ad9bb9853017c217c6673d5/4b0d6e11c87b31cc6c32e18be5a49b6b.pdf +0 -0
  425. package/BoilerPlate/Documents/uploads/section/5ad9bb9853017c217c6673d5/d4248bccecc0f55dd2fe7cd388c4c1ce.docx +0 -0
  426. package/BoilerPlate/Documents/uploads/section/5ad9bbd853017c217c6673d8/7c7b0d7f03359c38e3411ec448bdc746.png +0 -0
  427. package/BoilerPlate/Documents/uploads/section/5ad9bbd853017c217c6673d8/8c7eeb092084ee8349f12ceb7e6dab2d.docx +0 -0
  428. package/BoilerPlate/Documents/uploads/section/5ad9bbd853017c217c6673d8/b512a8558523894f0d9292f39dcd9d82.pdf +0 -0
  429. package/BoilerPlate/Documents/uploads/section/5ad9bc111b67922eb0f547d5/06cdca751d7c5897179af1bb956e13d3.docx +0 -0
  430. package/BoilerPlate/Documents/uploads/section/5ad9bc111b67922eb0f547d5/4fe0695295a41c9e3e5af0d2fd52bbae.png +0 -0
  431. package/BoilerPlate/Documents/uploads/section/5ad9c7ce673a50173865614b/1c68ca7ae23099cd139801766ccec600.docx +0 -0
  432. package/BoilerPlate/Documents/uploads/section/5ad9c7ce673a50173865614b/7d7d49834eea7899d77a29dda1d25bf4.pdf +0 -0
  433. package/BoilerPlate/Documents/uploads/section/5ad9c826673a50173865614e/301398c02f647d1e1804d48233e9e7e0.pdf +0 -0
  434. package/BoilerPlate/Documents/uploads/section/5ad9c826673a50173865614e/c9ca2431eed90529a633f88c6781e686.docx +0 -0
  435. package/BoilerPlate/Documents/uploads/section/5ad9c85f673a501738656153/71b1d92caefe43821426d139e6c931d1.pdf +0 -0
  436. package/BoilerPlate/Documents/uploads/section/5ad9c85f673a501738656153/a0735aa1e0befd14449b26063c112d46.docx +0 -0
  437. package/BoilerPlate/Documents/uploads/section/5ad9ce22f534442218fb8016/31724098865f19fd968d6167736bd388.docx +0 -0
  438. package/BoilerPlate/Documents/uploads/section/5ad9d714f534442218fb801b/a71e1f795a7c2f260ccbd877e9e03b17.docx +0 -0
  439. package/BoilerPlate/Documents/uploads/section/5ad9d755f534442218fb801e/c23154466cfcbb8aa9101509cc990962.docx +0 -0
  440. package/BoilerPlate/Documents/uploads/section/5ad9d816f534442218fb8021/e90f3adde177c831dd96d8fcf2f6bf17.docx +0 -0
  441. package/BoilerPlate/Documents/uploads/section/5ad9d83bf534442218fb8024/11a310205cd7c1b3f0a53cd4a3e1cd91.png +0 -0
  442. package/BoilerPlate/Documents/uploads/section/5ad9d83bf534442218fb8024/4c45d0286d8b0ae23fe1ccfd2d0f6b52.pdf +0 -0
  443. package/BoilerPlate/Documents/uploads/section/5ad9d83bf534442218fb8024/6dd38b8628ef60ea09e982c375720d94.docx +0 -0
  444. package/dump.rdb +0 -0
@@ -31,7 +31,7 @@ module.exports = function(){
31
31
  }
32
32
  });
33
33
  addPropertyToClass(global, '__line', undefined,{
34
- gçet: function(){
34
+ get: function(){
35
35
  return __stack[1].getLineNumber();
36
36
  }
37
37
  });
@@ -54,7 +54,7 @@ module.exports = function(){
54
54
  addPropertyToClass(global, "EWLog", function(){
55
55
  var date = new Date();
56
56
  var dateStr = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + ":"+ date.getMilliseconds()
57
- var args = [dateStr,__caller];
57
+ var args = [dateStr, __caller];
58
58
  for(var key in arguments){
59
59
  args.push(arguments[key]);
60
60
  }
@@ -1,68 +1,116 @@
1
- [![Build Status](https://travis-ci.org/riyadhalnur/mongoose-softdelete.svg?branch=master)](https://travis-ci.org/riyadhalnur/mongoose-softdelete)
1
+ # elderwand-mongoose-no-duplicate
2
2
 
3
- Mongoose Soft Delete Plugin
4
- ============================
3
+ A Mongoose plugin that prevents duplicate documents by hashing a document's
4
+ content into a unique-indexed `sha1_hash` field. When two documents would
5
+ have the same content, the second `.save()` is rejected by MongoDB with a
6
+ duplicate-key error.
5
7
 
6
- Mongoose plugin that enables soft deletion of Models/Documents.
8
+ ## How it works
7
9
 
8
- This plugin is based on the work of [Yi](https://github.com/yi).
10
+ 1. The plugin adds a `sha1_hash: String` field with `unique: true`.
11
+ 2. On every `.save()`, a `pre('save')` hook computes
12
+ `sha1(JSON.stringify(model.toObject()))` with selected fields excluded or
13
+ included, and stores the result in `sha1_hash`.
14
+ 3. The unique index ensures MongoDB rejects any insert whose content (per
15
+ the hash) is already in the collection.
9
16
 
10
- ## What's Different
11
- In the original plugin, models were deleted with a date reference only. This version takes that and uses a Boolean flag to to mark models deleted/restored. Adds `deletedAt` field to record when a document was deleted. Additionally, it removes a lot of overhead from the original code and doesn't use Coffeescript for the original code.
17
+ ## Usage
12
18
 
13
- ## License
14
- This plugin is licensed under the MIT license and can ve viewed in the LICENSE file.
19
+ ### Exclude specific fields from the hash
15
20
 
16
- ## Installation
17
- Install using [npm](https://npmjs.org)
18
- ```
19
- npm install mongoose-softdelete --save
20
- ```
21
-
22
- ## Tests
23
- IMPORTANT: You need to have MongoDB running to run tests
21
+ ```js
22
+ var mongoose = require('mongoose');
23
+ var no_duplicate = require('elderwand-mongoose-no-duplicate');
24
+
25
+ var ArticleSchema = new mongoose.Schema({
26
+ title: String,
27
+ body: String,
28
+ createdAt: Date,
29
+ lastSeenAt: Date,
30
+ meta: {
31
+ views: Number,
32
+ flags: { internal: String }
33
+ }
34
+ });
24
35
 
25
- ```
26
- npm test
36
+ ArticleSchema.plugin(no_duplicate.getPluginWithOptions({
37
+ exclude: [
38
+ 'createdAt',
39
+ 'lastSeenAt',
40
+ 'meta.views',
41
+ 'meta.flags.internal'
42
+ ],
43
+ sparse: true // unique index is sparse — only enforced on docs that
44
+ // have sha1_hash set (every saved doc, in practice)
45
+ }));
46
+
47
+ mongoose.model('Article', ArticleSchema);
27
48
  ```
28
49
 
29
- ## Usage
50
+ Two articles with identical `title` and `body` will collide on `sha1_hash`
51
+ even if their timestamps and `meta.views` counts differ.
30
52
 
31
- **models/test.js**
53
+ ### Hash only specific fields
32
54
 
33
55
  ```js
34
- var mongoose = require('mongoose'),
35
- Schema = mongoose.Schema,
36
- soft_delete = require('mongoose-softdelete');
56
+ ArticleSchema.plugin(no_duplicate.getPluginWithOptions({
57
+ includeOnly: ['title', 'body'],
58
+ sparse: true
59
+ }));
60
+ ```
37
61
 
38
- var TestSchema = new Schema({
39
- somefield: { type: String, default: 'Hello World!'}
40
- });
62
+ Only `title` and `body` contribute to the hash; everything else is ignored.
63
+
64
+ ## Plugin options
41
65
 
42
- TestSchema.plugin(soft_delete);
66
+ | Option | Type | Default | Notes |
67
+ | ------------- | --------- | ------- | ---------------------------------------------------------------------- |
68
+ | `exclude` | string[] | `[]` | Top-level or dotted paths to omit from the hash input. |
69
+ | `includeOnly` | string[] | — | If set, only these paths contribute to the hash (overrides `exclude`). |
70
+ | `sparse` | boolean | `false` | Forwarded to the unique index definition. |
71
+ | `dropDups` | boolean | `false` | Forwarded to mongoose. **Note:** removed in MongoDB ≥ 3.0; ignored. |
43
72
 
44
- mongoose.model('Test', TestSchema);
45
- ```
73
+ `_id` is always excluded from the hash regardless of `exclude` /
74
+ `includeOnly` — otherwise every document would be unique by definition.
46
75
 
47
- **controllers/test.js**
76
+ ## Catching the duplicate error
48
77
 
49
- ```js
50
- var Test = mongoose.model('Test');
51
- var test = new Test();
78
+ When the unique index trips, MongoDB raises an `E11000 duplicate key
79
+ error`. The plugin does not translate or wrap this — callers should check
80
+ for `err.code === 11000`:
52
81
 
53
- test.softdelete(function(err, newTest) {
54
- if (err) { callback(err); }
55
- callback(null, newTest);
82
+ ```js
83
+ new Article({ title: 'Same', body: 'thing' }).save(function (err, doc) {
84
+ if (err && err.code === 11000) {
85
+ return console.log('duplicate; document already exists');
86
+ }
87
+ if (err) return handle(err);
88
+ return console.log('saved:', doc._id);
56
89
  });
90
+ ```
91
+
92
+ ## Limitations
93
+
94
+ These are known and documented in the characterization test suite:
57
95
 
58
- test.restore(function(err, newTest) {
59
- if (err) { callback(err); }
60
- callback(null, newTest);
61
- });
62
- ```
63
-
64
- Built with love in Dhaka, Bangladesh by [Riyadh Al Nur](https://twitter.com/riyadhalnur)
96
+ - The hash is derived from `JSON.stringify(model.toObject())` — key
97
+ insertion order matters. Two semantically identical documents whose keys
98
+ were set in different orders may hash differently. Don't rely on this
99
+ plugin for cross-system content equivalence.
100
+ - Insert paths that bypass `.save()` (i.e. `Model.insertMany`,
101
+ `Model.collection.insert(…)`, `findOneAndUpdate({…}, {upsert: true})`)
102
+ skip the `pre('save')` hook, so the `sha1_hash` field is never populated
103
+ and duplicates are not blocked on those paths.
104
+ - `dropDups` is forwarded to mongoose for backwards compatibility but is a
105
+ no-op against MongoDB ≥ 3.0.
106
+
107
+ ## Tests
108
+
109
+ ```
110
+ npm test # offline characterization suite
111
+ npm run test:integration # requires MongoDB at localhost:27017
112
+ ```
65
113
 
114
+ ## License
66
115
 
67
- **Populate**
68
- I Added function to fix the problem that loading soft deleted objects when populating properties
116
+ MIT.
@@ -4,47 +4,65 @@ var mongoose = require('mongoose')
4
4
  , Query = mongoose.Query
5
5
  , crypto = require("crypto");
6
6
  var defaultExclude = ["_id"];
7
+
8
+ /**
9
+ * Navigate a dotted path on `obj`, applying `action(token, lastKey)` to
10
+ * the parent of the final segment. Returns false if the path could not
11
+ * be fully resolved (i.e. an intermediate key is missing or non-object).
12
+ *
13
+ * Fix: the original code dereferenced intermediate path keys without a
14
+ * guard and crashed with `Cannot read properties of undefined` whenever
15
+ * a document was missing a key in the middle of a configured nested
16
+ * exclude/include path. This helper makes that case a no-op.
17
+ */
18
+ function walkDottedPath(obj, dottedKey, action){
19
+ if(dottedKey.indexOf(".") === -1){
20
+ action(obj, dottedKey);
21
+ return true;
22
+ }
23
+ var deep = dottedKey.split(".");
24
+ var last = deep.pop();
25
+ var token = obj;
26
+ for(var j = 0; j < deep.length; j++){
27
+ token = token != null ? token[deep[j]] : undefined;
28
+ if(token == null || typeof token !== "object"){
29
+ return false; // intermediate path missing — nothing to do
30
+ }
31
+ }
32
+ action(token, last);
33
+ return true;
34
+ }
35
+
7
36
  function hashObject(model, exclude){
8
- exclude = exclude.concat(defaultExclude);
37
+ exclude = (exclude || []).concat(defaultExclude);
9
38
  var obj = model.toObject();
10
39
 
11
- for(var i in exclude){
40
+ for(var i = 0; i < exclude.length; i++){
12
41
  var key = exclude[i];
13
- if(key.indexOf(".") != -1){
14
- var deep = key.split(".");
15
- var last = deep.pop();
16
- var token = obj;
17
- for(var j in deep){
18
- token = token[deep[j]];
19
- }
20
- token[last] = undefined;
21
- }else{
22
- obj[key] = undefined;
23
- }
42
+ walkDottedPath(obj, key, function(parent, lastKey){
43
+ parent[lastKey] = undefined;
44
+ });
24
45
  }
25
46
  return crypto.createHash('sha1').update(JSON.stringify(obj)).digest('Base64')
26
47
  }
27
48
  function hashIncludeOnlyObject(model, include){
28
49
  var obj = model.toObject();
29
50
  var hashObject = {}
30
- for(var i in include){
51
+ include = include || [];
52
+ for(var i = 0; i < include.length; i++){
31
53
  var key = include[i];
32
- if(key.indexOf(".") != -1){
33
- var deep = key.split(".");
34
- var last = deep.pop();
35
- var token = obj;
36
- for(var j in deep){
37
- token = token[deep[j]];
38
- }
39
- hashObject[key] = token[last]
40
- }else{
41
- hashObject[key] = obj[key];
42
- }
54
+ walkDottedPath(obj, key, function(parent, lastKey){
55
+ hashObject[key] = parent[lastKey];
56
+ });
43
57
  }
44
58
  return crypto.createHash('sha1').update(JSON.stringify(hashObject)).digest('Base64')
45
59
  }
46
60
  module.exports.getPluginWithOptions = function(options){
47
61
 
62
+ // Fix: tolerate `getPluginWithOptions()` and `getPluginWithOptions({})`
63
+ // rather than crashing on `options.sparse`. exclude/includeOnly fall
64
+ // back to empty arrays so the pre-save hook can run.
65
+ options = options || {};
48
66
  options.sparse = options.sparse || false;
49
67
  options.dropDups = options.dropDups || false;
50
68
  return function(schema) {