Skip to content

Instantly share code, notes, and snippets.

@Lodo4ka
Lodo4ka / get key nested object
Created March 22, 2020 15:09
get key nested object any depths
const getIn = (data, keys) => {
let current = data;
for (const key of keys) {
if (!has(current, key)) {
return null;
}
current = current[key];
}
return current;
compareObject(objOne, objTwo) {
return Object.keys(objTwo).every(
key => objOne.hasOwnProperty(key) && objOne[key] == objTwo[key]
);
},
@Lodo4ka
Lodo4ka / launch.json
Created December 11, 2019 12:18
debuging mocha in vs code from node js
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha All",
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.formatOnSave": false,
// "css.fileExtensions": [
// "css",
// "scss",
// "less"
// ],
@Lodo4ka
Lodo4ka / best filter for date in client JS
Created September 27, 2019 10:34
filter from course node
capitalize(value) {
return (
value
.toString()
.charAt(0)
.toUpperCase() + value.slice(1)
);
},
date(value) {
return new Intl.DateTimeFormat('ru-RU', {
@Lodo4ka
Lodo4ka / app.js
Created September 27, 2019 10:25
return new Intl.DateTimeFormat('ru-RU', {
year: 'numeric',
month: 'long',
day: '2-digit',
}).format(new Date(value));
@Lodo4ka
Lodo4ka / UserList.vue
Created September 16, 2019 15:36
custom table with my sort any data
if (event.target.classList[0] === "points") {
this.toggleSortTable.points ? this.users.sort((a, b) => b.points_earned - a.points_earned) : this.users.sort((a, b) => a.points_earned - b.points_earned);
this.toggleSortTable.points = !this.toggleSortTable.points;
} else if (event.target.classList[0] === "name") {
if(this.toggleSortTable.name) {
this.users.sort(function (a, b) {
if (a.name < b.name) {
return 1;
}
if (a.name > b.name) {
const fn = (f, list) => {
if(list.length === 0) {
return [];
}
const [x, ...xs] = list
return f(x) ? [x, ...fn(f, xs)]: fn(f,xs)
}
const arrEx = [4, 2, 5, 1, 3];
import { getQueue } from '../test/data';
import ExecutorExt from '../test/ExecutorExt';
import { IExecutor } from './Executor';
import ITask from './Task';
export default async function run(executor: IExecutor, queue: Iterable<ITask>, maxThreads = 0) {
maxThreads = Math.max(0, maxThreads);
/**
* Код надо писать сюда
* Тут что-то вызываем в правильном порядке executor.executeTask для тасков из очереди queue
@Lodo4ka
Lodo4ka / settings.json for linux vs code
Created July 24, 2019 08:26
config vs code for linux development javascript
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.formatOnSave": false,
// "css.fileExtensions": [
// "css",
// "scss",
// "less"
// ],