monastery 3.5.1 → 3.5.2

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.
package/changelog.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [3.5.2](https://github.com/boycce/monastery/compare/3.5.1...3.5.2) (2025-01-22)
6
+
5
7
  ### [3.5.1](https://github.com/boycce/monastery/compare/3.5.0...3.5.1) (2024-12-23)
6
8
 
7
9
  ## [3.5.0](https://github.com/boycce/monastery/compare/3.4.3...3.5.0) (2024-12-20)
package/lib/manager.js CHANGED
@@ -188,7 +188,7 @@ Manager.prototype.isId = function(value) {
188
188
  return util.isId(value)
189
189
  }
190
190
 
191
- Manager.prototype.models = async function(pathname, opts) {
191
+ Manager.prototype.models = async function(pathname, opts={}) {
192
192
  /**
193
193
  * Setup model definitions from a folder location
194
194
  * @param {string} pathname
@@ -199,7 +199,7 @@ Manager.prototype.models = async function(pathname, opts) {
199
199
  * @this Manager
200
200
  */
201
201
  let out = {}
202
- let { waitForIndexes } = opts || {}
202
+ let { waitForIndexes } = opts
203
203
  if (!pathname || typeof pathname !== 'string') {
204
204
  throw 'The path must be a valid pathname'
205
205
  }
@@ -235,6 +235,10 @@ Manager.prototype.onError = function(fn) {
235
235
  * @return {Promise}
236
236
  */
237
237
  return new Promise((resolve, reject) => {
238
+ if (!this.emitter) {
239
+ reject(new Error('Emitter not found! This can happen if two seperate monastery packages are imported into the ' +
240
+ 'same project. E.g. the first package initializes the manager, and the second package tries to use it.'))
241
+ }
238
242
  this.emitter.on('error', (err) => {
239
243
  resolve(err)
240
244
  })
@@ -250,6 +254,10 @@ Manager.prototype.onOpen = function(fn) {
250
254
  * @return {Promise(manager)}
251
255
  */
252
256
  return new Promise((resolve, reject) => {
257
+ if (!this.emitter) {
258
+ reject(new Error('Emitter not found! This can happen if two seperate monastery packages are imported into the ' +
259
+ 'same project. E.g. the first package initializes the manager, and the second package tries to use it.'))
260
+ }
253
261
  if (this._state == 'open') {
254
262
  resolve(this)
255
263
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "monastery",
3
3
  "description": "⛪ A simple, straightforward MongoDB ODM",
4
4
  "author": "Ricky Boyce",
5
- "version": "3.5.1",
5
+ "version": "3.5.2",
6
6
  "license": "MIT",
7
7
  "repository": "github:boycce/monastery",
8
8
  "homepage": "https://boycce.github.io/monastery/",