npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@maicol07/ts-collections

v1.0.0

Published

Collections for array and objects data. Heavily faithful to Laravel implementation.

Downloads

2

Readme

Why?

Differences between Laravel Collections and TS Collections

There are some little differences between Laravel Collections and TS Collections due to how JS/TS works:

  • All names are camelCase (following JS coding standards)

Helpers

  • When you use a fallback value and the value you are trying to get is undefined, you will get the fallback value. Example:

    const data = {
      name: 'John Doe',
      age: undefined,
      address: {
        city: 'New York',
        country: 'USA'
      }
    }
    
    dataGet(data, 'age', 'fallback')
    // => 'fallback'

    The same applies to all the Collection methods that use this helper.

Collections

  • There are some new methods:
    • entries
    • isArray
  • Currently, lazy collections aren't implemented.
  • Due to the difference above, you can't use the following Laravel methods on your Collection:
    • chunkWhile
    • countBy
  • There are some changes inn the API of these methods:
    • contains: Instead of Laravel approach, this method will accept only one argument (item) that can be one of these values:
      • The item to test for
      • A function that will be called for each item in the collection and return true if the item matches
      • An entry (key-value pair) of the item to search in the collection
  • The following methods have not been implemented since they are already implemented in other methods or are natively supported by JS/TS:
    • containsStrict (since contains already does strict checks, following JS best practices)

WIP Status

  • [x] all
  • [x] average
  • [x] avg
  • [ ] chunk
  • [ ] chunkWhile
  • [x] collapse
  • [x] collect
  • [x] combine
  • [x] concat
  • [x] contains
  • [x] containsOneItem
  • [x] containsStrict
  • [x] count
  • [ ] countBy
  • [ ] crossJoin
  • [x] dd
  • [x] diff
  • [x] diffAssoc
  • [ ] diffAssocUsing
  • [x] diffKeys
  • [x] doesntContain
  • [ ] dot
  • [x] dump
  • [ ] duplicates
  • [ ] duplicatesStrict
  • [x] each
  • [ ] eachSpread
  • [ ] ensure
  • [x] every
  • [ ] except
  • [x] filter
  • [x] first
  • [ ] firstOrFail
  • [ ] firstWhere
  • [ ] flatMap
  • [x] flatten
  • [ ] flip
  • [ ] forget
  • [ ] forPage
  • [x] get
  • [ ] groupBy
  • [x] has
  • [ ] hasAny
  • [ ] implode
  • [ ] intersect
  • [ ] intersectAssoc
  • [ ] intersectByKeys
  • [ ] isEmpty
  • [ ] isNotEmpty
  • [ ] join
  • [ ] keyBy
  • [x] keys
  • [x] last
  • [ ] lazy
  • [ ] macro
  • [x] make
  • [x] map
  • [ ] mapInto
  • [ ] mapSpread
  • [ ] mapToGroups
  • [ ] mapWithKeys
  • [ ] max
  • [x] median
  • [ ] merge
  • [ ] mergeRecursive
  • [ ] min
  • [x] mode
  • [ ] nth
  • [ ] only
  • [ ] pad
  • [ ] partition
  • [ ] percentage
  • [ ] pipe
  • [ ] pipeInto
  • [ ] pipeThrough
  • [x] pluck
  • [ ] pop
  • [ ] prepend
  • [ ] pull
  • [x] push
  • [x] put
  • [ ] random
  • [x] range
  • [x] reduce
  • [ ] reduceSpread
  • [ ] reject
  • [ ] replace
  • [ ] replaceRecursive
  • [x] reverse
  • [ ] search
  • [ ] shift
  • [ ] shuffle
  • [ ] skip
  • [ ] skipUntil
  • [ ] skipWhile
  • [ ] slice
  • [ ] sliding
  • [ ] sole
  • [ ] some
  • [x] sort
  • [ ] sortBy
  • [ ] sortByDesc
  • [ ] sortDesc
  • [ ] sortKeys
  • [ ] sortKeysDesc
  • [ ] sortKeysUsing
  • [ ] splice
  • [ ] split
  • [ ] splitIn
  • [x] sum
  • [ ] take
  • [ ] takeUntil
  • [ ] takeWhile
  • [ ] tap
  • [ ] times
  • [ ] toArray
  • [ ] toJson
  • [ ] transform
  • [ ] undot
  • [ ] union
  • [ ] unique
  • [ ] uniqueStrict
  • [ ] unless
  • [ ] unlessEmpty
  • [ ] unlessNotEmpty
  • [ ] unwrap
  • [ ] value
  • [x] values
  • [ ] when
  • [ ] whenEmpty
  • [ ] whenNotEmpty
  • [ ] where
  • [ ] whereStrict
  • [ ] whereBetween
  • [ ] whereIn
  • [ ] whereInStrict
  • [ ] whereInstanceOf
  • [ ] whereNotBetween
  • [ ] whereNotIn
  • [ ] whereNotInStrict
  • [ ] whereNotNull
  • [ ] whereNull
  • [ ] wrap
  • [ ] zip

Credits