30-seconds-of-typescript
This repository is a collection of numerous utility functions that can be easily imported and used anywhere, similar to Lodash.
All the documents can be found on 30-seconds-of-typescript
Note: This repository is heavily inspired by 30-seconds-of-code. All JavaScript code has been converted to TypeScript so that it can be used for Modern HTML|JS, TypeScript and DenoGithub.
I am refactoring code and fixing bugs along with conversion.
Install node.js/npm
npm i @deepakvishwakarma/ts-util
How to use [Typescript]
import { mask } from "@deepakvishwakarma/ts-util";
console.log(mask(1234567890)); // '******7890'
console.log(mask(1234567890, 3)); // '*******890'
console.log(mask(1234567890, -4, "$")); // '$$$$567890'
How to use [JS]
const { mask } = require("@deepakvishwakarma/ts-util");
console.log(mask(1234567890)); // '******7890'
console.log(mask(1234567890, 3)); // '*******890'
console.log(mask(1234567890, -4, "$")); // '$$$$567890'
Install Snippet Extension
You can find the working plugin on marketplace.visualstudio.com
. You can either search for 30-seconds-of-typescript
Or Install from here imdeepak.30-seconds-of-typescript
Search for snippet- Sample[typescript & typescriptreact]
30_delay
This repo has a utility file, that can be imported to Deno and modern EcmaScript.
How to use [Deno]
import { all } from "https://denopkg.com/deepakshrma/30-seconds-of-typescript/util.ts";
all([{ name: "D" }, { name: "D2" }], hasName); //true
How to use using Github CDN [Modern HTML|JS]
<script type="module">
// Use any Github CDN
import * as util from "https://cdn.jsdelivr.net/gh/deepakshrma/30-seconds-of-typescript/util.js";
const el = util.createElement(
`<div class="container"><p>Hello! This is created using createElement!! </p></div>`
);
document.body.appendChild(el);
</script>
Contribution
Create New utility function
export here
util.ts
How to bundle: It will be auto using husky githook
How to test using Deno
deno test util.test.ts
Commands | Scripts
1. Generate Snippets:
npm run code-gen
2. Generate Extension:
npm run extension
3. Install Extension Locally:
code --install-extension *.vsix