npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dingle-swift

v0.3.9

Published

Dingle Generator for Swift

Downloads

6

Readme

Dingle Swift

Dingle Generator for Swift

Installation

$ npm install --save dingle-swift

Dependancies

You will need the following module in your project:

pod 'SwiftyJSON', '~> 2.2.0'
pod 'AFNetworking', '~> 2.0'
pod 'CocoaAsyncSocket', '~> 7.4.0'

Usage

Simply require the dingle generator module and specify the directory to build into:

var dingle = require('dingle')({
    http_listen: '0.0.0.0',
    https_listen: '0.0.0.0',
    tcp_listen: '0.0.0.0',
    udp_listen: '0.0.0.0'
});

var generator = require('dingle-swift');
generator.generate(dingle, './exports/swift');

Then simply drop the files generated into your XCode project and use like so:

var myapi = require('./MYAPI.js');

myapi.login("[email protected]", password: "mypassword") { (success, message, output) -> () in
	println(success)
	println(message)
	println(output)
}

Hostnames

When the code is generated your hostnames are automatically taken from the dingle config but you can change it like so:

var myapi = MYAPI();

myapi.hostnames["http"] = "localhost:7691"
myapi.hostnames["https"] = "localhost:7692"
myapi.hostnames["tcp"] = "localhost:7693"
myapi.hostnames["udp"] = "localhost:7694"

myapi.login("[email protected]", password: "mypassword") { (success, message, output) -> () in
	println(success)
	println(message)
	println(output)
}

File Uploads

To upload a file simply specify a NSURL as a parameter as shown below:

var myapi = MYAPI();

myapi.upload_file(NSURL(fileURLWithPath: "/Users/Me/Downloads/file.dump"), methods: [ "POST", "GET" ], callback: { (success, message, output) -> () in
	println(success)
	println(message)
	println(output)
}, uploading: { (size, remaining, percentage) -> Void in
	println("Upload at \(percentage)")
}, downloading: { (size, remaining, percentage) -> Void in
	println("Download at \(percentage)")
}, stream: nil)

File Downloads

When downloading a file you must specify a NSOutputStream to write to and once the download is complete the stream will be returned in the output variable callback:

var myapi = MYAPI();

myapi.download_file("[email protected]", methods: [ "POST", "GET" ], callback: { (success, message, output) -> () in
	println(success)
	println(message)
	println(output)
}, uploading: { (size, remaining, percentage) -> Void in
	println("Upload at \(percentage)")
}, downloading: { (size, remaining, percentage) -> Void in
	println("Download at \(percentage)")
}, stream: NSOutputStream(toFileAtPath: "/Users/Me/Downloads/file.dump", append: false))

Choosing Method

By default dingle will auto choose each method depending on the order of which they are specified in the function but we can override this like so:

var myapi = MYAPI();

myapi.login("[email protected]", password: "mypassword", methods: [ "POST", "TCP" ]) { (success, message, output) -> () in
	println(success)
	println(message)
	println(output)
}

Methods

The following methods are supported:

  • TCP
  • UDP
  • POST
  • GET
  • PUT
  • DELETE
  • OPTIONS
  • HEAD
  • PATCH
  • TRACE
  • CONNECT