Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fkit-js

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fkit-js

fkit ===========

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

fkit

fkit is a small javascript utility that aid in functional programming in javascript.

It consists of the following utilities:

  • get/mget
  • memoize
  • curry
  • identity
  • map

get/mget

get is a simple field getter for object literal data. It can be used to create reusable functions that access path that might be empty.


import { get } from 'jkit-js';

const order = ...

/*
  assumming order has a structure
  order = { product: { code: 'XY123' } };
  and product can be null
*/
if ( order && order.product ) {
    return order.product.code;
}

/**
  using get
*/
export const getProductCode = get('product.code');
const code = getProductCode(order);

Note that mget is a same as get but is memoized

memoize

A simple helper to create simple memoized functions. This assume that the function is a pure function. memoize takes in 2 arguments, 1. the function to memoize, 2.(optional) The function that can be used to generate a key. By default memoize will use the first argument as a key.


import { memoize } from 'jkit-js';

const translateCompute = memoize((a,b) => {
    return a.charCodeAt(a) + b.charCodeAt(b);
}, (a,b) => a + '_' + b);

export { translateCompute };

compose

Compose is a standard right to left compose.


import { get, compose } from 'jkit-js';

const getOrder = get('order');
const getProduct = get('product');
const getDeliveryInfo = get('deliveryInfo');

const getOrderProduct = compose(getProduct, getOrder);
const getOrderDeliveryInfo = compose(getDeliveryInfo, getOrder);

getOrderProduct({ order: { product: { id: '123'}}}); // { id: '123' }
getOrderDeliveryInfo({ order: { deliveryInfo: { address: 'Somewhere'}}}); // { address: '123' }

map

identity

curry

combinators

Keywords

FAQs

Package last updated on 23 Oct 2016

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