src/JokerDMAPI.js
function parse_domain (line) {
		debug.assert(line).is('string');

		// -S-G-J ==> "tili-lii.fi 2017-06-02"
		// +S-G-J ==> "tili-lii.fi 2017-06-02 lock"
		// +S+G-J ==> "tili-lii.fi 2017-06-02 lock @creator true 0 undef"
		// -S+G-J ==> "tili-lii.fi 2017-06-02 @creator true 0 undef"
		// -S-G+J ==> "tili-lii.fi 2017-06-02 0"
		// +S+G+J ==> "tili-lii.fi 2017-06-02 lock @creator true 0 undef 0"

		//debug.log('line = "' + line + '"');

		var tmp = line.split(' ');

		//debug.log('tmp = ', tmp);

		var domain = tmp.shift();
		var exp_date = tmp.shift();

		var obj = {
			'domain': domain,
			'expiration': exp_date
		};

		debug.assert(obj.domain).is('string');
		debug.assert(obj.expiration).is('string');

		if (showstatus) {
			obj.status = tmp.shift().split(',');
			debug.assert(obj.status).is('array');
		}

		if (showjokerns) {
			obj.jokerns = parse_jokerns(tmp.pop());
			debug.assert(obj.jokerns).is('boolean');
		}

		if (showgrants) {
			obj.grants = tmp.join(' ');
			debug.assert(obj.grants).is('string');
		}

		if (tmp.length !== 0) {
			throw new TypeError("Failed to parse everything: " + tmp.join(','));
		}

		//debug.log("obj = ", obj);
		return obj;
	}
function parse_domain (line) {
		debug.assert(line).is('string');

		// -S-G-J ==> "tili-lii.fi 2017-06-02"
		// +S-G-J ==> "tili-lii.fi 2017-06-02 lock"
		// +S+G-J ==> "tili-lii.fi 2017-06-02 lock @creator true 0 undef"
		// -S+G-J ==> "tili-lii.fi 2017-06-02 @creator true 0 undef"
		// -S-G+J ==> "tili-lii.fi 2017-06-02 0"
		// +S+G+J ==> "tili-lii.fi 2017-06-02 lock @creator true 0 undef 0"

		//debug.log('line = "' + line + '"');

		var tmp = line.split(' ');

		//debug.log('tmp = ', tmp);

		var domain = tmp.shift();
		var exp_date = tmp.shift();

		var obj = {
			'domain': domain,
			'expiration': exp_date
		};

		debug.assert(obj.domain).is('string');
		debug.assert(obj.expiration).is('string');

		if (showstatus) {
			obj.status = tmp.shift().split(',');
			debug.assert(obj.status).is('array');
		}

		if (showjokerns) {
			obj.jokerns = parse_jokerns(tmp.pop());
			debug.assert(obj.jokerns).is('boolean');
		}

		if (showgrants) {
			obj.grants = tmp.join(' ');
			debug.assert(obj.grants).is('string');
		}

		if (tmp.length !== 0) {
			throw new TypeError("Failed to parse everything: " + tmp.join(','));
		}

		//debug.log("obj = ", obj);
		return obj;
	}
function parse_domain ( line ) { debug . assert ( line ) . is ( 'string' ) ; // -S-G-J ==> "tili-lii.fi 2017-06-02" // +S-G-J ==> "tili-lii.fi 2017-06-02 lock" // +S+G-J ==> "tili-lii.fi 2017-06-02 lock @creator true 0 undef" // -S+G-J ==> "tili-lii.fi 2017-06-02 @creator true 0 undef" // -S-G+J ==> "tili-lii.fi 2017-06-02 0" // +S+G+J ==> "tili-lii.fi 2017-06-02 lock @creator true 0 undef 0" //debug.log('line = "' + line + '"'); var tmp = line . split ( ' ' ) ; //debug.log('tmp = ', tmp); var domain = tmp . shift ( ) ; var exp_date = tmp . shift ( ) ; var obj = { 'domain' : domain , 'expiration' : exp_date } ; debug . assert ( obj . domain ) . is ( 'string' ) ; debug . assert ( obj . expiration ) . is ( 'string' ) ; if ( showstatus ) { obj . status = tmp . shift ( ) . split ( ',' ) ; debug . assert ( obj . status ) . is ( 'array' ) ; } if ( showjokerns ) { obj . jokerns = parse_jokerns ( tmp . pop ( ) ) ; debug . assert ( obj . jokerns ) . is ( 'boolean' ) ; } if ( showgrants ) { obj . grants = tmp . join ( ' ' ) ; debug . assert ( obj . grants ) . is ( 'string' ) ; } if ( tmp . length !== 0 ) { throw new TypeError ( "Failed to parse everything: " + tmp . join ( ',' ) ) ; } //debug.log("obj = ", obj); return obj ; }
Parse single line
Parse single line