This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/Automattic/mongoose/issues/2596 | |
// 1. It was necessary for me to to fit our naming style to this behaviour. | |
// 2. And moreover, move to Mongoose 5 | |
// 3. And leave all data untouched, I mean, no changes, at all, a lot of production running data. | |
/** | |
* Discriminator Reflected mapping | |
* to discriminator value, | |
* used inside of existent db | |
* @param {object} baseModel : parent model used for discriminator creation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global.isSoftwareDeveloperDay = function () { | |
const DEVELOPER_DAY = | |
Math.pow(2, 8); | |
const UNIX_EPOCH_BEGIN = 864e5; | |
const timestmp = new Date() | |
.setFullYear( | |
(new Date()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// HOOKS EXAMPLE START | |
var counter = 0; | |
var currentId = 0; | |
var hooks = { | |
init: [], | |
before: [], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const common = require("../common"); | |
const assert = require("assert"); | |
const { AsyncContext } = require("async_hooks"); | |
const asyncContext = new AsyncContext(); | |
const tasks = []; | |
asyncContext.enter(store => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// Inheritance Map Example | |
const assert = require('assert'); | |
const { strictEqual, deepStrictEqual } = assert; | |
const util = require('util'); | |
const inspect = (value) => { | |
return util.inspect(value, { | |
colors : true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Pollen = { season : 'Spring' }; | |
// factory of constructors | |
var FlowersFactory = function (proto) { | |
var FlowerEggCell = function (sort) { | |
this.sort = sort; | |
}; | |
FlowerEggCell.prototype = proto; | |
return FlowerEggCell; | |
}; | |
var FlowerZygote = FlowersFactory(Pollen); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var createNamespace = require('cls-hooked').createNamespace; | |
const fn = () => { | |
var getNamespace = require('cls-hooked').getNamespace; | |
var session = getNamespace('my session'); | |
var user = session.get('user'); | |
process._rawDebug(user); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const { | |
AsyncResource, | |
executionAsyncId, | |
createHook, | |
} = require('async_hooks'); | |
const EventEmitter = require('events'); | |
const util = require('util'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const log = function (message, s) { | |
process.stdout.write(`${String(message).padEnd(17)} : ${s || ''}\n`); | |
}; | |
const YCombinator = async function (realWork) { | |
log('start', this); | |
return await (async function (cb_x) { | |
log('inside', this); | |
return await cb_x.call(this, cb_x); | |
}).call(this, async function (cb_y) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// just 4 fun & lools | |
class StringBoolean extends String { | |
static get [Symbol.species] () { | |
return Boolean; | |
} | |
get [Symbol.toStringTag] () { | |
return 'StringBoolean'; | |
} | |
get [Symbol.toString] () { |
OlderNewer