JSPM

  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q32897F
  • License BSD-3-Clause

A collection of useful utilities.

Package Exports

  • @1studio/utils
  • @1studio/utils/models/data
  • @1studio/utils/models/storage
  • @1studio/utils/propType
  • @1studio/utils/string/slugify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@1studio/utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

utils · travis build codecov coverage version commit type

A collection of useful utilities with Flow type checking (since 3.0).

Installation

Using npm:

$ npm i -S @1studio/utils

Transpiler for the Flow:

$ npm i -D babel-loader babel-preset-env babel-preset-flow babel-minify babel-plugin-transform-class-properties babel-plugin-transform-object-rest-spread

.babelrc

{
  "presets": ["flow", "env"],
  "plugins": ["transform-class-properties", "transform-object-rest-spread"],
  "env": {
    "production": {
      "presets": ["babel-minify"]
    }
  }
}

webpack.config.js

module: {
    rules: [
      {
        test: /\.js$/,
        exclude: [/node_modules\/(?!@1studio)/],
        use: [{
          loader: 'babel-loader'
        }]
      },
    ],
  }

Manual

Example (ES6):

import { getDistanceFromLatLonInKm } from '@1studio/utils/geometry';

const distance = getDistanceFromLatLonInKm(47.4925, 19.0513, 40.71448, -74.00598);
// Budapest <-> New York distance in km

Example (direct import):

import checkPropTypes from '@1studio/utils/propType/checkPropTypes'

checkPropTypes('string', PropTypes.number);
// -> [errors]

Example (Flow):

// @flow

import clamp from '@1studio/utils/math/clamp';

clamp('a');
// => Flow errors

Read more.

License

@1studio/utils is BSD licensed.