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

ts-code-layout

v1.3.2

Published

Changes the layout of typescript files.

Downloads

28

Readme

Name

ts-code-layout: Rearranges elements in typescript code.

Synopsis

  ts-code-layout -i input-directory -o output-directory [-s] sources ...

Description

Rearranges code elements in the top level of typescript source code. The layout is specified in "ts-code-layout.json". The file is searched in the current directory. If not found, the default configuration in the installation directory is used.

Installation

  npm install ts-code-layout

Options

  -i, --input-directory string    Input-directory to read scripts from. 
  -o, --output-directory string   Output-directory to write scripts to. 
  -s, --scripts string[]          Scripts to be processed.              
  -p, --pause                     Pause before closing the app.         
  -w, --write-options             Writes options to "options.txt"

Configuration

The elements are sorted based on following traits:

  • "kind": The kind of the elements (enumeration, class, function, ...).
  • "transfer": Whether elements are exported ("export").
  • "persistance": Whether elements are constant ("const").
  • "declaration": Whether elements are declared ("declare").
  • "pattern": Whether elements matches patterns.
  • "name": Alphabetically by the name of the element.

Possible values:

  • "kind": "Header", "Import", "TypeImport", "Enumeration", "Type", "Interface", "Variable", "Class", "Function"
  • "transfer": "IsExported"
  • "persistance": "IsConstant"
  • "declaration": "IsDeclared"
  • "pattern": One or more regular expressions
  • "name": -

In all traits (except "name", which has no values) the value "null" can also be used. A value of "null" means that the values of the corresponding trait do not apply to the element.

When comparing the elements, the order in which the traits are specified in the configuration as well as the order of values in a trait is taken into account.

Example

  {
    "comparisons": 
    [
      {"kind": ["Header", "Import", "TypeImport", "Enumeration", "Type", "Interface", "Variable", "Class", "Function", null]},
      {"declaration": ["IsDeclared", null]}, 
      {"transfer": ["IsExported", null]},
      {"persistance": ["IsConstant", null]},
      {"pattern": ["const option[a-zA-Z]+ = \"[-a-zA-z]+\";", null], "ignoreIfSingleLine": false},
      {"name": [], "ignoreIfSingleLine": true}
    ]
  }

This configuration file happens to be the configuration file used for "ts-code-layout" itself.

First, the code elements are ordered by their kind according to the order of the values defined. Then they are ordered by "transfer" and "persistance". As variables, with match the given pattern, have to come before any other variables, a corresponding rule is provided under "pattern". Finally the code elements are sorted alphabetically.