Skip to content

Instantly share code, notes, and snippets.

View jouni-kantola's full-sized avatar
😘

Jouni Kantola jouni-kantola

😘
View GitHub Profile
define(function(require) {
'use strict';
(function(window, undefined) {
// Prepare our Variables
var history = window.history,
document = window.document,
$ = require('jquery');
@jouni-kantola
jouni-kantola / stub-properties-and-methods-sinon.js
Created February 2, 2014 02:02
Sinon.JS used to stub properties and methods in a sandbox. Methods and properties are restored after test(s) are run.
define(['can', 'localCache'], function(can, localCache) {
'use strict';
describe('storeLocal()', function() {
var sandbox;
beforeEach(function() {
// create sandbox environment for mocking about
sandbox = sinon.sandbox.create();
});
@jouni-kantola
jouni-kantola / vdom-component
Last active August 29, 2015 14:13
Example of component with vDOM layer and pub/sub
(function() {
var Bacon = require('baconjs'),
doT = require('dot'),
createElement = require('virtual-dom/create-element'),
diff = require('virtual-dom/diff'),
patch = require('virtual-dom/patch'),
VNode = require('virtual-dom/vnode/vnode'),
VText = require('virtual-dom/vnode/vtext')
var convertHTML = require('html-to-vdom')({ VNode: VNode, VText: VText })
@jouni-kantola
jouni-kantola / index.js
Created January 20, 2015 07:32
requirebin sketch
var Bacon = require('baconjs'),
doT = require('dot'),
createElement = require('virtual-dom/create-element'),
diff = require('virtual-dom/diff'),
patch = require('virtual-dom/patch'),
VNode = require('virtual-dom/vnode/vnode'),
VText = require('virtual-dom/vnode/vtext')
var convertHTML = require('html-to-vdom')({
VNode: VNode,
@jouni-kantola
jouni-kantola / index.js
Created January 29, 2015 11:26
requirebin sketch
var Bacon = require('baconjs'),
doT = require('dot'),
createElement = require('virtual-dom/create-element'),
diff = require('virtual-dom/diff'),
patch = require('virtual-dom/patch'),
VNode = require('virtual-dom/vnode/vnode'),
VText = require('virtual-dom/vnode/vtext')
var convertHTML = require('html-to-vdom')({
VNode: VNode,
@jouni-kantola
jouni-kantola / AsimovReporter
Last active August 29, 2015 14:18
mocha reporter for Asimov
function AsimovReporter(runner) {
var passes = 0,
failures = 0;
runner.on('pass', function(test) {
passes++;
console.log('##asimov-deploy[test="%s" pass="true"', test.fullTitle());
});
runner.on('fail', function(test, err) {
@jouni-kantola
jouni-kantola / bundle.js
Created October 11, 2016 22:06
Application bootstrap by Webpack build type
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
// works in both v1 and v2
{
test: /\.less$/,
loader: "style-loader!css-loader!less-loader"
}
// works in v2
{
test: /\.less$/,
use: [
@jouni-kantola
jouni-kantola / 0.js
Created January 11, 2017 02:52
Webpack import sub module bug
// ./dist/0.js
webpackJsonp([0],[
/* 0 */,
/* 1 */
/***/ function(module, exports) {
module.exports = function() {
console.log('in module a');
}
@jouni-kantola
jouni-kantola / preserved.js
Created January 19, 2017 20:34
webpack tree shaking to the test
// index.js
import { foo } from './module-tree-shaking.js';
foo();
// module-tree-shaking.js
export const foo = function foo() {
bar();
};
export const bar = function bar() {