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

pirkan

v1.0.0

Published

Basic Day To Day Implementation

Downloads

76

Readme

Pirkan

Pirkan is a TypeScript package designed for creating modular collections of business logic. It provides functionality for transforming data, merging, pivoting, and more, using a flexible indexing system.

Features

  • Modular Structure: Create modules for collections with various operations.
  • Dynamic Method Generation: Automatically generate methods like findById, findByName, and more based on your data structure.
  • Key Transformation: Easily transform keys of objects with a specified mapping.

Installation

To install the package, run:

npm install pirkan

Usage

Initializing a Pirkan Instance the instance have this methods: getAll, findById and transform. lets dive to each of them:

getAll

import Pirkan from 'pirkan';

interface IOrder { id: number; type: string; }
const orderCollection: IOrder = [{ id: 1, type: 'book', { id: 2, type: 'book' }];

const pirkanOrders = new Pirkan<IOrder>({items: orderCollection});

Get all collection items

const orders: IOrder[] = pirkanOrders.getAll();

orders value when calling getAll:

 [{ id: 1, type: 'book' }]

findById

findById

const orders: IOrder = pirkanOrders.findById(1);

orders value when calling findById:

 [{ id: 1, type: 'book' }]

findBy*

Initializing a Pirkan Instance grouped by any key you like, id is the default

import Pirkan from 'pirkan';

interface IOrder { id: number; type: string; }
const orderCollection: IOrder = [{ id: 1, type: 'book' }, { id: 2, type: 'book' },{ id: 2, type: 'bag' }];

const pirkanOrders = new Pirkan<IOrder>({
  items: personCollection,
  byKeyName: 'type',
});

findByType

const orders: IOrder = pirkanOrders.findByType('book'); //if book is in enum it will ask to use enum here i.e OrderTypes.BOOK

orders value when calling findByType:

 [{ id: 1, type: 'book' }, { id: 2, type: 'book' }]

findBy{key1}And{key2} (for example findByIdAndType)

Initializing a Pirkan Instance with

import Pirkan from 'pirkan';

interface IOrder { id: number; type: string; }
const orderCollection: IOrder = [{ id: 1, type: 'book' }, { id: 2, type: 'book' },{ id: 2, type: 'bag' }];

const pirkanOrders = new Pirkan<IOrder>({
  items: personCollection,
  byDualKeyName: ['id', 'type'],
});

findByIdAndType

const orders: IOrder = pirkanOrders.findByIdAndType(1, 'book'); //if book is in enum it will ask to use enum here

orders value when calling findByType:

 [{ id: 1, type: 'book' }]

transformKeys

simple transform between existing keys to other keys, use a partial input, so you can provide any key you like, also it will check that your return value will return as expected. only for shallow layer at the moment

interface INewOrderStructure {userId: number, type: string}
const orders: INewOrderStructure = pirkanOrders.transformKeys<INewOrderStructure>({id: 'userId', type: 'orderType'});

orders value when calling transformKeys:

 [{ userId: 1, orderType: 'book' }, { userId: 2, orderType: 'book' }]

if someone want to help me with this, please message me here: [email protected] thanks in advance :)

p.s pirkan is the hebrew word for module