View isomorphic-code-splitting-webpack-2-mithril-route-resolver.js
import m from 'mithril'
import store from '../../store'
import {loadUsers} from '../../data/users/actions'
import layout from '../../components/layout'
if (typeof require.ensure !== 'function') require.ensure = (d, c) => c(require)
async function getJs(){
return (await require('./users.js')).default
}
View breadcrumb.js
var m = require('mithril');
var _ = require('lodash');
breadcrumb.view = function (ctrl,array) {
return m('.breadcrumb', [
_.map(array, function (b, i) {
return m('.breadcrumb', [
m('i.material-icons', 'chevron_right'),
m('a.breadcrumb-link', {
href: b.url,
View selectOption.js
var m = require( 'mithril' )
var isSelected = require( '../functions/isSelected' )
function action(option, selection, e){
if (isSelected(ctrl.option, ctrl.selection)) {
var i = ctrl.selection.indexOf(ctrl.option)
ctrl.selection.splice(i, 1)
} else {
View app.js
// No dependencies! + 1 point
// Only one API to reference! + 1 point
const Widget = {
// Expose desired data directly using destructuring! + 1 point
controller({initialValue}) {
// No more retrieving references buried by the superclass! + 1 point
this.counter = initialValue;
// Two less methods! + 2 points
},
View app.js
var m = require('mithril');
var layout = require('./components/layout/layout.js');
m.route.mode = 'pathname';
var Account = require('./models/account.model');
authRoutes(document.getElementById('app'), '/', layout.wrap({
'/': require('./pages/dashboard.js'),
View application.controller.js
import Ember from 'ember';
export default Ember.Controller.extend({
numbers:['1','2','3','4'],
letters:['a','b','c','d']
});
View mithriljsonextract.js
// MODEL
'use strict';
var m = require('mithril');
module.exports = function get_himage(){
return m.request({
method: 'GET',
url: '/config.json'
})
.then(function (data) {
View m.validator.js
m.validator = function (model, validations) {
this.errors = {}
this.validations = validations
this.model = model
}
m.validator.prototype.hasErrors = function () {
return Object.keys(this.errors).length
}
View modulator.js
var mod = ( function initModulator(){
if( !Map ){
// A naive shim for maps functionality
var Map = shim;
var WeakMap = shim;
}
// Garbage collection flag
mod.cleanup = true;