This is a test of creating an Atom package, it provides no tools for helping people write code more convenient, I wrote this package just for fun.
- Requirements before start:
- npm version >= 3.3.6 (Enter
npm --version
in your terminal to check it) - git version >= 2.0.0 (Enter
git --version
in your terminal to check it) - Atom version >= 1.2.0
- Your Atom must support ECMAScript 6 syntax to be able to use this package
- Open your terminal
- Windows: Press Ctrl + R, enter
cmd
(orpowershell
). - Mac OS X: Press Cmd + Space.
- Linux: Press Ctrl + Alt + T.
- Install this package to your Atom
- Step 1: Clone this repository to your computer, suppose that you choose 'path/to/your/directory' as installation directory of this package
cd path/to/your/directory
git clone https://github.com/ksxatompackages/atom-prime-generator.git
- Step 2: Link this package to Atom
cd ./atom-prime-generator # After doing Step 1, a directory named 'atom-prime-generator' which contains this package was created inside 'path/to/your/directory'
apm develop prime-generator . # Create a package named 'prime-generator' to directory '.' which is 'atom-prime-generator' above
apm link .
- Step 3: Install package's dependencies
cd path/to/your/directory
mkdir ./node_modules # If 'node_modules' doesn't exist
cd ./node_modules
git clone https://github.com/ksxnodemodules/ksxnodemodules.git
- You need to restart your Atom to use this package.
After you open/restart your Atom, there're 2 ways to open the pane:
- In menu-bar, go to Packages → prime-generator → Open.
- Open Command Palettle (by pressing Ctrl + Shift + P), then enter
Prime Generator: Open
.
- Input box: Representing amount of primes would be printed.
- Hit Enter to print prime numbers.
- Hit ESC to clear every input and output.
- Press Ctrl + S to open editor pane.
- Buttons
- Add: Print more an amount of primes which was represented by value in the input box.
- Reset: Clear the input box, reset output.
- Get: Create an editor pane which contains all generated primes.
- A prime number (or a prime) is a natural number greater than 1 that has no positive divisor other than 1 and itself, a natural number greater than 1 that is not a prime number is called a composite number.
- Source: https://en.wikipedia.org/wiki/Prime_number
- 0 and 1 are not prime numbers.
- 2 is a prime number.
- A prime number is a natural number greater than 1 which has no prime divisor other than itself.
- Any number which is not divisible by any less prime number is a prime number
- The only even prime number is 2, so, only check odd numbers
- ECMAScript 2015 provides
for...of
loop to iterate iterable object,prime.js
provides classPrimeGenerator
, which used to create an iterable object for primes
Open your terminal, type:
cd path/to/node_modules
npm install https://github.com/ksxnodemodules/ksxnodemodules.git
var PrimeGenerator = require('ksxnodemodules').prime.PrimeGenerator;
new PrimeGenerator(listclass, loopcondition);
- Parameter
listclass
is a constructor/class which should create an iterable object, this object must have.add(element)
method. Iflistclass
was not be specified, useSet
by default. - Parameter
loopcondition
is a function, which receivesn
as the only argument, and returns a boolean. Ifloopcondition
was not be specified, use() => true
by default. - Parameter
n
: current checking potential odd number. - Return value: if
false
, the iterating process will stop,true
for otherwise. - Return value: an object of
PrimeGenerator
.
for (let prime of primegen) {
statements;
}
primegen
is an object of classPrimeGenerator
.prime
is a prime number (greater than 2).statements
is JavaScript statements.