Coder Social home page Coder Social logo

nodef / extra-ientries Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 488 KB

IEntries is an iterable list of key-value pairs, with unique keys.

Home Page: https://www.npmjs.com/package/extra-ientries

License: MIT License

JavaScript 11.98% TypeScript 88.02%
chunk compare concat count count-as difference drop every extra filter

extra-ientries's Introduction

A collection of functions for operating upon Entries.
๐Ÿ“ฆ Node.js, ๐ŸŒ Web, ๐Ÿ“œ Files, ๐Ÿ“ฐ Docs, ๐Ÿ“˜ Wiki.

Entries is a list of key-value pairs, with unique keys. This package includes common functions related to querying about entries, generating them, comparing one with another, finding their size, adding and removing entries, obtaining its properties, getting a part of it, getting a subset entries in it, finding an entry in it, performing functional operations, manipulating it in various ways, combining together entries or its sub-entries, of performing set operations upon it.

All functions except fromLists() take entries as 1st parameter, and expect it to be iterable. It does not need to be an array. Entries are returned by Array, Object, Set, Map.

This package is available in Node.js and Web formats. The web format is exposed as extra_entries standalone variable and can be loaded from jsDelivr CDN.

Stability: Experimental.


const entries = require('extra-ientries');
// import * as entries from "extra-ientries";
// import * as entries from "https://unpkg.com/extra-ientries/index.mjs"; (deno)

var x = [['a', 1], ['b', 2], ['c', 3], ['d', 4], ['e', 5]];
[...entries.filter(x, v => v % 2 === 1)];
// โ†’ [ [ 'a', 1 ], [ 'c', 3 ], [ 'e', 5 ] ]

var x = [['a', 1], ['b', 2], ['c', -3], ['d', -4]];
entries.some(x, v => v > 10);
// โ†’ false

var x = [['a', 1], ['b', 2], ['c', -3], ['d', -4]];
entries.min(x);
// โ†’ -4

var x = [['a', 1], ['b', 2], ['c', 3]];
[...entries.subsets(x)].map(a => [...a]);
// โ†’ [
// โ†’   [],
// โ†’   [ [ 'a', 1 ] ],
// โ†’   [ [ 'b', 2 ] ],
// โ†’   [ [ 'a', 1 ], [ 'b', 2 ] ],
// โ†’   [ [ 'c', 3 ] ],
// โ†’   [ [ 'a', 1 ], [ 'c', 3 ] ],
// โ†’   [ [ 'b', 2 ], [ 'c', 3 ] ],
// โ†’   [ [ 'a', 1 ], [ 'b', 2 ], [ 'c', 3 ] ]
// โ†’ ]


Index

Property Description
is Check if value is an iterable.
keys List all keys.
values List all values.
fromLists Convert lists to entries.
compare Compare two entries.
isEqual Check if two entries are equal.
size Find the length of an iterable.
isEmpty Check if an iterable is empty.
get Get value at key.
getAll Get values at keys.
getPath Get value at path in nested entries.
hasPath Check if nested entries has a path.
set Set value at key.
swap Exchange two values.
remove Remove value at key.
count Count values which satisfy a test.
countAs Count occurrences of values.
min Find smallest value.
minEntry Find smallest entry.
max Find largest value.
maxEntry Find largest entry.
range Find smallest and largest values.
rangeEntries Find smallest and largest entries.
head Get first value.
tail Get values except first.
take Keep first n values only.
drop Discard first n values only.
subsets List all possible subsets.
randomKey Pick an arbitrary key.
randomEntry Pick an arbitrary entry.
randomSubset Pick an arbitrary subset.
has Check if entries has a key.
hasValue Check if entries has a value.
hasEntry Check if entries has an entry.
hasSubset Check if entries has a subset.
find Find first value passing a test (default order).
findAll Find values passing a test.
search Finds key of an entry passing a test.
searchAll Find keys of entries passing a test.
searchValue Find a key with given value.
searchValueAll Finds keys with given value.
forEach Call a function for each value.
some Check if any value satisfies a test.
every Check if all values satisfy a test.
map Transform values of entries.
reduce Reduce values of entries to a single value.
filter Keep entries which pass a test.
filterAt Keep entries with given keys.
reject Discard entries which pass a test.
rejectAt Discard entries with given keys.
flat Flatten nested entries to given depth.
flatMap Flatten nested entries, based on map function.
zip Combine matching entries from all entries.
partition Segregate values by test result.
partitionAs Segregate entries by similarity.
chunk Break entries into chunks of given size.
concat Append entries from all entries, preferring last.
join Join entries together into a string.
isDisjoint Check if entries have no common keys.
unionKeys Obtain keys present in any entries.
union Obtain entries present in any entries.
intersection Obtain entries present in both entries.
difference Obtain entries not present in another entries.
symmetricDifference Obtain entries not present in both entries.
randomValue Pick an arbitrary value.



ORG DOI Coverage Status Test Coverage Maintainability

extra-ientries's People

Contributors

wolfram77 avatar

Watchers

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