Task Requests avatar

JS Developers & Regex Experts Wanted: Javascript Coding Task

utopian.tasks

Published: 24 May 2018 › Updated: 24 May 2018JS Developers & Regex Experts Wanted: Javascript Coding Task

JS Developers & Regex Experts Wanted: Javascript Coding Task

[UPDATE]

We have received enough contributions for this task request already. Thanks for participating!

Repository

https://github.com/utopian-io/v2.api.utopian.io

Utopian.io is looking for an exceptional contribution from skilled JS Developers and Regex experts. The task is quite straightforward in terms of coding effort, but it requires proficiency in handling regular expressions.

utopian-post-banner.png

Task Details

Create a GitHub gist with a Javascript script that can perform the following:

Receive text as input
Parse the text and compare it with a set of regular expressions
Return a different object or an error result based on the scenarios listed below

Possible text scenarios

utopian-bot@utopian-bot !utopian

In this scenario, the text contains a mention at the start and a predefined text !utopian right after, both of which never change.

If this condition is met, then return the following object:

{
    beneficiaries: [],
}
Possible Errors

The whole sentence is not properly formatted
Some parts are missing or
Unrelated text is contained

RESULT: Return an appropriate error.

utopian-bot@utopian-bot !utopian mention1@mention1 mention2@mention2 mention3@mention3 mention4@mention4

In this scenario, the text contains a mention at the beginning and the predefined text !utopian just as in the previous scenario, but also contains a variable set of additional mentions right after. These mentions may be one or more and should be unique.

In the event of such a scenario, the following object should be returned, dividing 100% by the number of mentions.

{
    beneficiaries: [
            {mention1: 25},
            {mention2: 25},
            {mention3: 25},
            {mention4: 25},
        ],
}
Possible Errors
  • The same username is mentioned multiple times
  • The text is not properly formatted, some parts are missing, or there is additional unrelated text.
  • There are more than 8 beneficiaries

RESULT: Return an appropriate error.

utopian-bot@utopian-bot !utopian mention1@mention1:15% mention2@mention2:35% mention3@mention3:25% mention4@mention4:25%

This scenario, which adds on to the previous ones, handles additional syntax and allows for custom percentages. The text requirements are the same for the initial mention, the predefined text that follows, as well as the preceding mentions.

When handling this text input, the following object must be returned (making sure the sum of all the percentages is exactly 100%):

{
    beneficiaries: [
            {mention1: 15},
            {mention2: 35},
            {mention3: 25},
            {mention4: 25},
],
}
Possible Errors
  • The same username is mentioned multiple times
  • The text is not properly formatted, some parts are missing or there is unrelated text in it
  • The sum of all the percentages does not equal 100%
  • There are more than 8 beneficiaries

RESULT: Return an appropriate error.

General Errors

These are meant to handle scenarios that do not match any ones mentioned above.

If the text input does not match any of the required scenarios above, then an error must be returned.
A more specific error should be returned if possible for that scenario

Deadline

Friday 25th of May 2018

Communication

Get in touch with utopian@utopian#2644 on Discord

Rewards

Write a Utopian contribution under the Development category. The best contribution will be scored and rewarded accordingly.

Make sure to paste your contribution in the comments of this task as soon as you are done.

In Utopian we love collaboration. Use the comments section to collaborate with other awesome developers on this task and split the rewards via the beneficiaries, using a tool like steemplus@steemplus.

First Time Contributing in Utopian?

Learn how to contribute on our website

Utopian Witness

Vote for our witness!

Leave JS Developers & Regex Experts Wanted: Javascript Coding Task to:

Written by

Find Task Requests by Open Source Projects and solve them!

Read more #utopian-io posts


Best Posts From Task Requests

We have not curated any of utopian.tasks's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Task Requests