Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

noliter

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

noliter

Write code with no literal

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-71.43%
Maintainers
1
Weekly downloads
 
Created
Source

Noliter

Write code with no literal

Install

npm i -D noliter

API

createTagName

Create html element with builder.

Type

declare type HTMLElementTagNames = keyof HTMLElementTagNameMap;
declare type Builder<H extends HTMLElementTagNames> = (element: HTMLElementTagNameMap[H]) => void;

declare function createAnchor(builder?: Builder<"a">): HTMLAnchorElement;
declare function createInput(builder?: Builder<"input">): HTMLElement;
declare function createSpan(builder?: Builder<"span">): HTMLElement;
...

Example

createAnchor((anchor) => {
  anchor.href = 'https://www.google.com/';
  anchor.appendChild(createSpan((span) => {
    span.textContent = 'Google';
  }));
});

createInput((input) => {
  input.value = 'This is example!';
});

joinClassNames

Joins multiple classNames into a single string.

Type

declare function joinClassNames(...classNames: (undefined | null | boolean | number | string)[]): string;

Example

element.className = joinClassNames('header', isOpen && 'open');

removeChildren

Remove all of children from element.

Type

declare function removeChildren<N extends Node>(parent: N): void;

Example

removeChildren(element);

isEmail

Returns true if parameter is form of email, otherwise returns false.

Type

declare function isEmail(str: string): any;

Example

isEmail("simple@example.com") === true;
isEmail("A@b@c@example.com") === false;

matchNumber

Filter only numbers from string.

Type

declare function matchNumber(str: string): RegExpMatchArray;

Example

matchNumber("1a39b02c8") === ["1", "39", "2", "8"];

removeWhitespace

Remove all of whitespace from string.

Type

declare function removeWhitespace(str: string): string;

Example

removeWhitespace(" t es  t  ") === "test";

removeXmlTag

Remove all of xml tag from string.

Type

declare function removeXmlTag(str: string): string;

Example

removeXmlTag("<p>test</p>") === "test";

removeCharacterReference

Remove all of character reference from string.

Type

declare function removeCharacterReference(str: string): string;

Example

removeCharacterReference("&nsbp;tes&nsbp;t") === "test";

FAQs

Package last updated on 29 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc