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 N = 10000; | |
let prev1, prev2, prev3, prev4; | |
let counter1 = 0, counter2 = 0, counter3 = 0, counter4 = 0; | |
function test(obj) { | |
if (!prev1) { | |
prev1 = obj; | |
} | |
if (!%HaveSameMap(prev1, obj)) { |
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 qsort = (arr) => { | |
if (arr.length < 2) { | |
return arr; | |
} else { | |
// Опорная точка для деления массива, выбирается случайно | |
const pivotPosition = Math.floor(Math.random() * arr.length); | |
const pivot = arr[pivotPosition]; | |
// Значения меньшие, либо равные опорному | |
// попадают в новый массив less | |
const less = arr.filter((value, index) => { |
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
connect({ | |
items: state`items`, | |
itemAdded: signal`itemAdded` | |
}, | |
function Items ({items, itemAdded}) { | |
return ( | |
<div> | |
<ul> | |
{items.map((item) => <li>{item}</li>)} | |
</ul> |
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 ADD_ITEM = 'ADD_ITEM' | |
function addItem (item) { | |
return {type: ADD_ITEM, payload: item} | |
} | |
function Items ({items, onClick}) { | |
return ( | |
<div> | |
<ul> | |
{items.map((item) => <li>{item}</li>)} | |
</ul> |
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
@observer | |
class Items extends Component { | |
render() { | |
return ( | |
<div> | |
<ul> | |
{this.props.store.items.map((item) => <li>{item}</li>)} | |
</ul> | |
<button onClick={() => this.props.store.addItem('foo')}> | |
Add foo |
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 controller = Controller({ | |
state: { | |
items: [] | |
}, | |
signals: { | |
itemAdded: push(state`items`, props`item`) | |
} | |
}) | |
// Компоненты | |
const Items = connect({ |
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 ReduxState (state = Immutable.fromJS({items: []}), action) { | |
switch (actions.type) { | |
case 'addItem': | |
return state.push('items', action.item) | |
} | |
return state | |
} | |
// Компоненты | |
const Items = connect( |
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
// Определяем состояние и методы для его обновления | |
class MobxState { | |
@observable items = [] | |
addItem (item) { | |
this.items.push(item) | |
} | |
} | |
// Компоненты | |
@observer | |
class Items extends Component { |
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 cacheName = 'v1'; | |
this.addEventListener('install', function(event) { | |
event.waitUntil( | |
caches.open(cacheName).then(function(cache) { | |
return cache.addAll([ | |
'index.html', | |
'common.css' | |
].map(u => new Request(u, { credentials: 'include' }))) | |
}).then(()=> console.log('done')) | |
); |
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 server = http2.createSecureServer(options); | |
const commonCSS = fs.readFileSync('common.css'); | |
server.on('stream', (stream, headers) => { | |
console.log(`${headers[':method']} ${headers[':path']}`); | |
const parsedUrl = url.parse(headers[':path']); | |
let pathname = `.${parsedUrl.pathname}`; | |
const ext = path.parse(pathname).ext; | |
if (headers[':path'] === '/index.html') { | |
stream.pushStream({ ':path': 'common.css' }, |
NewerOlder