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

sketch-helpers

v0.0.4

Published

various 2D sketch helpers

Downloads

1,810

Readme

sketch-helpers

A number of 2d sketch helpers, they are 100% pure functions, no state to be found here.

I seemed to be obsessed with sketch helpers in Code-CAD applications, not only do I have this OpenSCAD library, but I also tried to add the following helpers to CascadeStudio. Unfortunately the latter was never merged, but I still think these are valuable at least to me. I'm likely to try and use these again at some point. I wouldn't consider this repo to be maintained, it's more "here for longevity".

I'm no TDD fanatic, but the methodology absolutely was a great help in this case. One challange I hit was with the test text, since tests serve double duty, primarily testing logic, but secondarily documenting the code, it can be hard to describe specific geometric secenarios, so I leveraged multiline template strings and everyone's favourite, 'ascii art', to draw the expected result.

Here's a dump of the test output to show what I mean:

 PASS  src/index.test.ts
  testing calculate3Points
    When the target angle is -90
      ✓ When clockwise and obtuse expect
      .-------------------------------- ~ - ,  startPoint
      .                                       ' ,
      .                                           , onArc
      .                                            ,
      .                                             ,
      .                                             , - endpoint
     (3 ms)
      ✓ When clockwise and acute expect
    .                         , - ~ ~ ~ - ,
    .                     , '               ' ,
    .                   ,  onArc                ,
    .                  ,                         ,
    .                 ,                           ,
    .                 ,                           , endPoint
    .                 ,
    .                  ,
    .                   ,
    .                     ,
    .______________________ ' - , _ _  startPoint
    
      ✓ When CCW and obtuse expect
    .                         , - ~ ~ ~ - ,
    .                     , '               ' ,
    .                   ,                       , onArc
    .                  ,                         ,
    .                 ,                           ,
    .                 , endPoint                  ,
    .                                             ,
    .                                            ,
    .                                           ,
    .                                        , '
    ._____________________________ _ _ _ , startPoint
     (1 ms)
      ✓ When CCW and acute expect
    .-------------------------, - ~ ~ startPoint
    .                     , '
    .                   , onArc
    .                  ,
    .                 ,
    .                 , endPoint
     (1 ms)
      ✓ When shortest and obtuse expect
    .-------------------------------- ~ - ,  startPoint
    .                                       ' ,
    .                                           , onArc
    .                                            ,
    .                                             ,
    .                                             , - endpoint
     (1 ms)
      ✓ When longest and obtuse expect
    .                         , - ~ ~ ~ - ,
    .                     , '               ' ,
    .                   ,                       , onArc
    .                  ,                         ,
    .                 ,                           ,
    .                 , endPoint                  ,
    .                                             ,
    .                                            ,
    .                                           ,
    .                                        , '
    ._____________________________ _ _ _ , startPoint
     (1 ms)
      ✓ When shortest and acute expect
    .-------------------------, - ~ ~ startPoint
    .                     , '
    .                   , onArc
    .                  ,
    .                 ,
    .                 , endPoint
     (1 ms)
      ✓ When longest and acute expect
    .                         , - ~ ~ ~ - ,
    .                     , '               ' ,
    .                   ,  onArc                ,
    .                  ,                         ,
    .                 ,                           ,
    .                 ,                           , endPoint
    .                 ,
    .                  ,
    .                   ,
    .                     ,
    .______________________ ' - , _ _  startPoint
    
    When the target angle is 90
      ✓ When clockwise and obtuse expect
      .---------------------------- ~ ~ - , startPoint
      .                                      ' ,
      .                                          ,
      .                                           ,
      .                                            ,
      .                , endPoint                  ,
      .                ,                           ,
      .                 ,                         ,
      .                  ,                       ,
      .                    ,                  , ' onArc
      .                      ' - , _ _ _ ,  '
    
      ✓ When clockwise and acute expect
    .                , endPoint
    .                ,
    .                 ,
    .                  , onArc
    .                    ,
    .______________________' - , _ _ startPoint
    
      ✓ When CCW and obtuse expect
    .                                             , endPoint
    .                                             ,
    .                                            , onArc
    .                                           ,
    .                                        , '
    ._____________________________ _ _ _ , startPoint
     (1 ms)
      ✓ When CCW and acute expect
    .------------------------, - ~ ~ startPoint
    .                    , '
    .                  ,
    .                 ,
    .                ,
    .                ,                           , endPoint
    .                ,                           ,
    .                 ,                         ,
    .                  , onArc                 ,
    .                    ,                  , '
    .                      ' - , _ _ _ ,  '
     (1 ms)
      ✓ When shortest and obtuse expect
    .                                             , endPoint
    .                                             ,
    .                                            , onArc
    .                                           ,
    .                                        , '
    ._____________________________ _ _ _ , startPoint
     (1 ms)
      ✓ When longest and obtuse expect
    .---------------------------- ~ ~ - , startPoint
    .                                      ' ,
    .                                          ,
    .                                           ,
    .                                            ,
    .                , endPoint                  ,
    .                ,                           ,
    .                 ,                         ,
    .                  ,                       ,
    .                    ,                  , ' onArc
    .                      ' - , _ _ _ ,  '
     (1 ms)
      ✓ When shortest and acute expect
    .                , endPoint
    .                ,
    .                 ,
    .                  , onArc
    .                    ,
    .______________________' - , _ _ startPoint
     (1 ms)
      ✓ When longest and acute expect
    .------------------------, - ~ ~ startPoint
    .                    , '
    .                  ,
    .                 ,
    .                ,
    .                ,                           , endPoint
    .                ,                           ,
    .                 ,                         ,
    .                  , onArc                 ,
    .                    ,                  , '
    .                      ' - , _ _ _ ,  '
    
  testing calculateIntersectionOfTwoLines
    ✓ two 45 degree angles
    ✓ horizontal and vertical line (1 ms)
    ✓ horizontal and angled line
    ✓ vertical and angled line (1 ms)
  testing offsetLine
    ✓ vertical line going up positive offset
    ✓ vertical line going up negative offset
    ✓ vertical line going down positive offset
    ✓ vertical line going down negative offset
    ✓ horizontal line going right positive offset
    ✓ horizontal line going right negative offset (1 ms)
    ✓ horizontal line going left positive offset
    ✓ horizontal line going left negative offset (1 ms)
    ✓ angled line line positive offset
    ✓ angled line line negative offset (1 ms)
  testing intersectionWithParallelLine
    ✓ 45 degree angle with offset and a vertical line
    ✓ two 45 degree angles, one offset
  testing pointToTangent
    ✓ When clockwise tangent (1 ms)
    ✓ When counterCW tangent (1 ms)
    ✓ When point is very far away from small circle, both points for clockwise and not should be close to 2*radius apart
  testing getTangentialPointOfTwoCircles
    ✓ when small to big clockwise circles where their tops are horizontal (1 ms)
    ✓ when big to small clockwise circles where their tops are horizontal (1 ms)
    ✓ when swapping the placement of the circles should mean the tangent runs along the bottom, and angle should be 180 (1 ms)
    ✓ when small to big counterCW circles where their bottoms are horizontal
    ✓ when circles of the same radius at 45deg angle
    ✓ when tangents are transverse, circles arranged such that tangent should be flat, first circle clockwise (1 ms)
    ✓ when tangents are transverse, circles arranged such that tangent should be flat, first circle counterCW (1 ms)

To run the tests yourself

yarn install
yarn test