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

date-filtersjs

v1.1.7

Published

A Javascript library to help developers in filtering according to specific date range

Downloads

11

Readme

DATE-FILTERSJS - Combination of Filter and Date

Release Release Date Last Commit License

Introduction

This is a javascript library, the main purpose of this library is to easily apply filter on specific date range and apply filter on any attribute.

Installation

To build your project using Webpack or similar builders, install packages from NPM:

npm i date-filtersjs

import as follows:

import { Filter } from 'date-filtersjs/src/filter';
import { Dates }  from 'date-filtersjs/src/dates';

Usage

Example User object

let obj = [
    {
        "name" : "userx",
        "age"  : "20",
        "date" : "05/25/2019"
    },
    {
        "name" : "usery",
        "age"  : "21",
        "date" : "05/24/2019"
    },
    {
        "name" : "userg",
        "age"  : "21",
        "date" : "05/31/2019"
    },
    {
        "name" : "userz",
        "age"  : "21",
        "date" : "06/03/2019"
    },
    {
        "name" : "userw",
        "age"  : "21",
        "date" : "26/05/2019"
    }
];

Filter

let filter = new Filter(obj);                                            // initialize filter
filter.filterBy("name","userz").result();                                // Filter by an attribute
filter.where("name","==","userz").where("age","==","21").result();       // compound filter (AND), valid operators that can be used (==, !=, <= , >=)

filter.filterByToday("date").result();                                    // filters the date by today
filter.filterByYesterday("date").result();                                // filters the date by yesterday
filter.filterByCurrentWeek("date").result();                              // filters the date by first and last day of the week
filter.filterByCurrentMonth("date").result();                             // filters the date by current month
filter.filterByNextWeek("date").result();                                 // filters the date by next week
filter.filterByNextMonth("date").result();                                // filters the date by next month
filter.filterByLastWeek("date").result();                                 // filters the date by last week

filter.filterByNextThirtyDays("date").result();                           // filters the date by next thirty days
filter.filterByLastSevenDays("date").result();                            // filters the date by last seven days
filter.filterByLastThirtyDays("date").result();                           // filters the date by last thirty days
filter.filterByLastSixtyDays("date").result();                            // filters the date by last sixty days 

filter.filterByLastNinetyDays("date").result();                           // filters the date by last ninety days
filter.filterByMonthToDate("date").result();                              // filters the date by month to date
filter.filterByLastMonth("date").result();                                // filters the date by last month

Note: All of the above will return the filtered array

Date

You can also retrieve the date ranges, the following are the different methods available:


let date = new Dates();                                                  // initialize
date.setFormat("MM/DD/YYYY");                                            // set the format, valid formats ("MM/DD/YYYY", "MM-DD-YYYY", "DD/MM/YYYY")
date.getFormat();                                                        // retrieve format

// both methods below will return an object like this {date: "26/05/2019"}, you can access the date using "date" attribute

date.today();                                                           // retrieve today's date
date.yesterday();                                                       // retrieve yesterday's date

// all methods below will return an object like this {first: "26/05/2019", last: "01/06/2019"}, you can access the first and last date by using "first" and "last attribute

date.currentWeek();                                                     // retrieve first and last day of the week
date.currentMonth();                                                    // retrieve first and last day of the month
date.nextWeek();                                                        // retrieve first and last day of next week

date.nextMonth();                                                       // retrieve first and last day of next month
date.lastWeek();                                                        // retrieve first and last day of last week
date.nextThirtyDays();                                                  // retrieve first and last day of the next thirty days

date.lastSevenDays();                                                   // retrieve first and last day of last seven days
date.lastThirtyDays();                                                  // retrieve first and last day of last thirty days
date.lastSixtyDays();                                                   // retrieve first and last day of the last sixty days

date.lastNinetyDays();                                                  // retrieve first and last day of the last ninety days
date.monthToDate();                                                     // retrieve first day of the month and current day
date.lastMonth();                                                       // retrieve first and last day of last month

date.incrementBy("40"));                                                // retrieve current day and last day according to the increment number provided
date.decrementBy("40"));                                                // retrieve current day and last day according to the decrement number provided