Skip to content

Instantly share code, notes, and snippets.

View koresar's full-sized avatar

Vasyl Boroviak koresar

View GitHub Profile
@koresar
koresar / app2.js
Last active September 4, 2017 05:44
Fun with Stamps. Episode 17. Easy 100% unit test coverage in JS: - app2.js
module.exports = require('@stamp/it')({
props: {
express: require('express'),
path: require('path'),
logger: require('morgan'),
cookieParser: require('cookie-parser'),
bodyParser: require('body-parser'),
http: require('http'),
debug: require('debug')('my-app-name:server'),
process,
@koresar
koresar / app.js
Last active July 23, 2017 03:53
Fun with Stamps. Episode 17. Easy 100% unit test coverage in JS: - app.js
const express = require('express');
const path = require('path');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const http = require('http');
const debug = require('debug')('my-app-name:server');
// Application
const app = express();
@koresar
koresar / privatize_plus_collision.js
Created February 9, 2017 02:43
Fun with stamps. Episode 12
import compose from '@stamp/compose';
import Privatize from '@stamp/privatize';
import Collision from '@stamp/collision';
const Password = compose({
properties: {
password: '12345qwert'
},
methods: {
getPassword() {
@koresar
koresar / collision.js
Last active January 26, 2017 01:51
Collision allowance and protection
const stampit = require('stampit');
const ProtectMethodCollisions = stampit({
statics: {
protectMethodCollisions(name) {
if (this.compose.methods && this.compose.methods[name]) {
const method = this.compose.methods[name];
function collisionProtectedMethodWrapper() {
return method.apply(this, arguments);
}
@koresar
koresar / index.js
Created December 27, 2016 01:08
Fun with Stamps. Episode 11. Interfering composition
const _ = require('lodash');
const stampit = require('stampit');
const isStamp = require('stampit/isStamp');
const Tracked = stampit()
.composers(({composables, stamp}) => { // declaring a composer
console.log(`Composed a stamp "${stamp}" from the following:
"${composables.join()}"`);
});
@koresar
koresar / gist:aca0ca81edc34f58462c
Last active June 5, 2016 00:03
Pick the prettiest logo for Stampit
function getUniqueKeys() {
var keys = [];
_.forEach(behaviors, function (behavior) {
keys.push(Object.keys(behavior.parametersTemplate));
}.bind(this));
return _.uniq(_.flatten(keys));
}
// OR