Skip to content

Instantly share code, notes, and snippets.

View WesTyler's full-sized avatar
:octocat:
.

Wes Tyler WesTyler

:octocat:
.
  • 06:39 (UTC -05:00)
View GitHub Profile
@WesTyler
WesTyler / index.js
Created February 17, 2017 21:28
JSON stringify bug with prototype conflict
'use strict';
// Observed in Node v4.5.0 and v5.0.0
// Does not appear to affect Node versions >= 6.x
const Thing = function(input) {
this.value = input;
Object.defineProperty(this, 'nonEnum', {value: 'this should not serialize'});
};
Thing.prototype.nonEnum = 'Overwrite the nonEnum to trigger the bug';
server.register(plugin, registrationOptions, (err) => {
if (err) {
console.log('Plugin registration error. Deal with it.');
}
});
await server.register(plugin, registrationOptions);
const register = (server, options, next) => {
// Do your registration stuff
return next();
};
register.attributes = {
name: 'pluginName',
version: '1.0.1'
};
server.register({ register }, () => {});
const register = async (server, options) => {
// Do your registration stuff
};
const plugin = {
register,
name: 'pluginName',
version: '1.0.1'
};
try {
await server.register(plugin);
server.register({ register, select: ['web'] }, () => {});
// OR
server.register({ register }, { select: ['web'] }, () => {});
await webServer.register(plugin1);
await adminServer.register(plugin2);
const register = (server, options, next) => {
// Do your registration stuff
return next();
};
register.attributes = {
name: 'pluginName',
version: '1.0.1'
};
const plugin = {
register,
const plugin = {
register: async (server, options) => {
// Do your registration stuff
},
name: 'pluginName',
version: '1.0.1',
once: true,
options: {}
};
try {
{
register: {
plugins: [
'myPlugin',
{ plugin: 'plugin2' },
{ plugin: require('finalPlugin') }
]
}
}