Skip to content

Instantly share code, notes, and snippets.

@Lodo4ka
Lodo4ka / get key nested object
Created Mar 22, 2020
get key nested object any depths
View get key nested object
const getIn = (data, keys) => {
let current = data;
for (const key of keys) {
if (!has(current, key)) {
return null;
}
current = current[key];
}
return current;
View compare two object
compareObject(objOne, objTwo) {
return Object.keys(objTwo).every(
key => objOne.hasOwnProperty(key) && objOne[key] == objTwo[key]
);
},
@Lodo4ka
Lodo4ka / launch.json
Created Dec 11, 2019
debuging mocha in vs code from node js
View launch.json
{
// 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",
View vs code settings for ubuntu
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.formatOnSave": false,
// "css.fileExtensions": [
// "css",
// "scss",
// "less"
// ],
View best filter for date in client JS
capitalize(value) {
return (
value
.toString()
.charAt(0)
.toUpperCase() + value.slice(1)
);
},
date(value) {
return new Intl.DateTimeFormat('ru-RU', {
View app.js
return new Intl.DateTimeFormat('ru-RU', {
year: 'numeric',
month: 'long',
day: '2-digit',
}).format(new Date(value));
@Lodo4ka
Lodo4ka / UserList.vue
Created Sep 16, 2019
custom table with my sort any data
View UserList.vue
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) {
View custom filter function
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];
View task async process for test
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 Jul 24, 2019
config vs code for linux development javascript
View settings.json for linux vs code
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.formatOnSave": false,
// "css.fileExtensions": [
// "css",
// "scss",
// "less"
// ],