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
/** | |
* Как сейчас. Это пример, где упрощённый синтаксис всё сильно упростит. | |
* Но есть и много других примеров, где, кажется, декларация модификаторов на события будет полезна | |
*/ | |
BEM.DOM.decl('b-page', { | |
bindEvents: function() { | |
this.__base.apply(this, arguments); | |
BEM.blocks['pane2-api'] |
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'; | |
let iterable = [3, 5, 7]; | |
iterable.foo = "hello"; | |
console.log('# iterable', iterable) | |
console.log('## access prop in array') | |
console.log(iterable.foo) // hello | |
console.log('## for in arr') |
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
// TOC | |
// Intro | |
// # New BEM based blocks concept — BEMS | |
// # New 3-step templating concept | |
// Example | |
/** | |
# New BEM based blocks concept — BEMS | |
## Нейминг: Не мода, а поле |
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'; | |
import {Priv as Bempriv, Html as Bemhtml, XJT as xjt} from 'bem-server' | |
// menu.priv.js - es6priv | |
Bempriv.decl('menu', class menu extends Bempriv { | |
constructor() { | |
this.prop('items', this.getItems()); | |
} | |
getItems() { | |
// Выдуманная, но близкая к реальности логика маппинга данных |
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
block('viewer-controls')( | |
def()(function() { | |
return applyNext({ | |
params: this.ctx.params | |
}); | |
}), | |
content()(function() { | |
return [ |
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
function fuzzysearch (sub, str) { | |
var l1 = sub.length, l2 = str.length; | |
var i = 0, j = 0; | |
if (l1 > l2) return false; | |
for (; i < l1; ++i, ++j) { | |
if (sub[i] == str[j]) continue; | |
do { | |
++j; | |
if (j >= l2) return false; |
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'; | |
let table, tr, td, div, _el, cl; | |
document.body.innerHTML = 'loading...'; | |
$.get('http://yitv.herokuapp.com') | |
.then((data) => { | |
let rows = data.body.reduce((prev, item)=>{ | |
let title = div(item.title, 'title'); | |
let vals = div(item.add_values.join(', ')); | |
let row = td(item.value, 'value') + td(title + vals, null, { title: item.detail }); |
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
function sumTree (tree) { | |
var sum = tree.value; | |
var root = tree; | |
var stack = [root.next]; | |
while(stack.length) { | |
sum = stack.pop().reduce((sum, root) => { | |
stack.push(root.next); | |
return sum + root.value; | |
}, sum); |
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 summary = hubs => _(hubs) | |
.groupBy('browserName') | |
.mapValues((data, bro) => | |
_(data).mapTuple(['active', 'total']).sumTuple().value() | |
) | |
.value(); | |
var hubs = [{ | |
host: 'hub01', | |
browserName: 'firefox', |
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 cloneObj = obj => { | |
var newObj = {}; | |
Object.keys(obj).forEach((key) => { | |
newObj[key] = obj[key]; | |
}); | |
return newObj; | |
}; | |
var appendTrace = (trace, key, val) => { | |
var newTrace = cloneObj(trace); |