[Javascript] How to write a Javascript libarary

Source: Internet
Author: User

Create Package.json File

// NPM settingsnpm set Init-author-name ' username 'npm set init-author-email ' [email protected] 'NPM Set init-author-url ' http://username.com 'npm set savetrue//Create Package.json NPM Init

Pubish to GitHub and tag it

--M "Commit message"1.0.0--tags

Publish to NPM

<project_name>

Release a new version

inch Package.json2. Publish to Git3. Publish tag to git4. NPM Publish5. NPM Info

Publishing a beta version
1. In Package.json: ' Version ': ' 1.2.0-beta.0 ',2. Publish to Git in gitbeta 5. NPM info//installnpm install starwars-[email protected]npm install starwars[ Email protected]

Mocha, Chai Testing:

varExpect = require (' Chai ')). Expect;varStarWars = require ('./index '));d Escribe (' Starwars-names ',function() {Describe (' All ',function(){        //Check return typeIt (' should is an array of strings ',function() {expect (Starwars.all). to.satisfy (isarrayofstring); functionisarrayofstring (array) {returnArray.every (function(item) {return typeofitem = = = ' String ';            });                }        }); //Ccheck One of the valueIt (' Should includ Asajj Ventress ',function() {expect (Starwars.all). To.include (' Asajj Ventress ');    });        }); Describe (' Random ',function() {It (' Should return one of the Starwar names form all ',function() {expect (Starwars.all). To.include (Starwars.random ()); })    });});

[Javascript] How to write a Javascript libarary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.