Comments (8)
Tweeting about this from @yourfirspr at 3PM (GMT), this is a great issue and exactly the kind of thing I want. Great balance between not giving the answer, but guiding you on your way.
from initials.
Just to get a bit of context, what is t.plan
used for ?
from initials.
@Ketouem t.plan
is part of https://www.npmjs.com/package/tape, see https://www.npmjs.com/package/tape#t-plan-n. You define the amount of tests (assertions), which is especially useful if you do async tests. Here we could remove t.plan
and put t.end
to the very end, it would have the same effect
from initials.
On line 177 of initials.js, there is a call to Array.splice inside of the loop which removes elements inside of the possibleInitials array causing the loop to skip some items. If we run the loop from end to beginning this issue is resolved, but the output of initials(['Moe Min', 'Moe Minutes'])
becomes ["Moe Min", "MMinutes"]
which is different than the expected value of the current test. Would you rather go with this approach and edit the test accordingly or keep tackling it to get an output that matches the current test?
from initials.
@sylvesterwillis good idea with running backwards! But Moe Min
is not really helpful as initials for Moe Min
, but maybe your changes is progress in the right direction? Wanna start a pull request, and we discuss there?
from initials.
Sure, I'll be on the train for a bit but will be able to talk more in about ~2hrs or so. My PR doesn't include any changes to the test since we'll be talking more about it.
from initials.
I think one way to approach the problem is that instead of ignoring initials that might be valid for both entirely, we could only allow them once.
For example, for simpler debugging, add only this test at the very end to the test/initials-test.js file:
test.only('debug', function (t) {
t.deepEqual(initials(['Moe Minutes', 'Moe Min']), ['MoM', 'MMi'], '["Moe Minutes", "Moe Min"] ☛ ["MoM", "MMi"]')
})
then in initials.js, log initialsForNamesMap
in line 170, before the // initialsForNamesMap
comment, then run
node test/initials-test.js
The output will look something like this:
TAP version 13
# debug
{ 'Moe Minutes': [ 'MM' ], 'Moe Min': [ 'MM' ] }
{ 'Moe Minutes': [ 'MoM', 'MMi' ], 'Moe Min': [ 'MoM', 'MMi' ] }
{ 'Moe Minutes': [ 'MoMi', 'MoeM', 'MMin' ],
'Moe Min': [ 'MoeM', 'MMin', 'MoMi' ] }
{ 'Moe Minutes': [ 'MMinu', 'MoeMi', 'MoMin' ],
'Moe Min': [ 'MoMin', 'MoeMi' ] }
{ 'Moe Minutes': [ 'MoMinu', 'MoeMin', 'MMinut' ],
'Moe Min': [ 'MoeMin' ] }
{ 'Moe Minutes': [ 'MoeMinu', 'MMinute', 'MoMinut' ],
'Moe Min': [] }
{ 'Moe Minutes': [ 'MMinutes', 'MoeMinut', 'MoMinute' ],
'Moe Min': [ 'Moe Min' ] }
not ok 1 ["Moe Minutes", "Moe Min"] ☛ ["MoM", "MMi"]
If we'd check for the amount of possible different initials, we could end with
{ 'Moe Minutes': [ 'MoM', 'MMi' ], 'Moe Min': [ 'MoM', 'MMi' ] }
And give Moe Minutes
the initials MoM
, and Moe Min
the initials MMi
. I guess for that we would need to add an extra check before these lines
I think there are different ways to achieve that, it's quite a puzzle though. I'm looking forward to see what we'll come up with
from initials.
resolved via #16, thanks @javimolla & @Charlotteis
from initials.
Related Issues (20)
- An in-range update of tape is breaking the build 🚨 HOT 1
- An in-range update of semantic-release is breaking the build 🚨 HOT 2
- An in-range update of semantic-release is breaking the build 🚨 HOT 2
- An in-range update of semantic-release is breaking the build 🚨 HOT 1
- LICENSE file HOT 4
- Limit to two characters? HOT 11
- An in-range update of browserify is breaking the build 🚨 HOT 2
- An in-range update of semantic-release is breaking the build 🚨 HOT 1
- An in-range update of rimraf is breaking the build 🚨 HOT 1
- An in-range update of semantic-release is breaking the build 🚨 HOT 1
- An in-range update of semantic-release is breaking the build 🚨 HOT 3
- An in-range update of tape is breaking the build 🚨 HOT 1
- An in-range update of semantic-release is breaking the build 🚨 HOT 1
- An in-range update of tape is breaking the build 🚨 HOT 1
- An in-range update of tape is breaking the build 🚨 HOT 1
- An in-range update of semantic-release is breaking the build 🚨 HOT 1
- Typescript support HOT 4
- Type Definition Error TS2309 HOT 1
- More intelligent TypeScript return type HOT 3
- The automated release is failing 🚨 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from initials.