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

@practicaloptimism/program-utility

v2.0.3

Published

A set of useful algorithms and data structures for computer programs

Downloads

471

Readme

Program Utility

A few algorithms and data structures for accessing property values of objects by using a property key name list. Also available, you may create a deep copy of objects and/or track the copies by using the ObjectDuplicator data structure.

Website Resources

Source Code | Demos | Video Introduction | Video Tutorial | Live Programming Development Journal

Project Development Status Updates

npm version downloads coverage report pipeline status

This Documentation Page was last Updated on Mon Jan 24 2022 15:19:13 GMT-0600 (Central Standard Time)

Installation

Node Package Manager (NPM) Installation
npm install --save @practicaloptimism/program-utility
Script import from JavaScript (requires NPM installation)
import * as programUtility from '@practicaloptimism/program-utility'
HTML Script Import
<script src="https://unpkg.com/@practicaloptimism/program-utility"></script>

Getting Started: Accessing Object Property Value

// Initialize the javascript library instance and the usecase property value
const programUtilityInstance = programUtility.algorithms.createJavascriptLibraryInstance.function()
const objectUtility =  programUtilityInstance.usecase.objectUtility.algorithms.object

// Create your javascript object
const object = { name: 'Hitomi', hobbyTable: { dancing: true, watchingScaryMovies: false } }

// Create your property value key list
const propertyKeyList = ['hobbyTable', 'dancing']

// Get your object property value using a key list
const propertyValue = objectUtility.getObjectValue.function(object, propertyKeyList)

// The value printed should return 'true'
console.log(propertyValue)

Getting Started: Creating Object Duplicators

// Initialize the javascript library instance and the usecase property value
const programUtilityInstance = programUtility.algorithms.createJavascriptLibraryInstance.function()
const  objectDuplicatorUtility =  programUtilityInstance.usecase.objectUtility.algorithms.objectDuplicator

// Create your javascript object
const object = { name: 'Miranda', hobbyTable: { watchingScaryMovies: true, watchingDanceRecitals: false } }

// Create your ObjectDuplicator data structure
const objectDuplicator = objectDuplicatorUtility.createObjectDuplicator.function(object)

// Add a duplicate of your object
objectDuplicatorUtility.addObjectToObjectDuplicator.function(objectDuplicator, 'item1')

// Get the duplicate of your object by using a sting value (objectDuplicateId)
const objectDuplicate = objectDuplicatorUtility.getObjectFromObjectDuplicator.function('item1')

// Change the 'name' property value of the object duplicate
// to showcase that the object and object duplicate
// will have different names since they are deep copies
// of one another.
objectDuplicate.name = 'Susan'

// The value printed should return 'false'
console.log(object.name === objectDuplicate.name)

Application Programmable Interface (API Reference)

constructor(defaultOption) {
    super(defaultOption);
    Object.assign(this, defaultOption);
}

}

constructor(defaultOption) {
    Object.assign(this, defaultOption);
}

}

constructor(defaultOption) {
    Object.assign(this, defaultOption);
}

}GetObjectPropertyKeyNameListByDepthFirstOrderFunctionfunction getObjectPropertyKeyNameListByDepthFirstOrderFunction(object, parentKeyNameList, option) { if (!object) { return []; } if (typeof object !== 'object') { return []; } if (!parentKeyNameList || parentKeyNameList.length < 0) { parentKeyNameList = []; } let propertyKeyNameList = []; if ((parentKeyNameList.length > 0) && (option ? !option.booleanObjectKeyNotAllowed : true)) { propertyKeyNameList.push(parentKeyNameList); } for (let objectKey in object) { if (!object.hasOwnProperty(objectKey)) { continue; } const objectPropertyKeyNameList = [...parentKeyNameList, objectKey]; if (option && (option.objectPropertyTreeHeight !== undefined) && (objectPropertyKeyNameList.length > option.objectPropertyTreeHeight)) { return []; } if (typeof object[objectKey] !== 'object') { propertyKeyNameList.push(objectPropertyKeyNameList); continue; } propertyKeyNameList.push(...getObjectPropertyKeyNameListByDepthFirstOrderFunction(object[objectKey], objectPropertyKeyNameList, option)); } return propertyKeyNameList; }GetObjectPropertyKeyNameListByBreadthFirstOrderFunctionfunction getObjectPropertyKeyNameListByBreadthFirstOrderFunction(object, parentKeyNameList, option) { if (!object) { return []; } if (typeof object !== 'object') { return []; } if (!parentKeyNameList || parentKeyNameList.length < 0) { parentKeyNameList = []; } let propertyKeyNameList = Object.keys(object).map(objectKey => { const propertyKeyName = Array.isArray(object) ? parseInt(objectKey, 10) : objectKey; return parentKeyNameList.concat(propertyKeyName); }); let removeObjectKeyNameListReferenceTable = {}; if (option && (option.objectPropertyTreeHeight !== undefined) && (propertyKeyNameList[0].length > option.objectPropertyTreeHeight)) { return []; } for (let i = 0; i < propertyKeyNameList.length; i++) { const objectPropertyKeyNameList = propertyKeyNameList[i]; const objectChildObjectValue = get_object_value__WEBPACK_IMPORTED_MODULE_0_["getObjectValue"].function(object, objectPropertyKeyNameList); const objectChildPropertyKeyNameList = getObjectPropertyKeyNameListByBreadthFirstOrderFunction(objectChildObjectValue, objectPropertyKeyNameList, option); if (option && option.booleanObjectKeyNotAllowed && typeof objectChildObjectValue === 'object') { removeObjectKeyNameListReferenceTable[i] = true; } propertyKeyNameList.push(...objectChildPropertyKeyNameList); } const propertyKeyNameListWithoutObjectKey = []; if (option && option.booleanObjectKeyNotAllowed) { for (let i = 0; i < propertyKeyNameList.length; i++) { const removeKeyNameListIndex = removeObjectKeyNameListReferenceTable[i]; if (removeKeyNameListIndex) { continue; } propertyKeyNameListWithoutObjectKey.push(propertyKeyNameList[i]); } propertyKeyNameList = propertyKeyNameListWithoutObjectKey; } return propertyKeyNameList; }

constructor(defaultOption) {
    Object.assign(this, defaultOption);
}

}

Operating Environment: JavaScript Runtime Environments

| JavaScript Runtime Environment | Node.js | Node.js Worker Thread | Web Worker | Google Chrome | Mozilla Firefox | Apple Safari | Beaker Browser | | -- | -- | -- | -- | -- | -- | -- | -- | | Supported Versions of the Runtime | The latest version(s) | The latest version(s) | The latest version(s) | The latest version(s) | The latest version(s) | The latest version(s) | The latest version(s) |

To Resolve Problems and Submit Feature Requests

To report issues or submit feature requests with this projectConstants, please visit Program Utility Issue Tracker

About This Project

Benefits

Features

Limitations

  • 🤓 Work-in-progress: This project is a work-in-progress. The project architecture and documentation are being updated regularly. Please learn more about the development life cycle by visiting our live programming development sessions on youtube: https://www.youtube.com/channel/UCIv-rMXljsbxoTUg1MXBi3g

Related Work

There are many projects relating to the application usecases that Program Utility strives to provide. A "project usecase 1", a "project usecase 2", a "project usecase 3" are the primary goal for Program Utility. This is a non-exhaustive list of other projects in the world that are being used and also relate to Program Utility usecase areas-of-interest (well renowned projects are prioritized in our listing order strategy):

| Object Utility Providers | | -- | | -- |

Acknowledgements

License

MIT