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

lkon

v5.1.5

Published

LKON is type of Object Notation implemented as an open-source library for JS.

Downloads

14

Readme

About project...

LKON Parser was created to deliever brand new configuration language called Language for Konfiguration Object Notation to your Node.JS project. Current version of newer stringifier does not support variables and imports yet!

LKON


Highlighting

Are you bored and tired of looking at LKON Syntax in the only one color? Well, we have something special for you. Thanks to my friend (yobonez) we now have special VSC addon with highlighter for LKON files. The only thing you have to do is download it in VSC marketplace:

  • Name of addon: LKON Syntax Hightlighting
  • GitHub

What's new?

Version 5.1.5: Parser:

  • parses numbers including "_" from now;
  • parsing variables is now fixed; Stringifier:
  • stringifies boolean values properly from now;

LKON Supports these types of data:

  • Files - "./path/to/file"encoding;
  • RegExps - /your_expression_here/flags;
  • String - "string";
  • Date - "01-01-1970, 0:00:00.000"date
  • undefined - Undefined;
  • Boolean - True or False;
  • null - Null;
  • Number - (every kind of notation!) 0x0001, 1, 1e+21, .1, -1, or Infinity;
  • NaN - NaN;
  • Numeric Array:
[
	@* => value;
];
  • Associative Array:
[
	@key => value;
];

Remember

  • Before you use it, you need to init this using require("lkon")({allowGlobal: true|false, allowRequire: true|false});
    • If you set allowGlobal to true, LKON global object will be created.
    • If you set allowRequire to true, you will be able to read files with ".lkon" extension using require method, e.g. require("./path/to/file.lkon").
  • Variables & Imports can be set before [, in a header of the file;
    • Import instruction examples:
      1. With destructuring: import "./path/to/file.lkon"utf8 as [ key=>alias; ];;
      2. Without destructuring: import "./path/to/file.lkon"utf8 as key;;
    • Use instruction examples:
      1. With destructuring use [ @hello => "world"; ] as [ hello=>alias ];
      2. Without destructuring: use "01-01-1970, 0:00:00.000"date as start;;
  • Single-line comments must be followed by #;
  • Multi-line comments must begin and be followed by ''' (three apostrophes);
  • Every line/expression of LKON Code must end with [, or ;;
  • Object keys must begin with @;
  • * (asterisk) mean numeric index, if first property of object has a * key, the object is set to an array;
  • An assignment mark is =>;
  • True, False, Undefined, NaN and Null are cases sensitive and must be started by upper case letter;
  • Every string is multi-line, and template string. To put variables into string, you just need to put your variable into [] square brackets, e.g. @string => "Hello, [users.0.username]";, @string => "Hello, [Main.users.0.username]";;
  • Main keyword is a reference to the global variable of the main object of file.

Examples of using

Using this module is very simple:

const lkon = require('lkon')();

lkon.parse(
`
use "v3.0.0" as version;
use [
	@privateKey => "./private.key"bin;
	@publicKey => "./public.key"bin;
] as keys;
import "./database.lkon"utf8 as [
	host => dbHost;
	port => dbPort;
];


[
  @version => version;
  @admin => [
    @username => "root";
    @password => "Q@wertyuiop";
  ];
  @keys => keys;
  @greeting => "Hello, [Main.admin.username]! The server is running on [dbHost]:[dbPort], its version is [version]."
  @database => [
    @host => dbHost;
    @port => dbPort;
    @username => Main.admin.username;
    @password => Main.admin.password;
  ];
  @localhostDirectory => "./views";
  @maxPasswordLength => 128;
  @passwordRegex => /[^a-zA-Z0-9\!@#$%\^&\*\(\)\{\}\[\];"'\/\\\.,]/g;
];
`
)
/* Expecting:
	{
		version: "v2.0.0",
		admin: {
			username: "root",
			password: "Q@wertyuiop"
		},
		keys: {
			public: <Buffer A7 B2 C7 ...>,
			private: <Buffer C3 A1 B8 ...>
		},
		greeting: "Hello, root! The server is running on 127.0.0.1:80, its version is v2.0.0.",
		database: {
			host: "127.0.0.1",
			port: 80,
			username: "root",
			password: "Q@wertyuiop"
		},
		localhostDirectory: "./views",
		maxPasswordLength: 128,
		passwordRegex: /[^a-zA-Z0-9\!@#$%\^&\*\(\)\{\}\[\];"'\/\\\.,]/g
	}
*/

lkon.stringify(
	[
		{
			username: "JohnDoe",
			age: 24,
			email: "[email protected]",
			password: "password",
			favRegexp: /[abc]+/
		},
		{
			username: "FooBar",
			age: 20,
			email: "[email protected]",
			password: "password",
			favRegexp: /[def]+/
		},
		{
			username: "CatSamson",
			age: 21,
			email: "[email protected]",
			password: "password",
			favRegexp: /[ghi]+/
		}
	],
	null,
	'\t'
)
/*Expecting:
	[
		@* => [
			@username => "JohnDoe";
			@age => 24;
			@email => "[email protected]";
			@password => "password";
			@favRegexp => /[abc]+/;
		];
		@* => [
			@username => "FooBar";
			@age => 20;
			@email => "[email protected]";
			@password => "password";
			@favRegexp => /[def]+/;
		];
		@* => [
			@username => "CatSamson";
			@age => 21;
			@email => "[email protected]";
			@password => "password";
			@favRegexp => /[ghi]+/;
		];
	];
*/