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

@tracespace/identify-layers

v5.0.0-alpha.0

Published

Try to guess Gerber files' layer types based on filenames.

Downloads

5,040

Readme

@tracespace/identify-layers

npm

Try to guess Gerber files' layer types based on filenames. Part of the tracespace collection of PCB visualization tools.

This module is one part of the tracespace render pipeline, and you may not need to use it directly. See @tracespace/core to integrate the full render pipeline into your project.

npm install @tracespace/identify-layers

usage

Pass identifyLayers an array of filenames from a PCB, and it will give you back an object keyed by filename with the best guess it can make for the type and side of each file. If both side and type are null, the filename cannot be identified as a Gerber / drill file.

import {identifyLayers} from '@tracespace/identify-layers'

const filenames = ['my-board-F_Cu.gbr', 'my-board-B_Cu.gbr', 'foo.bar']
const typeByFilename = identifyLayers(filenames)
// {
//   'my-board-F_Cu.gbr': {type: 'copper', side: 'top'},
//   'my-board-B_Cu.gbr': {type: 'copper', side: 'bottom'},
//   'my-board-notes.gbr': {type: 'drawing', side: null},
//   'foo.bar': {type: null, side: null},
// }

layer types and names

There are 12 available layer types, were a type is an object of the format:

{
  side: 'top' | 'bottom' | 'inner' | 'all' | null,
  type: 'copper' | 'soldermask' | 'silkscreen' | 'solderpaste' | 'drill' | 'outline' | 'drawing' | null,
}

You can get an array of all types with:

import {getAllLayers} from '@tracespace/identify-layers'

const allLayers = getAllLayers()

| side | type | | ---------- | --------------- | | 'top' | 'copper' | | 'top' | 'soldermask' | | 'top' | 'silkscreen' | | 'top' | 'solderpaste' | | 'bottom' | 'copper' | | 'bottom' | 'soldermask' | | 'bottom' | 'silkscreen' | | 'bottom' | 'solderpaste' | | 'inner' | 'copper' | | 'all' | 'outline' | | 'all' | 'drill' | | null | 'drawing' |

constants

Side and type constants are exported for your usage:

import {
  // layer types
  TYPE_COPPER, // 'copper'
  TYPE_SOLDERMASK, // 'soldermask'
  TYPE_SILKSCREEN, // 'silkscreen'
  TYPE_SOLDERPASTE, // 'solderpaste'
  TYPE_DRILL, // 'drill'
  TYPE_OUTLINE, // 'outline'
  TYPE_DRAWING, // 'drawing'

  // board sides
  SIDE_TOP, // 'top'
  SIDE_BOTTOM, // 'bottom'
  SIDE_INNER, // 'inner'
  SIDE_ALL, // 'all'
} from '@tracespace/identify-layers'

checking if a layer type is valid

You can check if any given string is a valid layer type with:

import {validate} from '@tracespace/identify-layers'

const type1 = {side: 'top', type: 'copper'}
const type2 = {side: 'foo', type: 'silkscreen'}
const type3 = {side: 'bottom', type: 'bar'}

console.log(validate(type1)) // {valid: true, side: 'top', type: 'copper'}
console.log(validate(type2)) // {valid: false, side: null, type: 'silkscreen'}
console.log(validate(type3)) // {valid: false, side: 'bottom', type: null}

supported cad programs

We should be able to identify files output by the following programs:

  • KiCad
  • Eagle
  • Altium
  • Orcad
  • gEDA PCB
  • DipTrace

contributing

Please read the Contributing Guide for development setup instructions.

If you're adding or modifying a filetype matcher, please remember to add or modify an example filename in @tracespace/fixtures/gerber-filenames.json to ensure your change is tested.