From a78eba66f2d066e2a0be0f1f22abcf48fe11b9a1 Mon Sep 17 00:00:00 2001 From: lord63 Date: Wed, 25 Feb 2015 10:59:51 +0800 Subject: [PATCH] Remove the useless nonWords --- dist/hipku.js | 14 +++++--------- index.js | 14 +++++--------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/dist/hipku.js b/dist/hipku.js index da441b3..44dd393 100644 --- a/dist/hipku.js +++ b/dist/hipku.js @@ -244,9 +244,7 @@ function writeHaiku(wordArray, ipv6) { var octet, schemaResults, schema, nonWords, haiku; octet = 'OCTET'; // String to place in schema to show word slots - schemaResults = getSchema(ipv6, octet); - schema = schemaResults[0]; - nonWords = schemaResults[1]; + schema = getSchema(ipv6, octet); /* ** Replace each instance of 'octet' in the schema with a word from @@ -327,12 +325,10 @@ function getSchema(ipv6, octet) { var insertSpace = true; /* - ** If the next entry is a nonWord, don't add a space + ** If the current entry is a nonWord, don't add a space */ - for (var j = 0; j < nonWords.length; j++) { - if (schema[i] === nonWords[j]) { - insertSpace = false; - } + if (schema[i] in nonWords) { + insertSpace = false; } /* @@ -348,7 +344,7 @@ function getSchema(ipv6, octet) { } } - return [schema, nonWords]; + return schema; } function capitalizeHaiku(haikuArray) { diff --git a/index.js b/index.js index 7afa046..7019990 100644 --- a/index.js +++ b/index.js @@ -244,9 +244,7 @@ function writeHaiku(wordArray, ipv6) { var octet, schemaResults, schema, nonWords, haiku; octet = 'OCTET'; // String to place in schema to show word slots - schemaResults = getSchema(ipv6, octet); - schema = schemaResults[0]; - nonWords = schemaResults[1]; + schema = getSchema(ipv6, octet); /* ** Replace each instance of 'octet' in the schema with a word from @@ -327,12 +325,10 @@ function getSchema(ipv6, octet) { var insertSpace = true; /* - ** If the next entry is a nonWord, don't add a space + ** If the current entry is a nonWord, don't add a space */ - for (var j = 0; j < nonWords.length; j++) { - if (schema[i] === nonWords[j]) { - insertSpace = false; - } + if (schema[i] in nonWords) { + insertSpace = false; } /* @@ -348,7 +344,7 @@ function getSchema(ipv6, octet) { } } - return [schema, nonWords]; + return schema; } function capitalizeHaiku(haikuArray) {