Coder Social home page Coder Social logo

owl-str's Introduction

owl-str

Make a string with owl-str!

Installation

You can download via npm, yarn

npm i owl-str

or

yarn add owl-str

Usage

You can make (sql or whatever) string more easier with tagged template literals!

import { str } from "owl-str";
// or you can use like this
// import owlStr from 'owl-str';
// owlStr.str`blahblahblah`;

const payload = {
  arg: true,
};

const string = str<typeof payload>`Hello? Is anyone there?\n${({ arg }) =>
  arg ? "Yes" : "Nope"}`;

string(payload);
// Hello? Is anyone there?
// Yes
import { str, isTrue, isNotEmpty } from "owl-str";

const payload = {
  some_function: () => (Math.floor(Math.random() * 101) >= 50 ? true : false),
};

const sql = str<typeof payload>`
    SELECT
        *
    FROM [SOME_TABLE]
    WHERE 1=1
    ${(props) => isTrue(props["some_function"]())`
        AND [SOME_COLUMN] = :SOME_COLUMN
    `}
    ${isNotEmpty(some_variable)`
        AND [SOME_COLUMN] = :SOME_COLUMN
    `}
`;

sql(payload);
// isNotEmpty method will be ignore that string if some_variables is empty(null or undefined).
// props in string will provide as the payload

Documents

raw

This is string template made by owl-str, you don't need to use this.

This is only for this package.

str

This is the base function of tagged template literals for our package.

const str = <T>(payload: T)

str can have a payload

This payload will provide to child function in string as the arguments.

emptyStr

This is the void. This function always return empty string('')

isNotEmpty, isEmpty

This methods are make a string with arguments. If you provide (empty or not empty) string, It will ignore the string what you provide, or not

isTrue, isFalse

This is just check the argument and return the string or not

Let me know if I wrote something wrong. ([email protected] or [email protected] or github issue)

owl-str's People

Contributors

pure-juan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.