@onify/flow-script-functions
v1.0.0
Published
Onify Script Functions
Downloads
187
Readme
Onify Script Functions
This library provides various functions designed for Onify Flow that can also be used in Node.js applications.
The functions available are as follows:
Onify Flow
Use functions.*
to access the functions present in this library.
const result = functions.slugify('sample onify');
console.log(result); // output: sample-onify
Installation
npm install @onify/flow-script-functions
Usage
Import the library:
Javascript
const functions = require('@onify/flow-script-functions');
Typescript
// import all functions
import * as functions from '@onify/flow-script-functions';
// or
// import specific functions
import { slugify } from '@onify/flow-script-functions';
Use the functions:
// example usage of `slugify` function
let output = functions.slugify('Hello World!');
// or
// when using specific imports in TypeScript
output = slugify('Hello World!');
Generate UUID
Creates a GUID string using crypto
Syntax
generateUuid(): string
Return value
GUID string with the format ${string}-${string}-${string}-${string}-${string}
Example
import { generateUuid } from '@onify/flow-script-functions';
// ...
const id = generateUuid(); // generates random GUID
console.log(id); // sample output: "55d03475-45fe-4415-81d7-8cd052081fe1"
Slugify
Transforms string to kebab case
Syntax
slugify(text: string): string
Parameters
| Name | Type | Description |
| :--- | :------- | ----------------------------- |
| text | string
| the string value to transform |
Return value
kebab-case
of the input
Example
import { slugify } from '@onify/flow-script-functions';
// ...
const transformedText = slugify('Hello World!');
console.log(transformedText); // output: "hello-world"
Validate Email
Checks if string is a valid email format
Syntax
validateEmail(email: string): boolean
Parameters
| Name | Type | Description |
| :---- | :------- | ------------------ |
| email | string
| string to validate |
Return value
true
if input is a valid email format, otherwise false
Example
import { validateEmail } from '@onify/flow-script-functions';
// ...
const isValid = slugify('[email protected]');
console.log(isValid); // output: true
Release new version and publish to npm
- Update
version
inpackage.json
- Update
CHANGELOG.md
- Commit and push the changes
- Run
npm run release