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

enamdict

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enamdict - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

69

enamdict.js

@@ -10,2 +10,5 @@ /**

// Default location of the included enamdict file
var enamdictFile = __dirname + "/enamdict.gz";
// Parse a line in the enamdict.

@@ -23,8 +26,9 @@ // Only parse lines that are of type: sugfm

// Use it as a backup when nothing else is found
var backupRomaji = [];
module.exports = {
init: function(stream, callback) {
if (arguments.length === 1) {
if (arguments.length < 2) {
callback = stream;
stream = "enamdict.gz";
stream = enamdictFile;
}

@@ -40,3 +44,6 @@

stream.pipe(concat(parseData));
stream.on("end", callback);
if (callback) {
stream.on("end", callback);
}
},

@@ -58,2 +65,10 @@

// Handle the case where there's a single name.
// Assume that the single name is the given name.
// (This is pretty common, an artist going by only their given name.)
if (parts.length === 1) {
given = parts[0];
surname = "";
}
var surnameEntries = this.find(surname);

@@ -126,9 +141,19 @@ var givenEntries = this.find(given);

romaji: function() {
return this.surname().romaji() + " " +
this.given().romaji();
var surname = this.surname().romaji();
if (surname) {
return surname + " " + this.given().romaji();
}
return "";
},
romajiModern: function() {
return this.given().romaji() + " " +
this.surname().romaji();
var surname = this.surname().romaji();
if (surname) {
return this.given().romaji() + " " + surname;
}
return "";
},

@@ -143,2 +168,4 @@

}
return "";
},

@@ -199,3 +226,6 @@

var capitalize = function(name) {
return name[0].toUpperCase() + name.slice(1);
if (name) {
return name[0].toUpperCase() + name.slice(1);
}
return "";
};

@@ -208,4 +238,6 @@

entries.forEach(function(entry) {
values[entry[key]] = (values[entry[key]] || 0) + 1;
total += 1;
if (key in entry) {
values[entry[key]] = (values[entry[key]] || 0) + 1;
total += 1;
}
});

@@ -217,3 +249,3 @@

if (values[popular[0]] > total / 2) {
if (popular.length > 0 && values[popular[0]] > total / 2) {
return popular[0];

@@ -232,2 +264,13 @@ }

}
backupRomaji.forEach(function(romaji) {
var newName = romaji.replace(/aa|ee|ii|oo|uu|'/g, function(all) {
return all === "'"? "" : all[0];
});
if (!(newName in byRomaji) ||
byRomaji[romaji].length >= byRomaji[newName].length) {
byRomaji[newName] = byRomaji[romaji];
}
});
};

@@ -266,2 +309,6 @@

byRomaji[romaji] = [data];
if (/aa|ee|ii|oo|uu|'/.test(romaji)) {
backupRomaji.push(romaji);
}
} else {

@@ -268,0 +315,0 @@ byRomaji[romaji].push(data);

2

package.json
{
"name": "enamdict",
"version": "0.0.1",
"version": "0.0.2",
"description": "Look up Romaji names and correct surname/given name usage.",

@@ -5,0 +5,0 @@ "main": "enamdict.js",

@@ -25,1 +25,7 @@ var fs = require("fs");

// enamdict.lookupKanji("安藤")
// To Test:
// Andoo Hiroshige
// Hiroshige Andoo
// Utagawa Hiroshige
// Hiroshige Utagawa
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