r/javascript • • Nov 27 '20

Template for making package namespace

https://dev.to/craftkitjs/craftkit-code-pattern-template-for-making-package-namespace-180h
1 Upvotes

4 comments sorted by

6

u/dillonerhardt Nov 27 '20

Read the article but still confused what the use of this is

1

u/Quirky-Ear8688 Sep 28 '22

craftkit provides a framework for maximizing the readability of web applications.
Namespaces are used so that the contents of the packages used can be assumed anywhere in the code. (For aesthetics).

0

u/[deleted] Nov 30 '20

[deleted]

1

u/Quirky-Ear8688 Nov 30 '20

This article describes how to isolate JavaScript component name both in script tag and node.js, something like this:

in script tag:

<script>
var view = new MyCompany.MyApp.View();
MyCompany.MyApp.ViewController.append({ id:'#view', view:view });
</script>

in node.js

import * as MyCompany from './MyCompany';
var view = new MyCompany.MyApp.View();
MyCompany.MyApp.ViewController.append({ id:'#view', view:view });

1

u/backtickbot Nov 30 '20

Hello, Quirky-Ear8688: code blocks using backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead. It's a bit annoying, but then your code blocks are properly formatted for everyone.

An easy way to do this is to use the code-block button in the editor. If it's not working, try switching to the fancy-pants editor and back again.

Comment with formatting fixed for old.reddit.com users

FAQ

You can opt out by replying with backtickopt6 to this comment.