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

object-to-array-convert

v1.1.0

Published

This package helps you work with objects in your project, making it very easy to convert object to array and manipulate it.

Downloads

41

Readme

Object-To-Array-Convert

Build Status

Code Quality

NPM

This package helps you work with objects in your project, making it very easy to convert object to array and manipulate it

Installation

Add Object-To-Array-Convert to your project by executing

$  npm install object-to-array-convert
or
$ yarn add object-to-array-convert

and that's it, you're all good to go!

Usage

To convert object to array use the "O2A"
//import the O2A into your project
import firebase from  "firebase";
import { O2A } from 'object-to-array-convert';

//and then use like so 
   firebase.database().ref("/user/").on('value', (data) => {
        const value = O2A(data);
        return value;
    })
NOTE: The O2A() api will add a new field to your record called object_key, which is the key of that item in the array.

To Reverse the items in an array use the "ReverseO2A"
understand that the "ReverseO2A" will only reverse items in an array and nothing more. But can also be used with the "O2A".
//import the O2A into your project
import firebase from  "firebase";
import { O2A, ReverseO2A } from 'object-to-array-convert';

//and then use like so 
   firebase.database().ref("/user/").on('value', (data) => {
        const value = ReverseO2A(O2A(data));
        return value;
    })

To Get the First items in an array use the "FirstO2A"
understand that the "FirstO2A" will only get the first items in an array and nothing more. But can also be used with the "O2A".
//import the O2A into your project
import firebase from  "firebase";
import { O2A, FirstO2A } from 'object-to-array-convert';

//and then use like so 
   firebase.database().ref("/user/").on('value', (data) => {
        const value = FirstO2A(O2A(data));
        return value;
    })

To Get the Last items in an array use the "LastO2A"
understand that the "LastO2A" will only get the last items in an array and nothing more. But can also be used with the "O2A".
//import the O2A into your project
import firebase from  "firebase";
import { O2A, LastO2A } from 'object-to-array-convert';

//and then use like so 
   firebase.database().ref("/user/").on('value', (data) => {
        const value = LastO2A(O2A(data));
        return value;
    })

To Get a specific number of item in an array use the "GetNO2A"
understand that the "GetNO2A" will only get the specific number of items in an array and nothing more. But can also be used with the "O2A".
//import the O2A into your project
import firebase from  "firebase";
import { O2A, GetNO2A } from 'object-to-array-convert';

//and then use like so 
   firebase.database().ref("/user/").on('value', (data) => {
        const value = GetNO2A(O2A(data), 3);
        return value;
    })

To Find out the total number of items in the array "CountO2A"
understand that the "CountO2A" will only get the total number of items in an array and nothing more. But can also be used with the "O2A".
//import the O2A into your project
import firebase from  "firebase";
import { O2A, CountO2A } from 'object-to-array-convert';

//and then use like so 
   firebase.database().ref("/user/").on('value', (data) => {
        const value = CountO2A(O2A(data));
        return value;
    })

Props

all Object-To-Array-Convert props

| Name | Use | | ------ | ------ | | O2A(data) | to convert object to array | | ReverseO2A(data) | Reverse the item in an array | | FirstO2A(data) | Get first item in an array| | LastO2A(data) | Get last item in an array | | GetNO2A(data, number) | Get n amount of items in an array | | CountO2A(data) | Get total amount of items in an array |

don't forget to star, like and share :)

Licensing


This project is licensed under MIT license.