GithubHelp home page GithubHelp logo

alisonmonteiro / shoe-size-converter Goto Github PK

View Code? Open in Web Editor NEW
20.0 3.0 5.0 46 KB

Converts footwear (shoe) sizes using a collection of sizing systems ๐Ÿ‘Ÿ

Home Page: https://npm.im/shoe-size-converter

License: MIT License

JavaScript 100.00%
shoes converter shoe-size iso conversion footwear

shoe-size-converter's Introduction

shoe-size-converter

Converts footwear (shoe) sizes using a collection of sizing systems ๐Ÿ‘Ÿ

Build Status

Usage

npm install shoe-size-converter --save

import {convert, iso} from 'shoe-size-converter';

convert({size: 36.5, system: 'eu'}, iso);
// =>
[{
	size: 4,
	prettySize: '4',
	system: 'au',
	men: true
}, {
	size: 6,
	prettySize: '6',
	system: 'au',
	women: true
}, {
	size: 5,
	prettySize: '5',
	system: 'brannock',
	men: true
}, {
	size: 6,
	prettySize: '6',
	system: 'brannock',
	women: true
}, {
	size: 23,
	system: 'cm',
	unisex: true
}, {
	size: 36.5,
	system: 'eu',
	unisex: true
}, {
	size: 230,
	system: 'mondopoint',
	unisex: true
}, {
	size: 3.5,
	prettySize: '3 1/2',
	system: 'mx',
	men: true,
	women: true
}, {
	size: 4,
	prettySize: '4',
	system: 'uk',
	men: true,
	women: true
}, {
	size: 5,
	prettySize: '5',
	system: 'us',
	men: true
}, {
	size: 6,
	prettySize: '6',
	system: 'us',
	women: true
}]

API

convert(parameters, systems, [options]);

parameters.size

Type: string|number

The shoe size you want to convert.

Can either be a size in number, or a string that can be transformed using each system's pretty transformers. For inch-based sizes, the iso system default to handling 'X Y/Z' formats (where Z is 2, 4 or 8).

[parameters.system]

Type: string

The system of the specified size

Default: As specified in systems. For iso: mondopoints

[parameters.women]

Type: boolean

Whether the passed in size should be treated as a women's size. Otherwise treated as a men's size (unless parameters.children has been specified).

Default: false

[parameters.children]

Type: boolean

Whether the passed in size should be treated as a children's size. Otherwise treated as a men's size (unless parameters.women has been specified).

Default: false

system

Type: A System

Usually iso is passed in, unless you want to use a custom system.

Check systems/iso/index.js for an example of the format.

options.footToLast

Type: Function

A function to convert between foot length and last length (both ways). See helpers.js for the existing/default one and use the same function signature if you want to provide a custom one.

The default implementation follows ISO, i.e. 2 size difference for adults, and 8% for children.

Default: See helpers.js -> footToLast

options.round

Type: Function

A function to round shoe sizes to reasonable sizes. See helpers.js for the existing/default one and use the same function signature if you want to provide a custom one.

Works in tandem with the round-property on each system.

Default: See helpers.js -> round

How it works

Converts footwear (shoe) sizes using a collection of sizing systems, provided along when converting. Each system support converting from the system to a unified format and from the unified format back to the system format. The default system follows the ISO standard (roughly - even the ISO standard say that footwear size conversion isn't a solved problem yet, unfortunately).

The default collection of systems included (iso) follows the ISO standardization (all systems convert to mondopoints and back for conversion) and implements the following systems ( either according to spec, or best match possible):

  • Mondopoint (mm, mondo, mondopoints)
  • EU
  • UK
  • US
  • Brannock (currently the same as US)
  • cm
  • AU
  • MX

See each system file for comments and details. They are quite short and easy to read.

Custom system collection

To implement your own systems, see the current implementation(s) at systems/iso/ (or systems/table/) for reference. As long as the same structure is followed, it should be fairly trivial.

Table-based system (and backwards compatibility)

There's a table-based systems collection which can be used instead of iso:

import {convert} from 'shoe-size-converter';
import {table} from 'shoe-size-converter/systems/table';

convert({size: 36.5, system: 'eu'}, table);
// => Same format as above - but with different conversion result

Currently, it's based on the old sizing table, which means it can be used to have the same conversion as version 0.0.5 and earlier, BUT with the new API.

The old conversion table can be found in the size-tables.js file, along with other conversion tables.

shoe-size-converter's People

Contributors

alisonmonteiro avatar cjblomqvist avatar styfle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

shoe-size-converter's Issues

Support for webpack 4 target: node with webpack-node-externals

When compiling with webpack with target: 'node', excluding node_modules (such as this package) using webpack-node-externals (which is common/best practice for target: 'node'), there's a mismatch since the app code will get transformed into require statements, but leave the original package as is (with es6 module syntax) - which causes your app to fail.

This is really a problem with webpack not handling this properly - but it also assumes you run node 14 or 12 with the module flag turned on (so if you want to run older versions you'll definitely have this issue).

Workaround: Exclude this package from webpack-node-externals (e.g. by whitelisting).

This issue is just for documentation's sake, in case anyone stumbles into the same issue. The workaround is fine until webpack handles this better.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.