let say there is a file file origins.txt
main
secondary
backup
It can be used as shown below
// Enter your code here | |
use std::io; | |
#[derive(Debug)] | |
enum Case { | |
TwoLines(String, String) | |
} | |
fn readStdin() -> Vec<String> { | |
let mut result: Vec<String> = Vec::new(); |
struct Memoize<'a, A, R> { | |
cache: std::collections::HashMap<A, R>, | |
func: &'a dyn Fn(A) -> R | |
} | |
impl<'a, A, R> Memoize<'a, A, R> where | |
A: Eq + std::hash::Hash + Copy + Clone, | |
R: Copy + Clone | |
{ | |
fn from_func(func: &'a dyn Fn(A) -> R) -> Self { |
In console
$ tsc @cli-ts-params.txt ./path-to-file
OR
$ npx tsc @cli-ts-params.txt ./path-to-file
in cli-ts-params.txt
/* | |
The source of the solution | |
https://stackoverflow.com/questions/45251664/typescript-derive-union-type-from-tuple-array-values | |
*/ | |
const listOfLetters = ['a', 'b', 'c'] as const; | |
type Letter = typeof list[number]; // 'a'|'b'|'c'; | |
let itIsOk: Letter = 'a'; | |
let itIsNot: Letter = 'd'; |
// how to run | |
// $ node ./detect-root-foders.js --root ../../../.. --ext jsp --until folderName | |
const glob = require('glob'); | |
const ROOT = 'root'; | |
const EXT = 'ext'; | |
const UNTIL = 'until'; | |
function getSettings (argv) { | |
return argv.reduce((params, arg, i, all) => { |
function measureTime (fn) { | |
var start = performance.now(); | |
fn(); | |
return performance.now() - start; | |
} |
/** | |
* | |
* @param {Function} fn - Function that should be run | |
* @param {Object} thisLink - This link should be set if fucntion should be call in the context of some object | |
* @param {...*} args - Any amount of arguments to be passed to the called function | |
* | |
* @comment args presented in the definition only for readability, there is no any other reason since it redefined right after the call | |
*/ | |
runFunctionIfSafe: function(fn, thisLink, args) { |