Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
coverage
package-lock.json
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ language: node_js
cache: npm
node_js:
- "10"
before_script:
- npm install eslint --global
- npm install standard --global
script:
- ./runcheckendline.sh
- standard
- ./scripts/runcheckendline.sh
- npm run validate
after_success:
- ./scripts/report-coverage.sh
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ memory.secret.min.js - 2.4kb (obfuscated)

[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)

[![License](https://img.shields.io/github/license/unsuitable001/memoryJS.svg?style=popout)](https://raw.githubusercontent.com/unsuitable001/memoryJS/master/LICENSE) [![Build Status](https://travis-ci.org/unsuitable001/memoryJS.svg?branch=master)](https://travis-ci.org/unsuitable001/memoryJS) [![codebeat badge](https://codebeat.co/badges/9a04c2ff-0e70-4290-a340-67f37d41e162)](https://codebeat.co/projects/github-com-unsuitable001-memoryjs-master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/392b5ccd3b854df8bc0988e359872afb)](https://www.codacy.com/app/unsuitable001/memoryJS?utm_source=github.com&utm_medium=referral&utm_content=unsuitable001/memoryJS&utm_campaign=Badge_Grade)
[![License](https://img.shields.io/github/license/unsuitable001/memoryJS.svg?style=popout)](https://raw.githubusercontent.com/unsuitable001/memoryJS/master/LICENSE)
[![Build Status](https://travis-ci.org/unsuitable001/memoryJS.svg?branch=master)](https://travis-ci.org/unsuitable001/memoryJS)
![Codecov](https://img.shields.io/codecov/c/github/unsuitable001/memoryJS)
[![codebeat badge](https://codebeat.co/badges/9a04c2ff-0e70-4290-a340-67f37d41e162)](https://codebeat.co/projects/github-com-unsuitable001-memoryjs-master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/392b5ccd3b854df8bc0988e359872afb)](https://www.codacy.com/app/unsuitable001/memoryJS?utm_source=github.com&utm_medium=referral&utm_content=unsuitable001/memoryJS&utm_campaign=Badge_Grade)

**Preliminary work is done. Testing in progress. Feature Requests, Bug Reports & Contributions are welcomed. Node Package Coming Soon**

Expand All @@ -31,50 +34,51 @@ memory.secret.min.js - 2.4kb (obfuscated)
### Creating New Object in Memory

```javascript
var ptr = memoryJS.publicMemoryObj.newobj(55) // this method returns a pointer object
var ptr = memoryJS.publicMemoryObj.newobj(55); // this method returns a pointer object
```

### Getting The Memory Address Of The Object

```javascript
console.log(ptr.value())
console.log(ptr.value());
```

### Accessing The Stored Object from Memory

```javascript
console.log(ptr.pointedTo()) // output : 55
console.log(ptr.point) // output : 55
console.log(memoryJS.publicMemoryObj.valueOf(ptr.value())) // output : 55
console.log(ptr.pointedTo()); // output : 55
console.log(ptr.point); // output : 55
console.log(memoryJS.publicMemoryObj.valueOf(ptr.value())); // output : 55
```

### Changing The Stored Object in Memory

```javascript
ptr.changeValue(96)
ptr.changeValue(96);
// or
ptr.point = 96
ptr.point = 96;
// or
memoryJS.publicMemoryObj.changeValue(ptr.value(), 96)
memoryJS.publicMemoryObj.changeValue(ptr.value(), 96);
```

### Deleting An Object From Memory

```javascript
ptr.free() // returns null object
ptr.free(); // returns null object
// or
memoryJS.publicMemoryObj.free() // returns zero
memoryJS.publicMemoryObj.free(); // returns zero
```

### Creating Custom Pointer Object

```javascript
var newptr = new Pointer('05f9') // where 05f9 is the memory address (i.e value of the pointer)
var newptr = new Pointer("05f9"); // where 05f9 is the memory address (i.e value of the pointer)
```

### Trying to access the whole memory object

```javascript
console.log(memoryJS.publicMemoryObj) // try yourself. it will not display any of the contents. Will only print the available methods.
console.log(memoryJS.publicMemoryObj); // try yourself. it will not display any of the contents. Will only print the available methods.
```

## Donate
Expand Down
5 changes: 5 additions & 0 deletions memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,8 @@ class Memory {
}

memoryJS.publicMemoryObj = new Memory(true)

if (typeof window === 'undefined') {
module.exports = memoryJS
}

56 changes: 56 additions & 0 deletions memory.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const memoryJS = require('./memory')

test('creates new object in memory', () => {
const values = [5, 2, 6, 9, 7, 80]

values.forEach((value, index) => {
const ptr = memoryJS.publicMemoryObj.newobj(value)

expect(ptr.value()).toBe((index + 1).toString())
})
})

test('accesses the stored object from memory', () => {
const values = [5, 2, 6, 9, 7, 80]

values.forEach((value) => {
const ptr = memoryJS.publicMemoryObj.newobj(value)

expect(ptr.pointedTo()).toBe(value)
expect(ptr.point).toBe(value)
expect(memoryJS.publicMemoryObj.valueOf(ptr.value())).toBe(value)
})
})

test('changes the stored object in memory', () => {
const values = [5, 2, 6, 9, 7, 80]
const changeValues = values.reverse()

values.forEach((value, index) => {
const ptr = memoryJS.publicMemoryObj.newobj(value)
ptr.changeValue(changeValues[index])

expect(ptr.point).toBe(changeValues[index])
})

values.forEach((value, index) => {
const ptr = memoryJS.publicMemoryObj.newobj(value)
memoryJS.publicMemoryObj.changeValue(ptr.value(), changeValues[index])

expect(ptr.point).toBe(changeValues[index])
})
})

test('deletes an object from memory', () => {
const ptr = memoryJS.publicMemoryObj.newobj(55)

expect(ptr.free()).toBe(null)
})

test('encapsulates object content', () => {
const ptr = memoryJS.publicMemoryObj.newobj(55)

Object.keys(ptr).forEach((key) => {
expect(typeof ptr[key]).toBe('function')
})
})
28 changes: 25 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"example": "examples"
},
"scripts": {
"test": "standard memory.js"
"test": "jest",
"test:coverage": "jest --coverage",
"standard": "standard --fix",
"validate": "npm run standard && npm run test"
},
"repository": {
"type": "git",
Expand All @@ -21,9 +24,28 @@
"memoryjs"
],
"author": "unsuitable001",
"license": "ISC",
"license": "MIT",
"bugs": {
"url": "https://github.com/unsuitable001/memoryJS/issues"
},
"homepage": "https://github.com/unsuitable001/memoryJS#readme"
"homepage": "https://github.com/unsuitable001/memoryJS#readme",
"devDependencies": {
"husky": "^3.0.9",
"jest": "^24.9.0",
"lint-staged": "^9.4.2",
"standard": "^14.3.1"
},
"standard": {
"env": [
"jest"
]
},
"jest": {
"testEnvironment": "node"
},
"husky": {
"hooks": {
"pre-commit": "npm run validate"
}
}
}
6 changes: 6 additions & 0 deletions scripts/report-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
if [ "$TRAVIS_BRANCH" == "master" ]; then
npm install -g codecov
npm run test:coverage
codecov
fi
1 change: 1 addition & 0 deletions runcheckendline.sh → scripts/runcheckendline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ flag=0
for i in $(find . -type f ! -path "*/*.egg-info/*"\
! -path "./.*"\
! -path "*.min.*"\
! -path "./node_modules/*"\
! -path "*.svg" -exec grep -Iq . {} \; -and -print); do
if [ "$(tail -c 1 $i)" != "" ]; then
echo "$i needs newline at the end"
Expand Down