SkillAgentSearch skills...

Carpenter

Method chaining pattern for all things Deno

Install / Use

/learn @duart38/Carpenter

README

<h1 align="center">Carpenter 🛠</h1> <p align="center"> <img src="https://img.shields.io/github/workflow/status/duart38/Carpenter/Test%20module?label=Tests&style=for-the-badge" /> <img src="https://img.shields.io/github/license/duart38/Carpenter?color=yellow&style=for-the-badge" /> <img src="https://img.shields.io/github/v/release/duart38/Carpenter?style=for-the-badge" /> </p> <a align="center" href="https://doc.deno.land/https/deno.land/x/carpenter/mod.ts">

Documentation

</a>

Road 🗺

  • [x] Add ARGS (deno.args) carpenter
  • [x] Add OS (deno.build) carpenter
  • [x] Add STRING carpenter
  • [x] Add ARRAY carpenter
  • [x] Add SWITCH carpenter
  • [x] Add OBJECT carpenter
  • [x] Add VALUE carpenter (unknown values)
  • [ ] Add more options to STRING carpenter
  • [ ] Add more interconnections between various carpenters

By example

OS specific code

import { OS } from "./mod.ts";

// basic
OS.on("darwin").do(() => console.log("Hey Darwin"));
OS.on("darwin").do(() => console.log("Hey Darwin")).else(() =>
  console.log("something else")
);
// multiple clauses
let str = "";
OS.on("windows")
  .do(() => str += "Hello ")
  .do(() => str += "world");

Command line argument specific code

import {ARGS} from "./mod.ts";

// basic usage
ARGS.on("-h")
    .do(() => some help code here)
    .else(() => -h was not found);

// multiple flags (evaluates when all flags are set)
ARGS.on("-x", "-a")
    .do(()=> console.log("flag -x and -a was found together"))

Other carpenters

For more carpenters see documentation.

import { STRING } from "./mod.ts";

STRING("hello")
  .contains("hello").and().contains("x") // false
  .or().isOfSize(5) // true
  .do(() => console.log("OH WOW!!!!")) // true because of OR operator
;

STRING("hello")
  .adapt((prev: string) => prev += " world") // adapts the string.. you may continue with chaining after this
  .getValue(); // gets the current object value.
import { SWITCH } from "./mod.ts";

SWITCH(someValue)
  .case("one").do(() => {})
  .case("chain")
  .do(() => {})
  .do(() => {})
  .default(() => {});
View on GitHub
GitHub Stars9
CategoryDevelopment
Updated2y ago
Forks0

Languages

TypeScript

Security Score

75/100

Audited on Jul 9, 2023

No findings