Coder Social home page Coder Social logo

consolas's Introduction

Welcome to ConsolAS - the library with the missing `console` methods for Google Apps Script ๐Ÿ‘‹

Version License: MIT

Adds useful Console methods to Google Apps Script

Getting Started

ConsolAS can be used as a native Apps Script library, as an NPM module or simply copied and pasted into your code.

As a Native Google Apps Script Library

Import the following script ID as a library into your Google Apps Script project:

18Wk4wG7DGRGvy39zZbWhkU37z6ytqW06QkSwUlZHlIClQXHmCtEFucvD

Initiate ConsoleAS:

const cx = ConsolAS.init();

As an NPM module

Install by running:

npm i @wildhog/consolas

Import and initiate ConsolAS:

import { ConsolAS } from '@wildhog/consolas';
const cx = new ConsolAS();

By Copying and Pasting the Code from the dist/copy-paste/consolas.js File

The IIFE in the dist/copy-paste/consolas.js returns a class and stores it in the ConsolAS variable. Hence you only need to initiate the said class:

const cx = new ConsolAS();

API

ConsolAS works with two-dimensional arrays and objects.

Example 1:

cx.table([
  ['Name', 'Profession'],
  ['John Doe', 'Developer'],
  ['Jane Doe', 'Designer'],
  ['Jim Doe', 'Artist'],
]);

This prints out:

| (index) | 0        | 1          |
| ------- | -------- | ---------- |
| 0       | Name     | Profession |
| 1       | John Doe | Developer  |
| 2       | Jane Doe | Designer   |
| 3       | Jim Doe  | Artist     |

Example 2:

cx.table({
  name: 'John Doe',
  profession: 'Developer',
  age: 30,
  city: 'Anytown',
});

This prints out:

| (index)    | Value     |
| ---------- | --------- |
| name       | John Doe  |
| profession | Developer |
| age        | 30        |
| city       | Anytown   |

Example 3:

cx.table([
  {
    name: 'Alice',
    age: 30,
  },
  {
    name: 'Bob',
    age: 25,
  },
  {
    name: 'Charlie',
    age: 35,
  },
  {
    name: 'Diana',
    age: 28,
  },
]);

This prints out:

| (index) | name    | age |
| ------- | ------- | --- |
| 0       | Alice   | 30  |
| 1       | Bob     | 25  |
| 2       | Charlie | 35  |
| 3       | Diana   | 28  |

Supported Methods

Currently only the table(TwoDimArray|Object) method works. Other methods will follow soon. Check CONTRIBUTING if you are interest in implementing them.

Run tests

npm t

See Also

Author

Show your support

Give a โญ๏ธ if this project helped you!


This README was generated with โค๏ธ by readme-md-generator

consolas's People

Contributors

wildh0g avatar

Stargazers

Sirvent avatar ANAND KUMAR JHA avatar Mike Downes avatar Jes Hunsballe avatar mark05E avatar  avatar Max Makhrov avatar

Watchers

 avatar

Forkers

brew-guy

consolas's Issues

TypeError: ConsolAS is not a constructor

I can't get the example to work with the copy-paste minified script from dist in Google Apps Script. It works if I change first line to var d = (function (d) { and create the cx instance with const cx = new d.ConsolAS();. What am I doing wrong?

Implement the `assert(condition, message)` method

Is your feature request related to a problem? Please describe.
Must return the specified error message or object when the condition is false

Describe the solution you'd like
A clear and concise description of what you want to happen.

Additional context
Use W3Schools (or similar) as a startiing point.

Implementing array of objects

How about adding recognition of tables provided in the format of array of objects:

data = [
{ id: 1,
first_name: 'Johan',
last_name: 'McMenamy',
email: '[email protected]',
gender: 'Male',
ip_address: '41.114.226.125' },
{ id: 2,
first_name: 'Kevyn',
last_name: 'Pedder',
email: '[email protected]',
gender: 'Female',
ip_address: '66.97.60.249' }
]

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.