GithubHelp home page GithubHelp logo

jesserussell411 / itmod Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 759 KB

Stands for Iterator Modifier. Linq for typescript. I was inspired by this video: https://www.youtube.com/watch?v=fG8GgqfYZkw. Something about an intelligent person showing off what they built made me want to make something similar. https://github.com/JesseRussell411/itmod/tree/main/src/collections contains a few datastructure implementations.

Home Page: https://npm.io/package/iterator-modifier

TypeScript 99.94% JavaScript 0.06%

itmod's Introduction

itmod

Stands for Iterator Modifier. Linq for typescript.

Allows the use of array operations like map, filter, or reduce on any Iterable (anything with a [Symbol.Iterator] method) with lazy execution.

To install:

npm install iterator-modifier

To use:

import Itmod from "iterator-modifier";

/** The mean of 2 and 4 */
const mean = Itmod.from([1, 2, 3])
    .map((n) => n + 1)
    .filter((n) => n % 2 === 0)
    .reduce(
        (t, n) => t + n,
        (total, numCount) => total / numCount
    );
console.log("mean:", mean);

Some nice features.

Lazy execution, above all else.

Sorting with default behavior that makes sense.

Itmod.of(1,10, 2, 20, 7, 90, 3).sort().toArray() => [1, 2, 3, 7, 10, 20, 90]

[1,10, 2, 20, 7, 90, 3].sort() => [1, 10, 2, 20, 3, 7, 90]

Converting to and from objects.

Itmod.fromObject({one: 1, two: 2, three: 3}).append(["four", 4]).toObject() => {one: 1, two: 2, three: 3, four: 4}

Takes any Iterable (or function that returns an Iterable).

Writen in modern-style typescript.

Infinite sequences.

high level optimizations.

declarative programming.

Itmod's methods

forEach

map

flat

filter

defined

notNull

notNullish

zip

reduce

fold

concat

preConcat

append

prepend

reverse

repeat

first

final

distinct

union

intersection

difference

take

takeFinal

takeEveryNth

takeWhile

skip

skipFinal

skipEveryNth

skipWhile

copyWithin

indexed

includes

some

none

every

nonIteratedCountOrUndefined

count

min

max

groupBy

split

partitionBySize

groupJoin

innerGroupJoin

join

innerJoin

toArray

toSet

toMap

indexBy

toObject

asArray

asSet

asMap

asObject

sort

sortDescending

shuffle

collapse

sequenceEquals

makeString

SortedItmod's methods

thenBy

thenByDescending

GroupedItmod's methods

mapGroups

itmod's People

Contributors

jesserussell411 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.