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

@consid/sitevision-functions

v1.0.8

Published

This is a JavaScript package for handling standard JavaScript functions commonly used in Sitevision.

Downloads

24

Readme

Consid Sitevision functions

This is a JavaScript package for handling standard JavaScript functions commonly used in Sitevision.

Getting started

1. install the package

npm install @consid/sitevision-functions

2. Import the package in your .js file

Import all functions in the .js file

import * as sitevisionFunctions from '@consid/sitevision-functions';

OR Import some of the functions in the .js file

import {getNumberOfArrays} from '@consid/sitevision-functions';

3. Use the functions in your .js file.

sitevisionFunctions.getNumberOfArrays(array);

Available functions in the npm package @consid/sitevision-functions:

Arrays

Sort arrays on date in descending order.

/**
 * @param {items} Array
 * @returns array with the newest array first
*/
function sortArraysOnDate(items)

Get part of array based on a maximum amount of arrays that should be returned.

/**
 * @param {items} Array
 * @param {maxItems} number amout of arrays to be returned af function execution
 * @returns array 
*/
function getNumberOfArrays(items, maxItems)

Date

Check if date d1 and date d2 is the same day.

/**
 * @param {d1} Date
 * @param {d2} Date 
 * @returns boolean 
*/
function isSameDay(d1, d2);

Add new functions

1. create a new folder in /functions/example and create a new example.js file with the same name as the folder.

2. Export your function in the example.js file:

export const example = () => {
}

3. Import and export your new function in index.js

import {
   example
} from './functions/example/example';

export {
  example
};

Now your done and ready to push your changes and add a new pull-request to the repository! 🎉🎉🎉

Test functionality

The application have a javascript file name app.js which imports sitevisionFunctions as default with all functions available in the npm package. So that it is possible to test the new functionality before a new release of the package.

1. Install the application:

npm install

2. Run the application and test the functionality in app.js:

npm run dev

3. Open your favorite browser and type in the address: http://127.0.0.1:3000/

Now you should see a text with Test environment ready and your all set to start coding new functionality! 💻

Example how functionality could be tested in app.js:

import * as sitevisionFunctions from './index';
import * as http from 'http';

const hostname = '127.0.0.1';
const port = 3000;

let array = [
   { id: 1, date: "Mar 12 2012 10:00:00 AM" },
   { id: 2, date: "Mar 8 2012 08:00:00 AM" },
   { id: 2, date: "Mar 4 2012 08:00:00 AM" },
   { id: 2, date: "Mar 9 2012 08:00:00 AM" }
];

const server = http.createServer((req, res) => {
   let newArray = sitevisionFunctions.sortArraysOnDate(array);
   res.statusCode = 200;
   res.setHeader('Content-Type', 'text/plain');
   res.end(JSON.stringify(newArray));
});

server.listen(port, hostname, () => {
   console.log(`Server running at http://${hostname}:${port}/`);
});

Authors