Giter VIP home page Giter VIP logo

newdash's Introduction

NewDash

Github CI Deno CI

Codecov Quality Gate Status Security Rating Netlify

npm (scoped) npm (scoped) npm (scoped) npm (scoped) npm (scoped)

NewDash is a hard fork of the lodash utility project, and re-build it with typescript.

Quick Start

NodeJS

works as you want.

// const { first } = require("@newdash/newdash")
const { first } = require("@newdash/newdash/first") // Compatible with es6 module
first("abc")
// => "a"

ES6 or Typescript

// import { first } from "@newdash/newdash" // load all functions of @newdash
import first from "@newdash/newdash/first" // only load `first` function
first("abc")
// => "a"

Deno Runtime

import from CDN, remember to add .ts suffix.

// import { add } from "https://cdn.jsdelivr.net/npm/@newdash/newdash-deno/index.ts"
import { add } from "https://cdn.jsdelivr.net/npm/@newdash/newdash-deno/add.ts"

add(1, 2)
// => 3
add('1', '2')
// => '12'
add('1', 2) // different types
// throw error: TS2345 [ERROR]: Argument of type '2' is not assignable to parameter of type '"1"'.

UMD Module (Browser Native)

just introduce script with html.

<script src="https://cdn.jsdelivr.net/npm/@newdash/newdash-umd/newdash.min.js"></script>

Highlight

  • concurrency/limit - limit concurrency of async operations
  • Mutex - exclusive executing
  • hash - hash js object to stable string (MD5 based)
  • fallback - fallback functions for resilience
  • LRUMap and TTLMap - Map implementations which concern about eviction

Different Release

In most cases, just use the @newdash/newdash package is enough.

  • @newdash/newdash - for modern nodejs environment, ready for all build tools which based on the nodejs commonjs module system (node, react, vuejs, webpack and more).
  • @newdash/newdash-deno - for deno language support, with some transform, like add the '.ts' suffix for modules.
  • @newdash/newdash-es5 - for old nodejs environment, ready for 0.12 <= node version <= 8.
  • @newdash/newdash-es6 - for modern build system, with es6 module keywords so that build tool could strip the unused modules.
  • @newdash/newdash-umd - for native browser without any build system, please access it with unpkg or jsdeliver

newdash's People

Contributors

adamcraven avatar blikblum avatar bnjmnt4n avatar braddunbar avatar danallison avatar danheberden avatar dependabot-preview[bot] avatar dependabot[bot] avatar falsyvalues avatar filipzawada avatar greenkeeperio-bot avatar iamnoah avatar jashkenas avatar jasondavies avatar jdalton avatar jfmengels avatar jridgewell avatar mathiasbynens avatar megawac avatar michaelficarra avatar octatone avatar octref avatar phated avatar pimterry avatar ratbeard avatar renovate[bot] avatar rheh avatar ryantenney avatar samuelclay avatar soontao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

newdash's Issues

feat: general iteratee types

/**
 * @ignore
 */
interface Iteratee<T, R, K> {
  (value?: T, key?: K): R
}

/**
 * @ignore
 */
type ArrayIteratee<T = any, R = any> = Iteratee<T, R, number>

/**
 * @ignore
 */
type ObjectIteratee<T = any, R = any> = Iteratee<T, R, string>

feat: cache wrapper for object

class A {
  getV() {
    return 1;
  }
}

const a = cacheIt(new A)
a.getV() // execute & cache it
a.getV() // return cache
a.getV(1) // execute & cache it
a.getV(1) // return cache
  • wrapper
  • TTLCacheProvider
  • LRUCacheProvider

feat: with any

const cMatch = with(isMatch, (v1, v2) => v1 > v2)
cMatch(2, 1) // true

feat: cache valid policy

try to get valid policy for cache

all default false

  • accept undefined
  • accept null
  • accept error (cache error throw)

[BUG] Able to pass anything as predicate

I think this line should be removed from all array util functions. It makes them type-unsafe

export function find<T>(collection: ArrayLike<T>, predicate?, fromIndex?: number): T | undefined;

As an example where this fails to provide type safety:

find([] as {id: string}[], {id_: 2}) // no error, but there should be one

feat: concurrent function

provide a concurrent namespace, limit the max concurrent

like this ?

async function getInfo(id) { }
const cLimitGetInfo = concurrent.limit(getInfo, 10)

await Promise.all(ids.map(cLimitGetInfo)) // only 10 requests will be sent in same time for this function
  • implmetation

  • test

  • fallback

  • retry

  • circuit

feat: try with multi providers

const getValues = try(f1, f2 ,f3)

getValue() // try f1, f2 ,f3 one by one, return value which not throw error
  • MultiError
  • fallback function
  • process async function

feat: setup CI

  • sonar
  • lgtm
  • github
  • circle ci
  • git hook with commit lint, eslint
  • multi-platform test (browser/electron ...)
  • old node version test

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/codeql.yml
  • actions/checkout v3
  • github/codeql-action v3
  • github/codeql-action v3
  • github/codeql-action v3
.github/workflows/deno.yml
  • actions/checkout v3
  • actions/setup-node v4
  • actions/cache v3
  • denoland/setup-deno v1
.github/workflows/nodejs-lint.yml
  • actions/checkout v3
  • actions/setup-node v4
  • actions/cache v3
.github/workflows/nodejs-release.yml
  • actions/checkout v3
  • actions/setup-node v4
.github/workflows/nodejs.yml
  • actions/checkout v3
  • actions/setup-node v4
  • actions/cache v3
  • codecov/codecov-action v3.1.4
  • actions/checkout v3
  • actions/setup-node v4
  • actions/cache v3
npm
package.json
  • @babel/cli 7.22.9
  • @babel/core 7.22.9
  • @babel/plugin-syntax-typescript 7.22.5
  • @types/jest 29.5.11
  • @types/node 20.9.2
  • @typescript-eslint/eslint-plugin 6.16.0
  • @typescript-eslint/parser 6.16.0
  • colors 1.4.0
  • eslint 8.56.0
  • jest 29.7.0
  • jest-environment-jsdom 29.7.0
  • ts-jest 29.1.1
  • typescript 5.3.3
  • node >=10.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

feat: math

math basic support

  • variance
  • standard deviation
  • regression
  • matrix & knn

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.