Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

firstline

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firstline - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

3

firstline.js
'use strict';
var fs = require('fs');
var Q = require('q');
module.exports = function (path) {
return Q.promise(function (resolve, reject) {
return new Promise(function (resolve, reject) {
var rs = fs.createReadStream(path, {encoding: 'utf8'});

@@ -9,0 +8,0 @@ var acc = '';

{
"name": "firstline",
"version": "1.0.0",
"version": "1.1.0",
"description": "Async npm module for Node JS that reads the first line of a file",

@@ -27,5 +27,3 @@ "main": "firstline.js",

"homepage": "https://github.com/pensierinmusica/firstline",
"dependencies": {
"q": "^1.2.0"
},
"dependencies": {},
"devDependencies": {

@@ -36,4 +34,4 @@ "chai": "^2.1.0",

"istanbul": "^0.3.6",
"js-promisify": "^1.0.2",
"mocha": "^2.1.0",
"q-io": "^1.11.6",
"rimraf": "^2.2.8"

@@ -40,0 +38,0 @@ },

@@ -9,5 +9,5 @@ # Firstline

Firstline is a [npm](http://npmjs.org) async module for [NodeJS](http://nodejs.org/), that **reads and returns the first line of any file**. Based on [q](http://github.com/kriskowal/q), supports promises and streams. It is well tested and built for high performance.
Firstline is a [npm](http://npmjs.org) async module for [NodeJS](http://nodejs.org/), that **reads and returns the first line of any file**. It uses native JS promises and streams (requires Node >= v4.0.0). It is well tested and built for high performance.
It is particularly suited if you need to programmatically access the first line of a large amount of files, while handling errors when they occur.
It is particularly suited when you need to programmatically access the first line of a large amount of files, while handling errors if they occur.

@@ -14,0 +14,0 @@ ## Install

'use strict';
var promisify = require('js-promisify');
var chai = require('chai');

@@ -7,3 +8,2 @@ var chaiAsPromised = require("chai-as-promised");

var fs = require('fs');
var FS = require("q-io/fs");
var path = require('path');

@@ -37,7 +37,7 @@ var rimraf = require('rimraf');

// Delete mock CSV file
return FS.remove(filePath);
return promisify(fs.unlink, [filePath]);
});
it('should reject if file does not exist', function () {
return FS.write(filePath, mocks.shortLine)
return promisify(fs.writeFile, [filePath, mocks.shortLine])
.then(function () {

@@ -49,3 +49,3 @@ return firstline(wrongFilePath).should.be.rejected;

it('should return the first short line of file', function () {
return FS.write(filePath, mocks.shortLine)
return promisify(fs.writeFile, [filePath, mocks.shortLine])
.then(function () {

@@ -57,3 +57,3 @@ return firstline(filePath).should.eventually.equal('abc');

it('should return the first long line of file', function () {
return FS.write(filePath, mocks.longLine)
return promisify(fs.writeFile, [filePath, mocks.longLine])
.then(function () {

@@ -65,3 +65,3 @@ return firstline(filePath).should.eventually.equal(mocks.longLine.split('\n')[0]);

it('should return the first empty line of file', function () {
return FS.write(filePath, '')
return promisify(fs.writeFile, [filePath, ''])
.then(function () {

@@ -68,0 +68,0 @@ return firstline(filePath).should.eventually.equal('');

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