Giter Site home page Giter Site logo

jrtilak / lazykit Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 2.0 945 KB

Refine your JavaScript workflows with Lazykit. A concentrated collection of lean utility functions, not a bloated library.

Home Page: https://lazykit.thapatilak.com.np

License: MIT License

Shell 0.04% JavaScript 1.45% CSS 1.24% TypeScript 97.27%
javascript jrtilak typescript utilities lazykit

lazykit's People

Contributors

dev-sandip avatar ebe25 avatar jrtilak avatar mxthxngx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ebe25 dev-sandip

lazykit's Issues

[FEAT]: directory suggestion

Currently pressing tab doesnot suggest the current path while giving input in inquirer
Make it to suggest the current path for better user convinence

FEAT: Run Example Snippets Live

image

  • Make these given examples executable like a run button that runs the example and prints a logs below
  • Also user should be able to edit the example code snippets for better convenience, if possible.
  • You can create a popup window for showing logs and editing code
  • Use some library for easy code editing experience

Idea

  • The idea is to create a api where we can pass the example snippet with it's parent function that it is importing
  • Execute the code in backend with package like isolated-vm for security reasons
  • Limit the runtime to 4-5 or some ideal seconds to prevent user form inserting malicious/infinite loop code.
  • Can also limit the usage of memory
  • Consider the security deeply in this context as running some malicious code can bring securing threat.

If you know some better approach with or without implementation of api you can suggest/contribute.

IDEAS

Here are some ideas if you are searching for.

For Arrays

  • sampleArr: generate a random array of specified length
  • shuffleArr: shuffle an array
  • insert: insert an element after a specified index
    • (if the index is negative, it will insert from the end)
    • (recursive => it will insert the element on every index like)
    //insert arr = [1,2,3,4,5], element = 0, index = 2	
    //output => [1,2,0,3,4,0,5]	
    //insert arr = [1,2,3,4,5, 6], element = 0, index = 2	
    //output => [1,2,0,3,4,0,5,6,0]	
    //when index is negative, it will start inserting from the end	
  • remove: remove an element at a specified index (if the index is negative, it will remove from the end) index can be array of indexes
  • unique: remove duplicates from an array
  • rotate: rotate an array by a specified number of steps ie ([1,2,3,4,5], 2) => [3,4,5,1,2]
  • partition: partition an array into two arrays based on a condition
  • #50

image

  • interDiff: combination of intersection and difference

For Objects

  • sampleObj: generate a random object with specified keys and values
  • #56
  • omit: omit specified keys from an object
  • pick: pick specified keys from an object and return a new object
  • rename: rename a key in an object
  • sortKeys: sort the keys of an object

Functional

  • #62
  • #61
  • #60
  • #59
  • #58
  • once: return a function that can only be called once
  • after: return a function that can only be called after being called n times
  • before: return a function that can only be called before being called n times
  • times: call a function n times and return array of results
  • #63
  • sleep: sleep for a specified amount of time
  • retry: retry a function n times
  • timeout: timeout a function after a specified amount of time ie timeout(f, 1000)(args) which will call f(args) and if it takes more than 1 second, it will return a timeout error

Date..

`remove` method

Category : array
Method: remove
Desc: remove an element at a specified index (if the index is negative, it will remove from the end)

The function will take a index or an array of indexes, it will remove the element of the given indexes and if the index is negative it will remove from last

difference: find the difference between two arrays

The difference function to return an array with three elements:

An array of elements that are unique to the first array.
An array of elements that are unique to the second array.
An array of elements that are common to both arrays.

Here's a rough sketch of what the new function might look like:

/**
 * Finds the unique and common elements between two arrays.
 *
 * @template T - The type of elements in the arrays.
 * @param {T[]} arr1 - The first array.
 * @param {T[]} arr2 - The second array.
 * @returns {[T[], T[], T[]]} - An array containing three arrays: 
 *                              the first with elements unique to arr1, 
 *                              the second with elements unique to arr2, 
 *                              and the third with elements common to both.
 */
const difference = <T>(arr1: T[], arr2: T[]): [T[], T[], T[]] => {
  const uniqueToArr1 = arr1.filter(el => !arr2.includes(el));
  const uniqueToArr2 = arr2.filter(el => !arr1.includes(el));
  const commonToBoth = arr1.filter(el => arr2.includes(el));
  return [uniqueToArr1, uniqueToArr2, commonToBoth];
};

This is just simple implementation.

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.