Code Monkey home page Code Monkey logo

moderndash's Introduction


moderndash's People

Contributors

github-actions[bot] avatar lautarodapin avatar maggi64 avatar renovate[bot] avatar tamatamvan avatar tkrotoff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

moderndash's Issues

set & flatKeys | better return type | stricter input type

With tools like hotscript or advanced TS magic we might be able to improve the return type and validate the given path on compile time.

It should be:

const obj = { a: 1 };
const newObj = set(obj, 'a.c', 1);
//      ^?  { a: { c: number } }

Instead of the current state:

const obj = { a: 1 };
const newObj = set(obj, 'a.c', 1);
//      ^?  PlainObject

Shouldn't `hotscript` be in the main dependencies since it's imported in `dist/index.d.ts`?

Hello!

I'm probably missing something, but I'm getting an error during my TS build because dist/index.d.ts from moderndash imports from hotscript, but it's not installed as a dependency — it's listed in devDependencies instead, so it's not in my project at all as a result, although I've run npm install moderndash previously.

The line at the very top of dist/index.d.ts

import { Call, Tuples, Objects } from 'hotscript';

Should hotscript be moved to the main dependencies instead?

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: renovate.json
Error type: Invalid JSON (parsing failed)
Message: Syntax error near ,{

`Watch` Function

watch: Observes changes to an object or array and triggers a callback when a change occurs.

Error: Unexpected token '??='

Tried to replace lodash with moderndash in a small project using Angular Schematics tooling (node) though im having this error, probably due to some module config

Unexpected token '??=' 
  ​​​​​at ​​​​​​​​wrapSafe​​​ ​internal/modules/cjs/loader.js:1001​
  ​​​​​at ​​​​​​​​Module._compile​​​ ​internal/modules/cjs/loader.js:1049​
  ​​​​​at ​​​​​​​​Object.Module._extensions..js​​​ ​internal/modules/cjs/loader.js:1114​
  ​​​​​at ​​​​​​​​Module.load​​​ ​internal/modules/cjs/loader.js:950​
  ​​​​​at ​​​​​​​​Function.Module._load​​​ ​internal/modules/cjs/loader.js:790​
  ​​​​​at ​​​​​​​​require​​​ ​internal/modules/cjs/helpers.js:101​
  ​​​​​at ​​​​​​​​Object.<anonymous>​​​ ​src/core/template.utils.ts:2​
  ​​​​​at ​​​​​​​​Module._compile​​​ ​internal/modules/cjs/loader.js:1085​

using

typescript: 4.9.4

// tsconfig
{
  "compilerOptions": {
    "baseUrl": "tsconfig",
    "lib": ["es2018", "dom"],
    "declaration": true,
    "module": "commonjs",
    "target": "es6",
    "moduleResolution": "node",
    "noEmitOnError": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": true,
    "noImplicitThis": true,
    "noUnusedParameters": true,
    "noUnusedLocals": true,
    "rootDir": "src/",
    "skipDefaultLibCheck": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strictNullChecks": true,
    "types": ["jasmine", "node"]
  },
  "include": ["src/**/*"],
  "exclude": ["src/*/files/**/*"]
}

Probably due to commonjs? Tried to change module: es2020 target: ES2022 but still no luck

Return the result of the last `throttle` invocation

Hi, lodash has this property with its throttle function that I think is more useful to be the default.

The func is invoked with the last arguments provided to the throttled function. Subsequent calls to the throttled function return the result of the last func invocation.

What do you say?

Feature request - `mergeWith`

Hello

I would like to know, if you planning to create a mergeWith function allowing to customize the merge function. The perfect use exemple is to merge nested array :

mergeWith(
 { a: [1, 2] }, 
 { a: [3, 4] }, 
 (a, b) => Array.isArray(a) && Array.isArray(b) => [...a, ...b] : undefined
) 
// => { a: [1, 2, 3, 4] } 

lodash doc: https://lodash.com/docs/4.17.15#mergeWith

Non-constructing `object.set`

In Typescript, in may be preferred to set properties that are already defined in interface rather then adding new properties

So it a variant of set that can't create properties not defined in the interface in may come useful

The sefSafe function may either return the input type, or return the input type with removed oprionals ? on created path.

See https://stackoverflow.com/questions/76255065/typescript-type-safe-version-of-lodashs-set/76280420#1

example usage:

type Pos = { x: number, y: number };
const pos0 = {} as DeepPartial<Pos>;
const pos1 = setSafe(pos0, 'x', 1); // { x: number, y?: number }
const pos2 = setSafe(pos1, 'y', 2); // { x: number, y: number }
const pos3: Pos = pos2;

T39 Decorators

Blocked by evanw/esbuild#104.
Esbuild seems not to support the T39 Standard Decorators yet. Until this is added we stay with the experimentalDecorators implementation.

The T39 Decorators allow the use in TS5 without the experimentalDecorators flag set.

Can't find `TextEncoder` in tests after 2.2.2 release

Can't find TextEncoder in Jest tests after 2.2.2 release:

Test suite failed to run

    ReferenceError: TextEncoder is not defined

    > 1 | import { merge } from 'moderndash';

What is strange it want to get it from src folder:

at Object.<anonymous> (../../node_modules/moderndash/src/crypto/hash.ts:5:21)

I can see only src comment in the dist source code:

// src/crypto/hash.ts
var textEncoder = new TextEncoder();

Bundle hotscript types

Tsup's --dts-resolve feature, which bundles dependency types, is experimental and doesn't reliably work with hotscript. We need to wait for improvements in tsup/esbuild to fully support this.

Until then hotscript needs to be a dependency.

Related: #117

splitWordsRegex fails on iOS 16

Safari iOS below 16.3 doesn't support certain group specifiers in the below RegEx, probably lookbehind: https://caniuse.com/?search=lookbehind.

const splitWordsRegex = new RegExp(
    '[^\\dA-Za-z]' +  // match any character that is not a letter or a digit
    '|' +                    // or
    '(?<=[a-z])' +           // lookbehind for a lowercase letter
    '(?=[A-Z])' +            // lookahead for an uppercase letter
    '|' +                    // or
    '(?<=[A-Z])' +           // lookbehind for an uppercase letter
    '(?=[A-Z][a-z])'         // lookahead for an uppercase letter followed by a lowercase letter
);

I haven't fully tested it, but what about replacing this splitWords function with something like:

const splitWordsRegex = /([\dA-Z][\da-z]+)|([\dA-Z]+)|([\da-z]+)/g;

export function splitWords(str: string): string[] {
  return [...str.matchAll(splitWordsRegex)].map(match => match[0]);
}

Other issues I've encountered with switching from Lodash to moderndash on a medium-size project:

  • range(0, 3) is inclusive instead of exclusive (e.g. returning [0, 1, 2, 3] instead of [0, 1, 2]). This is different from Lodash, and resulted in some bugs.
  • merge({}, b) doesn't modify the first input. While it's typically best practice to not modify inputs, I believe it makes sense here because otherwise a shallow copy (e.g. {...{}, ...b}) could be used in most cases. I've personally used Lodash's merge in areas of my code specifically because it modifies the input, cutting down on garbage collection.

Switch to mutations instead of copy

Every function except `set' creates and returns a new array. I've done this to be consistent, but it doesn't always make sense.
To improve performance, we could switch to in-place mutations where it makes sense. These would be break changes.

Possible candidates:

  • shuffle
  • sort
  • merge

Suggestion by acorn1010 #80

I am not sure yet. I would love to get some input on this.

Add possibility to wait until the queue finishes

version 3.5.0

It is not possible to wait for the queue to complete all tasks unless I use the await method when queueing the task. It would be a significant improvement to wait until all the promises I've queued before finish.

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/image-compression.yml
  • actions/checkout v4
  • peter-evans/create-pull-request v6
.github/workflows/image-svg-minifier.yml
  • actions/checkout v4
  • ericcornelissen/svgo-action v3
.github/workflows/linter.yml
  • actions/checkout v4
  • actions/setup-node v4
  • stefanzweifel/git-auto-commit-action v5
.github/workflows/no-old-imagetypes.yml
  • batista/lint-filenames v2
.github/workflows/npm-release.yml
  • actions/checkout v4
  • actions/setup-node v4
  • changesets/action v1
.github/workflows/test.yml
  • actions/checkout v4
  • actions/setup-node v4
npm
benchmark/package.json
package.json
  • @svitejs/changesets-changelog-github-compact 1.1.0
  • @tsconfig/strictest 2.0.3
  • @changesets/cli 2.27.1
  • eslint-config-dewald 1.0.17
  • eslint 8.57.0
  • typedoc 0.25.12
  • typescript 5.4.2
  • vitest 1.4.0
  • @vitest/coverage-v8 1.4.0
  • @vitest/ui 1.4.0
  • vite 5.1.6
package/package.json
  • hotscript 1.0.13
  • tsup 8.0.2
  • cross-env 7.0.3
website/package.json
  • typedoc-json-parser 9.0.1
  • @fortawesome/fontawesome-common-types 6.5.1
  • @fortawesome/free-brands-svg-icons 6.5.1
  • @fortawesome/free-regular-svg-icons 6.5.1
  • @fortawesome/free-solid-svg-icons 6.5.1
  • svelte-fa 4.0.2
  • svelte-sitemap 2.6.0
  • @sveltejs/adapter-static 3.0.1
  • @sveltejs/kit 2.5.2
  • @tailwindcss/nesting 0.0.0-insiders.565cd3e
  • svelte 4.2.12
  • @sveltejs/vite-plugin-svelte 3.0.2
  • svelte-check 3.6.6
  • tailwindcss 3.4.1
  • marked 12.0.0
  • svelte-meta-tags 3.1.0
  • @stackblitz/sdk 1.9.0

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

data-first or data-last paradigm

It's not stated in the docs whether you follow data-first or data-last paradigm, but I noticed that you incline towards the latter, e.g. intersection and difference. At the same time unique follows the data-first approach.
Do you have an opinion on what is better and why?
As far as I can judge from the TS perspective it's usually easier to put the callback last because all the typings would be in-place. Otherwise, when you provide the first parameter the types of the arrays are not yet defined which causes inconvenience.
Anyway, following a single paradigm seems a good way to go. What are your thoughts about it?

Feature request: debounce.pending()

Add pending function to debounce


Here the issue on Lodash (2017/09): lodash/lodash#3387
The PR that implements it (2017/09, jdalton himself): lodash/lodash#3388

It is present in Lodash master (2017/09, 6 years ago):

And yet never published as a Lodash npm package:

It should be part of Lodash v5 (which will probably never come)

Other interesting issues related to debounce.pending():

PlainObject not working with Interfaces

The Type PlainObject, which is used as type constrain for functions like merge does not accept interfaces.

type R = Record<PropertyKey, unknown>; // same as PlainObject, but its not exported. So lets rebuild it here
type Foo = {
  a: number;
  b: number;
};
interface Boo {
  a: number;
  b: number;
}

function f<x extends R>(x: x): void {
  /* NOP */
}

f<Foo>({ a: 1, b: 1 }); // This is OK
f<Boo>({ a: 1, b: 1 }); // This fails and requires a symbol and a string key

/*
Type 'Boo' does not satisfy the constraint 'R'.
  Index signature for type 'string' is missing in type 'Boo'.ts(2344)
*/

TS Playground: https://www.typescriptlang.org/play?ts=4.8.4#code/C4TwDgpgBASlC8sIGMD2AnAJgHgArtUnVAGkIQAaKAVwDsBrW1Ad1oD4BuKAem6gGcAhgFtog-lFwAbQQEtaAeQBGAKxTAqS6sCizgEpjogAPMBmARMAOigBlVFCkR9UdBC2ypmXToAWENwBYAChQSCgAMVQHRABvEKgoQQAuKFpqYSUAjgSoJVT0zOyQgF8c4PkLdAAzQWRoACFoqHjgxJS0jKz0csT8zqKe0pCQ6rpkYFlUWihq7GMoEwtaTAkYNgAKY1TjAEpUgDdUWW9WxO4AKigAOQVcKAvuYeDR7CjUTdik1IBGTV+oCVdlxeFAACq+WQSKFQBQkV5ND4bL4dP55AFAkF8CEw2qeCSCFauCAAR2osjcBIEIEyqCkSSJggEwHQ8gA5lB6OQgA

intersecting different types is not supported

It would be great if your intersect method supported a scenario like this:

const arr1 = [{ id: 1, name: 'Yeet' }, { id: 3, name: 'John' }];
const arr2 = [3, 4];

intersection((a, b) => a.id === b, arr1, arr2);

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.