ejson-extras
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -13,2 +13,4 @@ const debug = require('debug')('ejson'); | ||
debug("-> Checking for available EJSON's"); | ||
const EJSONs = []; | ||
@@ -18,11 +20,14 @@ const npmEJSON = tryRequire('ejson'); | ||
debug('In meteor? %o', checkMeteor()); | ||
if (npmEJSON) { | ||
debug('found npm.ejson'); | ||
debug('-> Found npm.ejson'); | ||
EJSONs.push(npmEJSON); | ||
} else { | ||
debug('-> Did not find npm.ejson'); | ||
} | ||
if (meteorEJSON) { | ||
debug('found meteor.ejson'); | ||
debug('-> found meteor.ejson'); | ||
EJSONs.push(meteorEJSON); | ||
} else { | ||
debug('-> Did not find meteor.ejson'); | ||
} | ||
@@ -29,0 +34,0 @@ |
@@ -13,2 +13,4 @@ const debug = require('debug')('ejson'); | ||
debug('-> Are we running inside Meteor? %o', checkMeteor()); | ||
const npmEJSON = tryRequire('ejson'); | ||
@@ -19,4 +21,4 @@ const meteorEJSON = checkMeteor() ? getGlobal('ejson', 'EJSON') : null; | ||
debug('Found EJSON to use %O', EJSON); | ||
debug('-> Found EJSON to use %O.', EJSON); | ||
module.exports = EJSON; |
20
index.js
@@ -1,16 +0,18 @@ | ||
const addType = require('./addType'); | ||
const assign = Object.assign || require('object.assign'); | ||
const debug = require('debug')('ejson'); | ||
const types = require('./types'); | ||
const requireEJSON = require('./require/ejson'); | ||
let initialized = false; | ||
module.exports = { | ||
apply: function() { | ||
debug('Applying EJSON-extras...'); | ||
if (initialized) { | ||
debug('Already initialized...'); | ||
const EJSON = require('./ejson'); | ||
debug('-> Found custom types %O', EJSON._getTypes()); | ||
if (EJSON._getTypes().extras) { | ||
debug('00 Already initialized. Exiting'); | ||
return; | ||
} | ||
const addType = require('./addType'); | ||
const types = require('./types'); | ||
Object.values(types).forEach(({ prototype, shims, typeName, factory }) => { | ||
@@ -31,5 +33,9 @@ if (!prototype.__noSupportForEJSON) { | ||
if (typeof require === 'function') { | ||
const requireEJSON = require('./require/ejson'); | ||
debug(`-> adding support for EJSON to 'require'`); | ||
require.extensions['.json'] = requireEJSON; | ||
} | ||
debug('00 Finished. Exiting'); | ||
}, | ||
}; |
{ | ||
"name": "ejson-extras", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": | ||
@@ -12,3 +12,3 @@ "Extends EJSON with additional types, including Qty (js-quantities) objects.", | ||
"license": "MIT", | ||
"repository": "https://github.com/luzlab/ejson-extras.git", | ||
"repository": "git://github.com/luzlab/ejson-extras.git#v1.0.12", | ||
"dependencies": { | ||
@@ -15,0 +15,0 @@ "debug": "^3.1.0", |
@@ -85,6 +85,11 @@ # Description | ||
1.0.11 - Fixed patching of 'require' inside Meteor. | ||
1.0.10 - Fixed ejson detection and import inside Meteor. | ||
1.0.9 - Reverted to standard try/catch syntax. | ||
1.0.8 - Handles multiple calls to apply(). | ||
1.0.7 - Added Meteor autodetection for patching of bundled EJSON. | ||
1.0.6 - Removed dependancy on `fs` to enable browser usage of `ejson-extras`. |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
const debug = require('debug')('ejson'); | ||
const fs = require('fs'); | ||
@@ -6,5 +6,6 @@ const stripBom = require('strip-bom'); | ||
debug('-> Building replacement parser for require with %O', EJSON); | ||
module.exports = (module, filename) => { | ||
const content = fs.readFileSync(filename, 'utf8'); | ||
try { | ||
@@ -11,0 +12,0 @@ module.exports = EJSON.parse(stripBom(content)); |
@@ -9,3 +9,6 @@ // Reading the directory and adding all the files automatically won't work when this module is run on the browser. | ||
// "marker" is a dummy type that's used to detect if we've already patched EJSON | ||
const marker = { prototype: {}, shims: {}, factory: true, typeName: 'extras' }; | ||
// module.exports = requireDirectory(module, { exclude: /.+test\.js/ }); | ||
module.exports = { qty, map }; | ||
module.exports = { qty, map, marker }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
11995
260
95