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

exam-cc

v3.0.0

Published

Exam console collection

Downloads

235

Readme

exam-cc

EXAM Cheet Commands package for Hungarian 'OKJ' software developer exam

Install (using npm)

npm i exam-cc --save

Usage

const cc = require('exam-cc')

Most important functions

read

read(filename[,col_sep,elines,header_arr,bof,row_sep,char_set])

Read data (comma separated values) from text files (.csv or .txt) into an array of objects

var ot = cc.read('input.txt',';',1,['id','property','value'])
Return value: exam-cc Array
Parameters
  1. filename | String
    • Path to location and filename
  2. col_sep | String | optional
    • Column (attribute) separator
      • usually in a csv file it is ',' or ';'
      • in txt file it is ' ' (space) or ('\t') tabulator
  3. elines | Number | optional
    • Empty (or cuttable) rows on end of file
  4. header_arr | Array | optional
    • Custom header/attribute names
      • if the file not contain, is needed
  5. bof | Number | optional
    • Empty rows on begin of file
  6. row_sep | String | optional
    • Row (line-end, record) separator
      • in windows file is '\r\n'
      • in linux file is '\n'
      • default value is '\n'
  7. char_set | String | optional
    • default value is 'UTF-8'

write

write( filename, content [, sep1, sep2] )

Wrte array of objects into a comma separated text file

var ot = cc.write('input.txt', content, '\r\n', ',')
Parameters (write)
  1. filename | String
    • Path to location and filename.
  2. content | Array of Objects
  3. sep1 | String | optional
    • Row (line-end, record) separator.
      • in windows file is '\r\n'
      • in linux file is '\n'
      • default value is '\n'
  4. sep2 | String | optional
    • Column (attribute) separator.
      • n csv file is ',' or ';'
      • in txt file is ' ' (space) or ('\t') tabulator
  5. custom header/attribute names - under construction

initsql

initsql(db,content,tablename,host,user,pwd)

Initialise MySQL, create a MySQL table and insert all element of object array to the MySQL table

cc.initsql('mydb',array_of_objects,'test_table')
...
cc.sql.end()

or if table aredy exists:

cc.initsql('mydb')
...
cc.sql.end()
Parameters (initsql)
  1. db | String
    • Database name
    • default value is 'vizsga'
  2. content | Array of Objects
  3. tablename | String
    • Name of the data table in MySQL
    • default value is 'default'
  4. host | String
    • MySQL Host URL
    • default value is 'localhost'
  5. user | String
    • MySQL Username
    • default value is 'root'
  6. pwd | String
    • MySQL password
    • default value is '' (empty String)

query

query(sql)

Run SQL Query and return an array of objects from results

let answ = cc.query('SELECT * FROM teszt')[0].szerzo
Parameter (query)
  1. query | String
    • The Query string in MySQL language

input

input(text)

Get an input from console to a value

name=cc.input('Tell a name!')

print( value <or a list of value> )

cc.print("I found:",cc.find(t,'Name',name).age)

Array

let ta=new cc.Array({a:1, b:3},{a:2, b:2},{a:4, b:3})
let m=ta.toMap('a')
console.log(m)

Map

let t1 = [
    {id: 1, name:'cica', lsz: 4},
    {id: 2, name:'cirmoscica', lsz: 3},
    {id: 4, name:'kisvakond', lsz: 4}
]
const m=new cc.Map(t1,'id')

console.log( m.toArray('cica') )
const cc=require('exam-cc')
let t1 = new cc.Map([{a:1, b:3},{a:2, b:2},{a:4, b:3}],'a')
let t2 = new cc.Map([{a:1, c:2},{a:2, c:4},{a:3, c:1}],'a')
console.log(t1.union(t2))
const cc=require('exam-cc')
let t1 = new cc.Map([{a:1, b:3},{a:2, b:2},{a:4, b:3}],'a')
let t2 = new cc.Map([{a:1, b:2},{a:2, b:4},{a:3, b:1}],'a')
console.log( t1.union( t2, ( a, b ) => a + b ) )

Examples

cc = require('exam-cc')
t = cc.read('users.txt')
console.log(cc.sort(t,'Name'))
betu=cc.input('Tell a name!')
cc.print("I found:",cc.find(t,'Name',name).age)

const cc = require('exam-cc')
const text = cc.read('input.txt',';',1,['name','age'])
cc.initsql('exam',text,'test')
const name = cc.input('Please give a name!')
cc.print( cc.query(`
                SELECT *
                FROM test
                WHERE name like '%${name}%'
                ORDER BY age
            `)
            .map( v => v.name + ': '+ v.age)
            .join( cc.EOL )
)
cc.sql
  .end()

Colors in console (console.log)

(cyan, red, white, green, blue, light, black, yellow)

const cc = require('exam-cc')
console.log(cc.yellow,'Sárga')

Other functions

find( array, attribute, condition )

Parameters (find)
  1. array | Array of Objects
  2. attribute | String
  3. condition | String
  4. exact | Boolean

filter( array, attribute, condition )

Parameters (filter)
  1. array | Array of Objects
  2. attribute | String
  3. condition | String
  4. exact | Boolean

sort( array, attribute )

sorting

Parameters (sort)
  1. array | Array of Objects
  2. attribute | String

rsort( array, attribute )

reverse sorting

Parameters (rsort)
  1. array | Array of Objects
  2. attribute | String

max( array, attribute )

find minimum value

Parameters (max)
  1. array | Array of Objects
  2. attribute | String

min( array, attribute )

find maximum value

Parameters (min)
  1. array | Array of Objects
  2. attribute | String