dotfiles/.config/nodejsscript/nodejsscriptrc.mjs
Jan Andrle ff3138230d
Migrate other dotfiles and log …
not included in the original repo
2024-02-20 16:00:47 +01:00

19 lines
630 B
JavaScript

/* --print/--echo aliases */
Reflect.defineProperty($, "nosed", { get(){ return this.stdin.text(""); }, });
Reflect.defineProperty($, "nojq", { get(){ return this.stdin.json(null); }, });
Reflect.defineProperty($, "noawk", { get(){ return this.stdin.lines([]); }, });
/* deprecated/fallback */
globalThis.cyclicLoop= function*(items){
if(!items) items= 'win32'===process.platform ? '|/-\\' : "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏";
const { length }= items;
for(let i=0; true; i++){
if(i===length) i= 0;
yield items[i];
}
}
Reflect.defineProperty($, "clipboard", {
get(){ return s.$().run`xclip -o -selection clipboard`; }
})