New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

filesplit

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filesplit - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

35

index.js

@@ -14,12 +14,6 @@ /* vim: set expandtab tabstop=2 shiftwidth=2 foldmethod=marker: */

var m = str.length;
for (var i = 0; i < m; i++) {
if (str.charCodeAt(i) > 32) {
break;
}
for (var i = 0; i < m && str.charCodeAt(i) < 33; i++) {
}
for (var j = m - 1; j > i; j--) {
if (str.charCodeAt(j) > 32) {
break;
}
for (var j = m - 1; j > i && str.charCodeAt(j) < 33; j--) {
}

@@ -42,2 +36,3 @@

'filters' : [],
'handles' : [], /**< 产出列处理规则 */
'fields' : [],

@@ -51,11 +46,23 @@ 'routes' : {},

/* {{{ function _buildRow() */
if (!Array.isArray(_options.fields) || _options.fields.length < 1) {
var _buildRow = new Function('row', Util.format("return row.join('%s');", _options.EOF));
function _deal(row) {
row.forEach(function (f, i) {
if (handles[i]) {
row[i] = (handles[i])(f);
}
});
}
var _buildRow = new Function(['row', 'handles'], _deal.toString() + '\n_deal(row);\n' + Util.format("return row.join('%s');", _options.EOF));
} else {
function _fn(f, i) {
if (handles[i]) {
return (handles[i])(f);
}
return f;
}
var _temp = [];
_options.fields.forEach(function (k) {
_temp.push(Util.format('row[%d]', k));
_options.fields.forEach(function (k, i) {
_temp.push(Util.format('_fn(row[%d], %d)', k, i));
});
var _buildRow = new Function('row', 'return ' + _temp.join(Util.format(" + '%s' + ", _options.EOF)) + ';');
var _buildRow = new Function(['row', 'handles'], _fn.toString() + '\nreturn ' + _temp.join(Util.format(" + '%s' + ", _options.EOF)) + ';');
}

@@ -141,3 +148,3 @@

var idx = _getRoute(row);
var txt = _buildRow(row) + _options.EOL;
var txt = _buildRow(row, _options.handles) + _options.EOL;

@@ -144,0 +151,0 @@ if (undefined === _wcache[idx]) {

21

package.json
{
"name": "filesplit",
"version": "0.1.1",
"author": "Aleafs Zhang (zhangxc83@gmail.com)",
"version": "0.1.2",
"author": "Aleafs Zhang (zhangxc83@gmail.com), iseeyou1987 (21.aoei@gmail.com)",
"contributors": [],
"homepage": "git@github.com:iseeyou1987/filesplit.git",
"description": "A high speed file splitor on Node.js",
"keywords": [ "filesplit", "cut", "split" ],
"keywords": [
"filesplit",
"cut",
"split"
],
"dependencies": {},

@@ -14,9 +18,14 @@ "engines": {

"devDependencies": {
"should" : ">=0.4.2",
"mocha" : ">=0.9.0"
"should": ">=0.4.2",
"mocha": ">=0.9.0"
},
"main" : "./index.js",
"main": "./index.js",
"scripts": {
"test": "make test"
},
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git://github.com/iseeyou1987/filesplit.git"
}
}

@@ -23,3 +23,3 @@ [![Build Status](https://secure.travis-ci.org/aleafs/filesplit.png?branch=master)](http://travis-ci.org/aleafs/filesplit)

Thanks goes to the people who have contributed code to this module, see the [GitHub Contributors page](https://github.com/aleafs/filesplit/graphs/contributors).
Thanks goes to the people who have contributed code to this module, see the [GitHub Contributors page](https://github.com/iseeyou1987/filesplit/graphs/contributors).

@@ -30,3 +30,3 @@ # License #

Copyright (c) 2012 aleafs and other filesplit contributors
Copyright (c) 2012 iseeyou1987 and other filesplit contributors

@@ -33,0 +33,0 @@ Permission is hereby granted, free of charge, to any person obtaining

@@ -5,2 +5,3 @@ /* vim: set expandtab tabstop=2 shiftwidth=2 foldmethod=marker: */

var splitor = require(__dirname + '/../');
var fs = require('fs');

@@ -13,3 +14,2 @@ var cleanOutput = function (callback) {

var fs = require('fs');

@@ -142,3 +142,51 @@ /* {{{ should_read_wrong_character_when_not_set_encoding() */

it('should_field_handle_works_fine', function (done) {
var _input = [__dirname + '/res/test_input_1.txt', __dirname + '/res/test_input_2.txt'];
var caller = splitor.create(_input, __dirname + '/res/output', {
'EOF' : String.fromCharCode(1),
'bufferSize' : 1024,
'maxLines' : 30,
'routes' : {'thedate' : 0},
'fields' : [1,0,4,3],
'filters' : [splitor.trim],
'handles' : [,,,_S]
});
function _S(str) {
return ['$', str, '$'].join('');
}
caller(function (error, result) {
should.ok(!error);
var _content = fs.readFileSync(result['thedate=20120623'][0].file).toString().trim();
_content.split('\n').forEach(function (l) {
var fields = l.split(String.fromCharCode(1));
fields.pop().should.match(/^\$.*\$$/);
});
done();
});
});
it('should_field_handle_works_fine_when_no_fields_given', function (done) {
var _input = [__dirname + '/res/test_input_1.txt', __dirname + '/res/test_input_2.txt'];
var caller = splitor.create(_input, __dirname + '/res/output', {
'EOF' : String.fromCharCode(1),
'bufferSize' : 1024,
'maxLines' : 30,
'routes' : {'thedate' : 0},
'filters' : [splitor.trim],
'handles' : [,,,,_S]
});
function _S(str) {
return ['$', str, '$'].join('');
}
caller(function (error, result) {
should.ok(!error);
var _content = fs.readFileSync(result['thedate=20120623'][0].file).toString().trim();
_content.split('\n').forEach(function (l) {
var fields = l.split(String.fromCharCode(1));
fields.pop().should.match(/^\$.*\$$/);
});
done();
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc