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

freesewing-baby

v0.2.2

Published

Generate a baby measurement set based on a single measurement

Downloads

10

Readme

freesewing-baby

An NPM package to generate measurements to create freesewing patterns for babies based on a single measurement

Important disclaimer

This package is a work in progress. The baby measurements have not all been verified, and it seems only the top ones work (aka you can generate a Brian and probably anything based on it, but Charlie currently generates a blank SVG). I will be testing the measurements once I can measure the waist of the infant in my life, and I invite others to test them as well so long as they don't expect a guarantee that the garment will fit. If you try it and the garment fits wrong, please submit an issue with as much detail as possible.

Usage

Just generating measurements

If you prefer to just generate some measurements to manually add to FreeSewing, here's the easy way to do it.

In your terminal/console (in your node package directory):

npm install freesewing-baby

In your index.js file:

import Baby from 'freesewing-baby'
const measurements = new Baby(440) //44 cm waist
console.log(measurements)

By default, freesewing-baby assumes you're using millimeters and want millimeters back. To change this, use the second argument to specify what measurements you're passing in and the third to specify what measurements you're wanting back.

For example, if you're using inches and want millimeters back, you could do Baby(17,"in"). If you want inches back, you can do Baby(17,"in","in"). Both arguments accept "in", "mm", or "cm". In order to request something other than millimeters back, you must pass in all three arguments.

Uploading measurements

Currently, there is no way to upload measurement sets directly to your account via node, but when v3 comes out, you can use the API to create a person. This documentation is also subject to change.

Generating whole pattern in node.js

Installation

In your terminal/console (in your node package directory):

npm install @freesewing/core@next @freesewing/plugin-bundle@next @freesewing/utils@next
npm install @freesewing/pattern@next freesewing-baby

Replace "pattern" with the specific pattern you're trying to make. You may also have to install additional dependencies if the design you're using depends on others. For example, @freesewing/aaron requires @freesewing/brian. For more on how to generate FreeSewing patterns in node.js, see the freesewing.dev page howto on node.js.

Note: when v3 of FreeSewing comes out, remove the @next.

In your package.json, make sure you have set "type": "module" somewhere.

In your index.js file:

import { Pattern } from '@freesewing/pattern' //again, replace "Pattern" and "pattern" with the specific pattern you want to use. Make sure the pattern inside the brackets is capitalized, as this is a named export.
import { pluginTheme as theme } from '@freesewing/plugin-theme' //theme optional but recommended
import Baby from 'freesewing-baby' //you can name this import whatever you want

Pattern generation

To generate a pattern with the Pattern you imported, put something like this in your index.js, updated with the actual design and seam allowance you want to use and your baby's waist measurement. The package assumes you're using millimeters as your measurement unless you specify.

const waistInMillimeters = 440 //if your baby's waist is about 44 centimeters (a bit over 17 inches)
const svg = new Pattern({
    sa: 10, //1 cm seam allowance, you can change this
    measurements: new Baby(waistInMillimeters),
    options: {
        //insert any required options for the pattern here
    }
}).use(theme).draft().render()

If you would rather work in a measurement other than millimeters, you can add a second argument:

measurements : new Baby(17,"in")

This only works with "in", "mm", or "cm" as the second argument. If you have a reason that you want a different measurement added, let me know.

Important note: While there is a third argument to say what measurement type you want back, if you're generating patterns this way the measurements need to be in millimeters. This generates millimeter measurements by default, so just leave the third argument blank!

Printable PDF or SVG

The above code just returns a string svg with the contents of an svg image. In order to actually get a working pattern, you'll first need to save the svg. This will require the fs module or something similar.

First, install fs:

npm install fs
import fs from 'fs'

Then, you can save an SVG file like so:

fs.writeFile('./path/to/fileYouWant.svg', svg, err => {
  if (err) {
      console.error(err);
  }
  else console.log("File written successfully!")
});

Note the console logging and error are not strictly necessary, but can be helpful to determine if something goes wrong.

If you want to turn your pattern into something you can print, use FreeSewing's tiler tool and upload the SVG you generated. It can convert it to a printable PDF for several different paper sizes.

Running tests

The package has a couple of inbuilt tests. If you want, you can generate your own Aaron or Brian from them. The Charlie test currently doesn't work, but here's how to do the others:

import Baby, {tests} from 'freesewing-baby'
tests.createAaron(new Baby(500),'./tests/aaron.svg')
tests.createBrian(new Baby(550),'./tests/brian.svg')

The second argument is a URL of where you would like the SVG to be stored. The file doesn't have to exist when you run the test, but the directory does. You don't have to have the tests folder or anything, just choose a relative or absolute file path.