New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@basekits/core

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@basekits/core

Super extensible utility library for javascript apps.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

@basekits/core

Super extensible utility library for javascript apps.

As an alternative to lodash or underscore, basekits is a modular, fast and powerful helper library for javascript apps.

Introduction

The core package has no utility or helper. Utility and helper functions are provided by kits. A kit, is a group of helper functions. The core allows you to add/update/remove kits.

Installation

Through npm:

npm i @basekits/core

Usage and Sample Kit

Let's create a sample kit that has two functions which are isString and isUUID:

const sampleKit = {
  name: 'sample',
  items: {
    isString: function isString(v) {
      return typeof v == 'string'
    },
    isUUID: function isUUID(v) {
      return this.regexes.uuid.test(v)
    }
  },
  opts: {
    regexes: {
      uuid: /[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}/g
    }
  }
}

name, items and opts are the three main properties that creates the kit. Now we are going to see how core eats them:

const kit = require('@basekits/core')

// add kit
kit.addKit(sampleKit)

// all valid items registered
kit.isString('some string') // returns true
kit.isString(12) // returns false
kit.isUUID('109156be-c4fb-41ea-b1b4-efe1671c5836') // returns true

As you see above, all items registered as a property for kit and ready to use. regexes property in opts indicates that the kit is going to need some regular expressions in order to work. core stores regular expressions in its regexes property and they can be accessible in this.regexes property as you can see above in isUUID.

If you would like to add, update or remove an item in the sample kit:

kit.sample.removeItem('isString')
// kit.isString is not available anymore

kit.sample.addItem('isString', function isString() {/*...*/})
kit.isString('') // returns true

// replace existing function with the new one
kit.sample.updateItem('isString', function isString() {/**/})

Kits Available To Use

No one needs to write its own kit unless there is a special need. There are many kits written already and anyone can start using it right away:

  1. @basekits/kit-type
  2. @basekits/kit-array
  3. @basekits/kit-error
  4. @basekits/kit-object
  5. @basekits/kit-validator
  6. @basekits/kit-dom
  7. @basekits/kit-hashing
  8. @basekits/kit-function
  9. @basekits/kit-string

Development & Contributing

Clone this repo and run test:

npm run test

Run builds:

npm run builds

Make a pull request.

Keywords

FAQs

Package last updated on 20 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc