nl_tokens: Create a table | a json file The second argument is optional if ommitted the file will be created at the default location .
pl_tokens: function createTable ( ) { tableName = arguments [ 0 ] ; var fname = '' ; var callback ; if ( arguments . length === 2 ) { callback = arguments [ 1 ] ; fname = path . join ( userData , tableName + '.json' ) ; } else if ( arguments . length === 3 ) { fname = path . <mask> ( arguments [ 1 ] , arguments [ 0 ] + '.json' ) ; callback = arguments [ 2 ] ; } // Check if the file with the tablename.json exists let exists = fs . existsSync ( fname ) ; if ( exists ) { // The file exists, do not recreate the table/json file callback ( false , tableName + '.json already exists!' ) ; return ; } else { // Create an empty object and pass an empty array as value let obj = new Object ( ) ; obj [ tableName ] = [ ] ; // Write the object to json file try { fs . writeFileSync ( fname , JSON . stringify ( obj , null , 2 ) , ( err ) => { } ) callback ( true , "Success!" ) return ; } catch ( e ) { callback ( false , e . toString ( ) ) ; return ; } } }