Skip to content

Instantly share code, notes, and snippets.

View dmitrymatveev's full-sized avatar

Dmitry Matveev dmitrymatveev

  • Auckland, New Zealand
View GitHub Profile
/**
* Removes new lines and tabs and preceding whitespace in a multi-line
* template strings.
*
* E.g.:
* console.log(lineTag`line: ${1}
* line: ${2}
* line: ${3}`); // line: 1 line: 2 line: 3
*
const DELIMITER = /[\W_](\w)/g
export default str => str.replace(DELIMITER, (m, ch) => ch.toUpperCase());
util functions
const HEAD = 0;
const splitCallback = list => [
list.slice(0, list.length - 1),
list[list.length - 1]
];
function next(args, done, ...functions) {
const fnc = functions[HEAD];
function deepMerge(...objects) {
let dest = objects[0];
let target = objects[1] || {};
for(let targetKey of Object.keys(target)) {
let targetValue = target[targetKey];
if (Array.isArray(targetValue)) {
dest[targetKey] = dest[targetKey] || [];
dest[targetKey].push(...targetValue);
@dmitrymatveev
dmitrymatveev / github-deploy.sh
Last active September 29, 2017 02:52
Scripts to manage projects version updates
#!/bin/bash
# ==================================================================================================
# Makes an archive of a pre-built distributable and
# using github REST apiV3 create a release on the current tag and uploads archive.
# This will assume the tag was created with the same name as current version in package.json
#
# Usage:
# github-deploy <archive file path>
# ==================================================================================================
"use strict";
class Signal {
constructor() {
this._callbacks = new Map();
}
add(fnc) {
this._callbacks.set(fnc, {count:0});
"use strict";
/*
The MIT License (MIT)
Copyright (c) 2016 Dmitry Matveev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace DM.Cli
{
public interface ICliDictionary
{
void Command(string line);
}
/*
Simple function overloading, well, not exactly overloading.
Invokes overloaded function with the matching number of arguments passed to its proxy.
Example:
let fnc = overloaded(
function () {console.log('-')},
function (a) {console.log(a)}
);