Giter Club home page Giter Club logo

globfile's Introduction

globfile

the .env alternative for changeable global variables!

install

npm i globfile --save

file structure

the file should be structured as such:

IDENTIFIER: "VALUE" # create a key-value pair, the key being named IDENTIFIER with the sting value of VALUE

# and yes, comments really do exist in globfile
             # same with unnecessary whitespace!

the rules

  • only one tab or space is required when declaring new key-value pairs

    • that means there should only be one space or tab
    • the spaces/tabs before the key do not matter
    • this, obviously, does not go for comments
  • values should be put in quotes, will always return a string

    • if it is not enclosed in quotes (eg. "x") you will get an error
  • duplicate keys are NOT looked for, and you will NOT be warned of them

    • instead, whatever is first of the keys will be the return value
  • key-value pairs on the same line is allowed but not reccomended

example

// Require globfile
const globfile = require('globfile');

// Setup options before initialization
// (^ Options chosen are default, this is just for demonstration pourposes)
globfile.options.globalFile = '.global';
globfile.options.nameConvention = true;

// DO NOT CHANGE options.tokens OR options.initialized

// Lex the globalFile provided in options
globfile.init();

// Search for key in object and log it
globfile.find('HI', (data) => {
    console.log(data);
});

// Append and re-initialize
globfile.append('HELLO', 'How are you?', (data, err) => {
    if(err)
        console.log(data, err);

    console.log(data);
});

features

  • find variables
  • append to global file
  • easy to use
  • json alternative :>

documentation

functions

globfile#init() lex the global file, this is required for globfile to work
globfile#find() find a value in the tokens based off a key, will always return as string
globfile#append() append to the global file (starts with newline)

options

globalFile '' the file to use for globfile to work
nameConvention ? capitalize all letters in keys when you append
tokens [] the tokens to use while finding with globfile, do not edit (unless you need to debug)
initialized ? used to check if globfile is initialized, do not edit (unless you need to debug)

globfile's People

Contributors

asciidude avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.