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

xit-parse

v1.2.1

Published

An Xit file parser written in plain JavaScript

Downloads

47

Readme

xit-parse

A simple, plain JavaScript, program that parses Xit files. Written originally to be used in a desktop editor that I'm currently writing for desktop, web, and mobile.

It deviates just a little bit from the spec (included in this repo for convenience), but only to the extent that I find acceptable.

To use, simply add xit-parse to your package.json, then add: import * as xit from 'xit-parse' to your code. From there, you can use any of the exposed functions or constants, like so: xit.toObject(...)

There are two methods exposed:

  • toObject: Given an Xit string (assuming you have already read the file to a variable), this returns the Xit string represented as an Object.
  • toString: Given the Xit string represented as an Object, this returns the Xit as a string, that can be written to file.

There are also a number of constants exposed, whether you find them useful is up to you:

    toObject,
    toString,
    xitLineTypePatterns,
    xitItemStatusDelimiterPatterns,
    xitLineModifierPatterns,
    TITLE_TYPE,
    ITEM_TYPE,
    ITEM_LEFT_SYM,
    ITEM_RIGHT_SYM,
    ITEM_STATUS_OPEN,
    ITEM_STATUS_OPEN_SYM,
    ITEM_STATUS_CHECKED,
    ITEM_STATUS_CHECKED_SYM,
    ITEM_STATUS_ONGOING,
    ITEM_STATUS_ONGOING_SYM,
    ITEM_STATUS_OBSOLETE,
    ITEM_STATUS_OBSOLETE_SYM,
    ITEM_STATUS_IN_QUESTION,
    ITEM_STATUS_IN_QUESTION_SYM,
    ITEM_DETAILS_TYPE,
    NEWLINE_TYPE,
    PRIORITY_MOD_TYPE,
    DUE_DATE_MOD_TYPE,
    TAG_MOD_TYPE

Output Example

When toObject is called on the following *.xit file (A book reading list, as an example), you can expect the following object (stringified for your reading convenience)

The Xit file:

Books I Am Reading
[@] !!!! Lord of Chaos #jordan #fantasy -> 2023
[@] ...! Cibola Burn #scifi #corey

Books I Have Read
[x] The Tao of Pooh #philosophy

Books I Want to Read
[?] The Way of Kings #sanderson #fantasy
[~] Infinite Jest #fiction

The Output:

{
  "groups": {
    "5215f2ee-51f3-4de0-a270-8c856364bc85": [
      {
        "type": "title",
        "status": null,
        "content": "Books I Am Reading",
        "rawContent": "Books I Am Reading",
        "modifiers": null,
        "groupID": "5215f2ee-51f3-4de0-a270-8c856364bc85"
      },
      {
        "type": "item",
        "status": "ongoing",
        "content": "Lord of Chaos",
        "rawContent": "[@] !!!! Lord of Chaos #jordan #fantasy -> 2023",
        "modifiers": {
          "hasPriority": true,
          "priorityLevel": 4,
          "priorityPadding": 0,
          "due": "2023",
          "tags": [
            "#jordan",
            "#fantasy"
          ]
        },
        "groupID": "5215f2ee-51f3-4de0-a270-8c856364bc85"
      },
      {
        "type": "item",
        "status": "ongoing",
        "content": "Cibola Burn",
        "rawContent": "[@] ...! Cibola Burn #scifi #corey",
        "modifiers": {
          "hasPriority": true,
          "priorityLevel": 1,
          "priorityPadding": 3,
          "due": null,
          "tags": [
            "#scifi",
            "#corey"
          ]
        },
        "groupID": "5215f2ee-51f3-4de0-a270-8c856364bc85"
      }
    ],
    "85d6ad60-4f10-4e06-9a0c-a54f49273b84": [
      {
        "type": "title",
        "status": null,
        "content": "Books I Have Read",
        "rawContent": "Books I Have Read",
        "modifiers": null,
        "groupID": "85d6ad60-4f10-4e06-9a0c-a54f49273b84"
      },
      {
        "type": "item",
        "status": "checked",
        "content": "The Tao of Pooh",
        "rawContent": "[x] The Tao of Pooh #philosophy",
        "modifiers": {
          "hasPriority": false,
          "priorityLevel": 0,
          "priorityPadding": 0,
          "due": null,
          "tags": [
            "#philosophy"
          ]
        },
        "groupID": "85d6ad60-4f10-4e06-9a0c-a54f49273b84"
      }
    ],
    "38b122df-1da5-4958-8853-76a17f5ea01e": [
      {
        "type": "title",
        "status": null,
        "content": "Books I Want to Read",
        "rawContent": "Books I Want to Read",
        "modifiers": null,
        "groupID": "38b122df-1da5-4958-8853-76a17f5ea01e"
      },
      {
        "type": "item",
        "status": "in-question",
        "content": "The Way of Kings",
        "rawContent": "[?] The Way of Kings #sanderson #fantasy",
        "modifiers": {
          "hasPriority": false,
          "priorityLevel": 0,
          "priorityPadding": 0,
          "due": null,
          "tags": [
            "#sanderson",
            "#fantasy"
          ]
        },
        "groupID": "38b122df-1da5-4958-8853-76a17f5ea01e"
      },
      {
        "type": "item",
        "status": "obsolete",
        "content": "Infinite Jest",
        "rawContent": "[~] Infinite Jest #fiction",
        "modifiers": {
          "hasPriority": false,
          "priorityLevel": 0,
          "priorityPadding": 0,
          "due": null,
          "tags": [
            "#fiction"
          ]
        },
        "groupID": "38b122df-1da5-4958-8853-76a17f5ea01e"
      }
    ]
  }
}