nlptoolkit-util 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  For Developers
2
2
  ============
3
3
  You can also see [Cython](https://github.com/starlangsoftware/Util-Cy), [Java](https://github.com/starlangsoftware/Util),
4
- [C++](https://github.com/starlangsoftware/Util-CPP), [Swift](https://github.com/starlangsoftware/Util-Swift),
5
- [Python](https://github.com/starlangsoftware/Util-Py), or [C#](https://github.com/starlangsoftware/Util-CS) repository.
4
+ [C++](https://github.com/starlangsoftware/Util-CPP), [Swift](https://github.com/starlangsoftware/Util-Swift), [C](https://github.com/starlangsoftware/Util-C), [Python](https://github.com/starlangsoftware/Util-Py), or [C#](https://github.com/starlangsoftware/Util-CS) repository.
6
5
 
7
6
  ## Requirements
8
7
 
@@ -0,0 +1,7 @@
1
+ export declare class FileContents {
2
+ private readonly contents;
3
+ private filePointer;
4
+ constructor(fileName: string);
5
+ readLine(): string;
6
+ hasNextLine(): boolean;
7
+ }
@@ -0,0 +1,35 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "fs"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FileContents = void 0;
13
+ var fs = require("fs");
14
+ var FileContents = /** @class */ (function () {
15
+ function FileContents(fileName) {
16
+ var data = fs.readFileSync(fileName, 'utf8');
17
+ this.contents = data.split("\n");
18
+ this.filePointer = 0;
19
+ }
20
+ FileContents.prototype.readLine = function () {
21
+ if (this.filePointer < this.contents.length) {
22
+ var s = this.contents[this.filePointer];
23
+ this.filePointer++;
24
+ return s;
25
+ }
26
+ return "";
27
+ };
28
+ FileContents.prototype.hasNextLine = function () {
29
+ return this.filePointer < this.contents.length;
30
+ };
31
+ return FileContents;
32
+ }());
33
+ exports.FileContents = FileContents;
34
+ });
35
+ //# sourceMappingURL=FileContents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileContents.js","sourceRoot":"","sources":["../source/FileContents.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,uBAAyB;IAEzB;QAKI,sBAAY,QAAgB;YACxB,IAAI,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;YAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAChC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAA;QACxB,CAAC;QAED,+BAAQ,GAAR;YACI,IAAI,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAC;gBACxC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;gBACvC,IAAI,CAAC,WAAW,EAAE,CAAA;gBAClB,OAAO,CAAC,CAAA;aACX;YACD,OAAO,EAAE,CAAA;QACb,CAAC;QAED,kCAAW,GAAX;YACI,OAAO,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAA;QAClD,CAAC;QACL,mBAAC;IAAD,CAAC,AAvBD,IAuBC;IAvBY,oCAAY"}
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export * from "./dist/Interval"
2
2
  export * from "./dist/Permutation"
3
- export * from "./dist/RandomNormalizedArray"
4
3
  export * from "./dist/Subset"
5
4
  export * from "./dist/SubsetFromList"
6
5
  export * from "./dist/Tuple"
7
6
  export * from "./dist/Random"
7
+ export * from "./dist/FileContents"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nlptoolkit-util",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Simple Utils Library",
5
5
  "main": "index.js",
6
6
  "types": "index.js",
@@ -0,0 +1,26 @@
1
+ import * as fs from "fs";
2
+
3
+ export class FileContents {
4
+
5
+ private readonly contents: string[]
6
+ private filePointer: number
7
+
8
+ constructor(fileName: string) {
9
+ let data = fs.readFileSync(fileName, 'utf8')
10
+ this.contents = data.split("\n")
11
+ this.filePointer = 0
12
+ }
13
+
14
+ readLine(): string{
15
+ if (this.filePointer < this.contents.length){
16
+ let s = this.contents[this.filePointer]
17
+ this.filePointer++
18
+ return s
19
+ }
20
+ return ""
21
+ }
22
+
23
+ hasNextLine(): boolean{
24
+ return this.filePointer < this.contents.length
25
+ }
26
+ }