🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

fudi

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fudi - npm Package Compare versions

Comparing version
0.0.1
to
0.0.2
+9
-45
fudi.js

@@ -136,2 +136,3 @@ var toArray = exports.toArray = function(m){

this.on('newListener', this.add);
this.on('parse', this.parse);
return this;

@@ -143,9 +144,9 @@ };

Parser.prototype.add = function(regex, callback){
//this.parsers[regex] = new RegExp('(?:^|(;\n))' + regex + '([^;\n]?)+', 'g');
//this.parsers[regex] = new RegExp('(?:^|;\n)' + regex + '(.*?)', 'g');
this.parsers[regex] = new RegExp('(^|;\n)' + regex + '([^;\n]?)+', 'g');
// .match(/(a b)(.*)[^;\n]/g)
// 'a b 1;\na a b c 2;\na b 3'.match(/((?:^|(;\n))a b)/g)
this.parsers[regex] = new RegExp('^' + regex + '([^;]*)', 'gm');
};
Parser.prototype.remove = function(regex){
delete this.parsers[regex];
};
Parser.prototype.parse = function(fudi){

@@ -156,42 +157,5 @@ var result;

result = fudi.match(this.parsers[p]);
if (result) console.log('result', p, result);
}/*
for (var i = 0, l = this.parsers.length; i < l; i++){
// console.log(this.parsers[i]);
result = fudi.match(this.parsers[i]);
if (result) console.log('result', result);
}*/
if (!!result) this.emit(p, result);
}
return this;
};
+9
-1
{
"name": "fudi"
, "version": "0.0.1"
, "version": "0.0.2"
, "author": "Enrique Erne (http://mild.ch/)"
, "description": "101 ways to encode/decode FUDI"
, "keywords": [
"fudi"
, "parse"
, "format"
, "object"
, "array"
]
, "contributors": [

@@ -6,0 +14,0 @@ {"name": "Enrique Erne"}

@@ -1,6 +0,5 @@

FUDI.js
=======
# FUDI.js
101 ways to encode/decode [FUDI](http://en.wikipedia.org/wiki/FUDI)
messages to JSON in [Node.js](http://nodejs.org)
messages to JSON

@@ -7,0 +6,0 @@

@@ -92,3 +92,6 @@ exports.setup = function(Tests){

expect(toObject('foo bar 1 2;\nfoo bar 2 3;\n')).toBeSimilar({
expect(toObject(
'foo bar 1 2;\n'
+ 'foo bar 2 3;\n'
)).toBeSimilar({
'foo': {

@@ -102,3 +105,7 @@ 'bar': {

expect(toObject('foo bar 1 2;\nfoo bar 2 blih;\nfoo baz 3 4;\n')).toBeSimilar({
expect(toObject(
'foo bar 1 2;\n'
+ 'foo bar 2 blih;\n'
+ 'foo baz 3 4;\n'
)).toBeSimilar({
'foo': {

@@ -116,31 +123,5 @@ 'bar': {

});
/*
expect(fromFUDI('key 1;\nfoo 1 2 3;\n')).toBe({
'key': 1,
'foo': [1, 2, 3]
});
it('should convert a FUDI string to a nested object', function(expect){
expect(fromFUDI('top foo bar;\n')).toBe({
'top': {
'foo': 'bar'
}
});
expect(fromFUDI('first second third value;\n')).toBe({
'first': {
'second': {
'third': 'value'
}
}
});
});
*/
});
};

@@ -10,2 +10,3 @@ exports.setup = function(Tests){

it('should fire on certain FUDI messages', function(expect){
expect.perform(14);

@@ -18,12 +19,17 @@ expect(Parser).toBeType('function');

fudi.on(1, function(value){
console.log('1', value);
fudi.on(1, function(values){
expect(values).toBeType('array');
expect(values).toBeSimilar(['1', '1 2', '1 2 3 4 5']);
});
fudi.on('2 3', function(value){
console.log('2 3', value);
fudi.on('1', function(values){
expect(values).toBeType('array');
expect(values).toBeSimilar(['1', '1 2', '1 2 3 4 5']);
});
//fudi.emit('parse', 'foo bar baz 1 2 3;\nfoo bar baz 4 5 6;\n');
fudi.on('2 3', function(values){
expect(values).toBeType('array');
expect(values).toBeSimilar(['2 3 4 5 6']);
});
fudi.parse(

@@ -38,2 +44,11 @@ '1;\n'

fudi.emit('parse',
'1;\n'
+ '1 2;\n'
+ '0 1 2;\n'
+ '0 1 2 3 4;\n'
+ '1 2 3 4 5;\n'
+ '2 3 4 5 6;\n'
);
});

@@ -40,0 +55,0 @@