From 8227ee6a9ba3daef2e96c9b4ddb7914f637194e6 Mon Sep 17 00:00:00 2001 From: James Swift Date: Sun, 26 Jun 2016 00:11:59 +0100 Subject: [PATCH] Name change --- README.md | 10 ++++----- index.js | 20 +++++++++--------- lib/conf.js | 30 +++++++++++++------------- lib/decode.js | 54 +++++++++++++++++++++++------------------------ lib/encode.js | 58 +++++++++++++++++++++++++-------------------------- lib/error.js | 26 +++++++++++------------ lib/util.js | 14 ++++++------- package.json | 8 +++---- test/index.js | 4 ++-- 9 files changed, 112 insertions(+), 112 deletions(-) diff --git a/README.md b/README.md index 56022c0..3965020 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,21 @@ Swift-Cardinal Object Notation (SCON) A minimal node module allowing the reading and writing of data in the SCON format. The SCON format, created by Aritz J Beobide-Cardinal (ARitz Cracker) and James R Swift, is an extendable binary file format that was created to store data more efficiantly than the popular JSON standard. -Get the module here [![npm version](https://badge.fury.io/js/sbtag.svg)](https://badge.fury.io/js/sbtag) +Get the module here [![npm version](https://badge.fury.io/js/scon.svg)](https://badge.fury.io/js/scon) ## Installation ```shell -npm install sbtag --save +npm install scon --save ``` ## Usage ```js -var sbtag = require('sbtag'); +var scon = require('scon'); -var encoded = sbtag.encode( { hello: "world!", five: 5 } ).result; -var decoded = sbtag.decode( encoded ).result; +var encoded = scon.encode( { hello: "world!", five: 5 } ).result; +var decoded = scon.decode( encoded ).result; ``` ## Contributing diff --git a/index.js b/index.js index 3ab1774..49a10c9 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ /** * Swift Binary Tag - * https://github.com/JamesxX/sbtag + * https://github.com/JamesxX/scon * * Copyright (c) Aritz Beobide-Cardinal, 2016 James R Swift * Licensed under the GNU GPLv3 license. @@ -10,20 +10,20 @@ var Buffer = require('buffer').Buffer; -var sbtag = {} -var sbtagUtil = require( "./lib/util.js" ); +var scon = {} +var sconUtil = require( "./lib/util.js" ); -sbtagUtil.loadSubmodule( sbtag, "lib/conf.js" ); -sbtagUtil.loadSubmodule( sbtag, "lib/error.js" ); -sbtagUtil.loadSubmodule( sbtag, "lib/encode.js" ); -sbtagUtil.loadSubmodule( sbtag, "lib/decode.js" ); +sconUtil.loadSubmodule( scon, "lib/conf.js" ); +sconUtil.loadSubmodule( scon, "lib/error.js" ); +sconUtil.loadSubmodule( scon, "lib/encode.js" ); +sconUtil.loadSubmodule( scon, "lib/decode.js" ); if ( true ){ - var encoded = sbtag.encode( { hello: "world!!", hi: "bye", five: 5, pi: 3.14159, object:{amazing:true,true:{"mind":"fuck"}}, six: 6 ,arr:["wan","too","free",{"for":4},[1,2,3,4,5]]}); + var encoded = scon.encode( { hello: "world!!", hi: "bye", five: 5, pi: 3.14159, object:{amazing:true,true:{"mind":"fuck"}}, six: 6 ,arr:["wan","too","free",{"for":4},[1,2,3,4,5]]}); console.log( "encoded:", encoded ); - var decoded = sbtag.decode( encoded.result ); + var decoded = scon.decode( encoded.result ); console.log( "decoded:", JSON.stringify(decoded)); } -module.exports = sbtag; +module.exports = scon; diff --git a/lib/conf.js b/lib/conf.js index 4871365..3b3de2b 100644 --- a/lib/conf.js +++ b/lib/conf.js @@ -1,6 +1,6 @@ /** * Swift Binary Tag - * https://github.com/JamesxX/sbtag + * https://github.com/JamesxX/scon * * Copyright (c) Aritz Beobide-Cardinal, 2016 James R Swift * Licensed under the GNU GPLv3 license. @@ -8,20 +8,20 @@ "use strict"; -var sbtagConf = {} +var sconConf = {} -sbtagConf.magicNumber = "sbtag" -sbtagConf.bufferSize = 50 * 1024 // 50kb +sconConf.magicNumber = "scon" +sconConf.bufferSize = 50 * 1024 // 50kb -sbtagConf.endBlock = 0; -sbtagConf.int32 = 1; -sbtagConf.float32 = 2; -sbtagConf.string = 3; -sbtagConf.compound = 4; -sbtagConf.array = 5; -sbtagConf.null = 6; -sbtagConf.undefined = 7; -sbtagConf.boolean = 8; -sbtagConf.reserved = 255; +sconConf.endBlock = 0; +sconConf.int32 = 1; +sconConf.float32 = 2; +sconConf.string = 3; +sconConf.compound = 4; +sconConf.array = 5; +sconConf.null = 6; +sconConf.undefined = 7; +sconConf.boolean = 8; +sconConf.reserved = 255; -module.exports = sbtagConf; +module.exports = sconConf; diff --git a/lib/decode.js b/lib/decode.js index 47e2cff..cd90df2 100644 --- a/lib/decode.js +++ b/lib/decode.js @@ -1,6 +1,6 @@ /** * Swift Binary Tag - * https://github.com/JamesxX/sbtag + * https://github.com/JamesxX/scon * * Copyright (c) Aritz Beobide-Cardinal, 2016 James R Swift * Licensed under the GNU GPLv3 license. @@ -8,69 +8,69 @@ "use strict"; -var sbtag = {}; -var sbtagUtil = require( "./util.js" ); +var scon = {}; +var sconUtil = require( "./util.js" ); -sbtagUtil.loadSubmodule( sbtag, "lib/conf.js" ); -sbtagUtil.loadSubmodule( sbtag, "lib/error.js" ); +sconUtil.loadSubmodule( scon, "lib/conf.js" ); +sconUtil.loadSubmodule( scon, "lib/error.js" ); -sbtag.decodeValue = function(buf,type,_offset){ +scon.decodeValue = function(buf,type,_offset){ var result; switch( type ){ // int32 - case sbtag.int32: + case scon.int32: result = buf.readInt32BE(_offset); _offset += 4; break; // float32 - case sbtag.float32: + case scon.float32: result = buf.readFloatBE(_offset); _offset += 4; break; // string - case sbtag.string: + case scon.string: var varLength = buf.readUInt32BE(_offset); _offset += 4; result = buf.toString(null, _offset, _offset + varLength); _offset += varLength; break; // compound - case sbtag.compound: - var compound = sbtag.decode( buf, false, _offset ); + case scon.compound: + var compound = scon.decode( buf, false, _offset ); result = compound.result; _offset = compound.offset; break; - case sbtag.array: + case scon.array: result = []; var len = buf.readUInt32BE(_offset); _offset += 4; for (var i=0;i= 0){ var type = buf.readUInt8(_offset); _offset += 1; - if (type==sbtag.endBlock){ + if (type==scon.endBlock){ //_offset += 1; return { result: result, offset: _offset }; @@ -107,7 +107,7 @@ sbtag.decode = function ( string, verify, offset ){ var nameLength = buf.readUInt16BE(_offset); _offset += 2; var name = buf.toString(null, _offset, _offset + nameLength); _offset += nameLength; - var a = sbtag.decodeValue(buf,type,_offset) + var a = scon.decodeValue(buf,type,_offset) result[ name ] = a[0]; _offset = a[1]; @@ -119,4 +119,4 @@ sbtag.decode = function ( string, verify, offset ){ } -module.exports = sbtag; +module.exports = scon; diff --git a/lib/encode.js b/lib/encode.js index 022eaa6..3d891a8 100644 --- a/lib/encode.js +++ b/lib/encode.js @@ -1,6 +1,6 @@ /** * Swift Binary Tag - * https://github.com/JamesxX/sbtag + * https://github.com/JamesxX/scon * * Copyright (c) Aritz Beobide-Cardinal, 2016 James R Swift * Licensed under the GNU GPLv3 license. @@ -8,13 +8,13 @@ "use strict"; -var sbtag = {}; -var sbtagUtil = require( "./util.js" ); +var scon = {}; +var sconUtil = require( "./util.js" ); -sbtagUtil.loadSubmodule( sbtag, "lib/conf.js" ); -sbtagUtil.loadSubmodule( sbtag, "lib/error.js" ); +sconUtil.loadSubmodule( scon, "lib/conf.js" ); +sconUtil.loadSubmodule( scon, "lib/error.js" ); -sbtag.writeKey = function(buf,key,offset){ +scon.writeKey = function(buf,key,offset){ if (key!=null){ @@ -27,7 +27,7 @@ sbtag.writeKey = function(buf,key,offset){ return offset; } -sbtag.writeValue = function(buf,key,value,offset){ +scon.writeValue = function(buf,key,value,offset){ switch( typeof value ){ @@ -36,15 +36,15 @@ sbtag.writeValue = function(buf,key,value,offset){ // Integer if ( value % 1 === 0 ){ - buf.writeUInt8( sbtag.int32, offset ); offset += 1; - offset = sbtag.writeKey(buf,key,offset); + buf.writeUInt8( scon.int32, offset ); offset += 1; + offset = scon.writeKey(buf,key,offset); buf.writeInt32BE( value, offset ); offset += 4; // Float } else { - buf.writeUInt8( sbtag.float32, offset ); offset += 1; - offset = sbtag.writeKey(buf,key,offset); + buf.writeUInt8( scon.float32, offset ); offset += 1; + offset = scon.writeKey(buf,key,offset); buf.writeFloatBE( value, offset ); offset += 4; } @@ -52,8 +52,8 @@ sbtag.writeValue = function(buf,key,value,offset){ break; case "string": - buf.writeUInt8( sbtag.string, offset ); offset += 1; - offset = sbtag.writeKey(buf,key,offset); + buf.writeUInt8( scon.string, offset ); offset += 1; + offset = scon.writeKey(buf,key,offset); buf.writeUInt32BE( value.length, offset ); offset += 4; buf.write( value, offset ); offset += value.length; break; @@ -62,35 +62,35 @@ sbtag.writeValue = function(buf,key,value,offset){ if (Array.isArray(value)){ - buf.writeUInt8( sbtag.array, offset ); offset += 1; - offset = sbtag.writeKey(buf,key,offset); + buf.writeUInt8( scon.array, offset ); offset += 1; + offset = scon.writeKey(buf,key,offset); buf.writeUInt32BE( value.length, offset ); offset += 4; for (var i=0;i", "license": "GPL-3.0", "bugs": { - "url": "https://github.com/JamesxX/sbtag/issues" + "url": "https://github.com/JamesxX/scon/issues" }, - "homepage": "https://github.com/JamesxX/sbtag#readme", + "homepage": "https://github.com/JamesxX/scon#readme", "devDependencies": { "chai": "^3.5.0", "mocha": "^2.5.3" diff --git a/test/index.js b/test/index.js index 9f89c34..6137a9c 100644 --- a/test/index.js +++ b/test/index.js @@ -1,10 +1,10 @@ var expect = require('chai').expect; -var sbtag = require('../index.js'); +var scon = require('../index.js'); describe("Swift Binary Tag file format", function() { it("should write the magic number", function(){ - expect(sbtag.encode( {} ).result.substring( 0, sbtag.magicNumber.length ) ).to.equal( sbtag.magicNumber ); + expect(scon.encode( {} ).result.substring( 0, scon.magicNumber.length ) ).to.equal( scon.magicNumber ); }) });