Converting JavaScript from Drupal 7 to Drupal 8 standards I have a Drupal 7 module that contains a JavaScript file whose only contents are

Drupal.behaviors.InitializeMapplic = {
  attach: function (context, settings) {
    jQuery("#mapplic").mapplic(Drupal.settings.mapplic);
  }
};


I'm aware that Drupal 8 introduced a new JavaScript API and that this code needs to be updated. However, I'm confused as to what the Drupal 8 equivalent is. I have read and tried to dissect the change records at https://www.drupal.org/node/1793334 and I have reviewed the API documentation at https://www.drupal.org/docs/8/api/javascript-api/javascript-api-overview.

So my question is, exactly what needs to change here in order for this to play ball with Drupal 8? Will it just become

jQuery("#mapplic").mapplic(drupalSettings.mapplic);


all by itself or what? Any light that can be shed on this for me would be appreciated.
As you already linked from the docs https://www.drupal.org/docs/8/api/javascript-api/javascript-api-overview I just repeat the most important parts here:

MYMODULE.libraries.yml

foobar:
  js:
    js/foobar.js: {}
  dependencies:
    - core/jquery
    - core/jquery.once
    - core/drupal
    - core/drupalSettings


js/foobar.js

(function ($, Drupal) {
  Drupal.behaviors.myModuleBehavior = {
    attach: function (context, settings) {
      $('.MYSELECTOR', context).once('myCustomBehavior').each(function () {
        // Apply the myCustomBehaviour effect to the elements only once.

        // I guess you have to pass something to `settings` first.
        // $("#mapplic").mapplic(settings.mapplic);

        console.log('Hello world!');
      });
    }
  };
})(jQuery, Drupal);


MYMODULE.module

function MYMODULE_page_attachments_alter(array &amp;$attachments) {
  $attachments['#attached']['library'][] =  'MYMODULE/foobar';
}




Update: removed some flaws.