This file contains hidden or 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 paginate (arr, size) { | |
| return arr.reduce((acc, val, i) => { | |
| let idx = Math.floor(i / size) | |
| let page = acc[idx] || (acc[idx] = []) | |
| page.push(val) | |
| return acc | |
| }, []) | |
| } |
This file contains hidden or 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
| // create winstonLoggerInstance here, e.g. in beforeEach().... | |
| const winstonLoggerMock = jest.spyOn(winstonLoggerInstance, 'log'); | |
| serviceInstance.debug('debug sent from test'); | |
| expect(winstonLoggerMock).toHaveBeenCalled(); |
This file contains hidden or 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
| export class Form { | |
| constructor(data) { | |
| this.originalData = data; | |
| for (let field in data) { | |
| this[field] = data[field]; | |
| } | |
| } | |
| data() { | |
| let data = {}; |
This file contains hidden or 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
| searchControl.search('Казахстан, Алматы, ' + streetInput.value/*'4 Щербакова Алматы'*/ | |
| .then(function (res) { | |
| var geoObjectsArray =searchControl.getResultsArray(); | |
| if (geoObjectsArray.length) { | |
| // Выводит свойство name первого геообъекта из результатов запроса. | |
| return geoObjectsArray | |
| .map((item) => item.properties.getAll().metaDataProperty.GeocoderMetaData.Address.Components) | |
| .filter(item => item.find(el => el.kind === 'street')) | |
| .map(item =>{ return item.find(el => el.kind === 'street').name }) | |
| .map(name => { |
This file contains hidden or 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 eventFire(el, etype){ | |
| if (el.fireEvent) { | |
| el.fireEvent('on' + etype); | |
| } else { | |
| var evObj = document.createEvent('Events'); | |
| evObj.initEvent(etype, true, false); | |
| el.dispatchEvent(evObj); | |
| } | |
| } |
This file contains hidden or 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 sym = Symbol(); | |
| console.log( typeof sym ); | |
| let sym2 = Symbol('name'); | |
| console.log( sym2.toString() ); | |
| let a = {}; | |
| let b = a; | |
| b.d = 2; |
This file contains hidden or 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 watch = function (context, setter) { | |
| return function (varName, setter) { | |
| var value = undefined; | |
| Object.defineProperty(context, varName, { | |
| get: function () { return value; }, | |
| set: function (v) { | |
| value = v; | |
| console.log('Value changed! New value: ' + value); | |
| setter(value); |